RFR: 8341696: C2: Non-fluid StringBuilder pattern bails out in OptoStringConcat [v5]
Vladimir Kozlov
kvn at openjdk.org
Thu Jan 16 19:25:42 UTC 2025
On Fri, 10 Jan 2025 09:37:04 GMT, Theo Weidmann <tweidmann at openjdk.org> wrote:
>> Extends stringopts to also recognize non-fluid uses of StringBuilder and optimize them the same way.
>>
>> For example, this basic case was not optimized before and is optimized with this PR:
>>
>>
>> StringBuilder sb = new StringBuilder();
>> sb.append("a");
>> sb.append(a);
>> return sb.toString();
>
> Theo Weidmann has updated the pull request incrementally with one additional commit since the last revision:
>
> Make code more clear
src/hotspot/share/opto/stringopts.cpp line 659:
> 657: cnode->in(TypeFunc::Parms + 1)->dump();
> 658: }
> 659: #endif
This print code could be put into `process_append_candidate()` too as you do for `AbortOptimization`.
src/hotspot/share/opto/stringopts.hpp line 58:
> 56: enum class ProcessAppendResult {
> 57: // Indicates that the candidate was indeed an append and process_append_candidate processed it
> 58: // accordingly (added it to the StringCocat etc.)
`StringCocat` -> `StringConcat`
src/hotspot/share/opto/stringopts.hpp line 67:
> 65: };
> 66:
> 67: // Called from build_candidate. Looks at an "append candidate", a call that might be a call to StringBuilder::append. If so, adds it to the StringConcat.
Please split line.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22537#discussion_r1919082945
PR Review Comment: https://git.openjdk.org/jdk/pull/22537#discussion_r1919068910
PR Review Comment: https://git.openjdk.org/jdk/pull/22537#discussion_r1919069842
More information about the hotspot-compiler-dev
mailing list