RFR: 8336856: Optimize String Concat [v34]

Claes Redestad redestad at openjdk.org
Tue Aug 6 22:55:37 UTC 2024


On Tue, 6 Aug 2024 18:07:16 GMT, Shaojin Wen <duke at openjdk.org> wrote:

>> This PR implements the same algorithm as the current generateMHInlineCopy based on bytecode to improve startup performance.
>
> Shaojin Wen has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - copyright
>  - remove unused import

src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1591:

> 1589:                             }
> 1590:                             cb.loadLocal(kind, nextSlot)
> 1591:                               .invokestatic(CD_StringConcatHelper, "stringSize", methodTypeDesc);

The approach here isn't checking for overflow at all, deferring to the length check in the newArray step. While current tests all pass with this I think we need to maintain checking for overflow as we go, otherwise it'd be possible to construct concatenations where the length overflows to negative and then back again to positive. Let's try this with a new set of `mix` methods.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20273#discussion_r1706191966


More information about the core-libs-dev mailing list