RFR: 8333893: Optimization for StringBuilder append boolean & null [v15]

Chen Liang liach at openjdk.org
Tue Jul 23 13:28:40 UTC 2024


On Tue, 23 Jul 2024 12:57:52 GMT, Shaojin Wen <duke at openjdk.org> wrote:

>> After PR https://github.com/openjdk/jdk/pull/16245, C2 optimizes stores into primitive arrays by combining values ​​into larger stores.
>> 
>> This PR rewrites the code of appendNull and append(boolean) methods so that these two methods can be optimized by C2.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   replace unsafe with putChar

Changes requested by liach (Reviewer).

src/java.base/share/classes/java/lang/StringLatin1.java line 832:

> 830:     static void putCharsAt(byte[] val, int index, int c1, int c2, int c3, int c4) {
> 831:         assert index >= 0 && index + 3 < length(val) : "Trusted caller missed bounds check";
> 832:         // Don't use the putChar method, Its instrinsic will cause C2 unable to combining values into larger stores.

`StringLatin1` has no `putChar` method. I think you can just convert this to explicit array stores for the merge store optimization.

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

PR Review: https://git.openjdk.org/jdk/pull/19626#pullrequestreview-2193985500
PR Review Comment: https://git.openjdk.org/jdk/pull/19626#discussion_r1688061453


More information about the hotspot-compiler-dev mailing list