RFR: 8357289: Break down the String constructor into smaller methods
Shaojin Wen
swen at openjdk.org
Tue May 20 01:23:51 UTC 2025
On Sun, 18 May 2025 20:44:12 GMT, Chen Liang <liach at openjdk.org> 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.
>
> src/java.base/share/classes/java/lang/String.java line 690:
>
>> 688: .onUnmappableCharacter(CodingErrorAction.REPLACE);
>> 689: char[] ca = new char[en];
>> 690: int caLen = decodeWithDecoder(cd, ca, bytes, offset, length);
>
> Let's restore the CharacterCodingException for now. I don't think we should change the exceptions as part of the break down.
Restoring the exception handling here will cause the codeSize of the create method to be greater than 325. This exception will not occur here, so the exception handling is moved to decodeWithDecoder.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25290#discussion_r2096683192
More information about the core-libs-dev
mailing list