RFR: 8341696: C2: Non-fluid StringBuilder pattern bails out in OptoStringConcat [v4]

Emanuel Peter epeter at openjdk.org
Wed Jan 8 13:56:43 UTC 2025


On Thu, 12 Dec 2024 09:55:24 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:
> 
>   Fix test name

src/hotspot/share/opto/stringopts.cpp line 613:

> 611:         } else if (use != nullptr &&
> 612:                    check_append_candidate(use, sc, m, string_sig, int_sig, char_sig) == CheckAppendResult::GiveUp) {
> 613:           return nullptr;

What happens here in the two other cases `GoodAppend` and `NotAppend`?

src/hotspot/share/opto/stringopts.cpp line 643:

> 641: 
> 642:       if (result == CheckAppendResult::GiveUp) {
> 643:         break;

Can you put a comment here where this is supposed to jump, and why?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22537#discussion_r1907211458
PR Review Comment: https://git.openjdk.org/jdk/pull/22537#discussion_r1907213010


More information about the hotspot-compiler-dev mailing list