RFR: 8357289: Break down the String constructor into smaller methods [v4]

Shaojin Wen swen at openjdk.org
Sun May 25 05:53:10 UTC 2025


> 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:

  Update src/java.base/share/classes/java/lang/String.java
  
  Co-authored-by: Chen Liang <liach at openjdk.org>

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25290/files
  - new: https://git.openjdk.org/jdk/pull/25290/files/fab7728b..4fe4b89d

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25290&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25290&range=02-03

  Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/25290.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25290/head:pull/25290

PR: https://git.openjdk.org/jdk/pull/25290


More information about the core-libs-dev mailing list