On Tue, 20 May 2025 02:11:34 GMT, Shaojin Wen <[email protected]> wrote:
>> Through JVM Option +PrintInlining, we found that String has a constructor
>> codeSize of 852, which is too large. This caused failed to inline.
>>
>> The following is the output information of PrintInlining:
>>
>> @ 9 java.lang.String::<init> (12 bytes) inline (hot)
>> !m @ 1 java.nio.charset.Charset::defaultCharset (52 bytes)
>> inline (hot)
>> ! @ 8 java.lang.String::<init> (852 bytes) failed to
>> inline: hot method too big
>>
>>
>> In Java code, the big method that cannot be inlined is the following
>> constructor
>>
>>
>> String(Charset charset, byte[] bytes, int offset, int length) {}
>>
>> The above String constructor is too large; break it down into smaller
>> methods with a codeSize under 325 to allow them to be inlined by the C2.
>
> Shaojin Wen has updated the pull request incrementally with one additional
> commit since the last revision:
>
> create method share variant val & coder
src/java.base/share/classes/java/lang/String.java line 569:
> 567: }
> 568: this.value = str.value;
> 569: this.coder = str.coder;
Suggestion:
this(str);
We have integrated flexible constructor bodies.
src/java.base/share/classes/java/lang/String.java line 646:
> 644: }
> 645:
> 646: private static String create(Charset charset, byte[] bytes, int
> offset, int length) {
Should we call this "decode", as "create" feels too generic?
src/java.base/share/classes/java/lang/String.java line 703:
> 701: throw new Error(x);
> 702: }
> 703: if (COMPACT_STRINGS) {
Now we can call other constructors of String, so instead of having this manual
handling of char[], we can call `return new String(ca, 0, caLen, null)`. Same
for the `clen` version above.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25290#discussion_r2106082898
PR Review Comment: https://git.openjdk.org/jdk/pull/25290#discussion_r2106082727
PR Review Comment: https://git.openjdk.org/jdk/pull/25290#discussion_r2106082563