RFR: 8357289: Break down the String constructor into smaller methods [v8]
Shaojin Wen
swen at openjdk.org
Fri Jun 27 04:05:40 UTC 2025
On Wed, 25 Jun 2025 00:13:56 GMT, Shaojin Wen <swen 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.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> code format, from @RogerRiggs
Scalar 293 CheckCastPP === 290 288 [[ 430 367 367 430 357 357 ]] #java/lang/String (java/io/Serializable,java/lang/Comparable,java/lang/CharSequence,java/lang/constant/Constable,java/lang/constant/ConstantDesc):NotNull:exact *,iid=276 Oop:java/lang/String (java/io/Serializable,java/lang/Comparable,java/lang/CharSequence,java/lang/constant/Constable,java/lang/constant/ConstantDesc):NotNull:exact *,iid=276 !jvms: String::iso88591 @ bci:6 (line 624) String::<init> @ bci:42 (line 562) String::<init> @ bci:12 (line 1463) StringConstructor::newStringFromBytesCharSet @ bci:12 (line 19) StringConstructorTest::newStringFromBytesCharSet @ bci:25 (line 27)
++++ Eliminated: 276 Allocate
By configuring the JVM startup parameters `-XX:+UnlockDiagnosticVMOptions -XX:+PrintEliminateAllocations` to print the log, the allocated String temporary object escapes successfully
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25290#issuecomment-3011550441
More information about the core-libs-dev
mailing list