RFR: 8283541: Add Statical counters and some comments in PhaseStringOpts [v3]

Xin Liu xliu at openjdk.java.net
Tue Apr 19 19:18:26 UTC 2022


On Tue, 19 Apr 2022 17:16:07 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> Add 3 counters for `OptimizeStringConcat`.  Total is the total number of StringBuilder/Buffer.toString() encountered.  if it matches, it is either merged or replaced. 
>> 
>> 1. For each StringConcat, increase `total` counter.
>> 2. merged: this phase realizes that it can coalesce 2 StringConcats, or 
>> 3. replaced: this phase replace a StringConcat with a new String. 
>> 
>> In the following example, javac encounters 79 StringConcats, 4 of them are merged with their successors.  41 have been replaced.  The remaining 34 are mismatched in `build_candidate`. 
>> 
>> $./build/linux-x86_64-server-fastdebug/images/jdk/bin/javac -J-Xcomp -J-XX:+PrintOptoStatistics
>> 
>> --- Compiler Statistics ---
>> Methods seen: 13873  Methods parsed: 13873  Nodes created: 3597636
>> Blocks parsed: 42441  Blocks seen: 46403
>> 50086 original NULL checks - 41382 elided (82%); optimizer leaves 13545,
>> 3671 made implicit (27%)
>> 36 implicit null exceptions at runtime
>> StringConcat:   41/   4/  79(replaced/merged/total)
>> ...
>
> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update typo
>   
>   Co-authored-by: Tobias Hartmann <tobias.hartmann at oracle.com>

I grep "-DstringConcat=inline" in make directory.  "stringConcate=inline" is indeed used to build javac! That explains why example above reports 79 encounters in javac.  thanks for the head-up

-------------

PR: https://git.openjdk.java.net/jdk/pull/7933


More information about the hotspot-compiler-dev mailing list