RFR: 8365186: Reduce size of j.t.f.DateTimePrintContext::adjust [v3]

Roger Riggs rriggs at openjdk.org
Wed Aug 20 21:38:41 UTC 2025


On Sun, 10 Aug 2025 03:36:06 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> By adding the JVM startup parameters `-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining` and analyzing the printed log information, and found that the code size of the j.t.f.DateTimePrintContext::adjust method is 382, which is greater than 325, causing inlining failure.
>> 
>> 
>> @ 7   java.time.format.DateTimePrintContext::adjust (382 bytes)   failed to inline: hot method too big
>> 
>> 
>> By splitting the code into `common/uncommon`, and moving the uncommon code into adjust0, the adjust method is kept small and can be inlined by the C2 optimizer.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   from @liach

src/java.base/share/classes/java/time/format/DateTimePrintContext.java line 134:

> 132:      * @return the adjusted temporal, or the original if no overrides are present in the formatter
> 133:      * @implNote Optimizes for the common case where formatters don't specify chronology/time-zone
> 134:      *           by avoiding unnecessary processing. Most formatters have null for these properties.

@implNote should be before @param

src/java.base/share/classes/java/time/format/DateTimePrintContext.java line 146:

> 144:         // The chronology and zone fields of Formatter are usually null,
> 145:         // so the non-null processing code is placed in a separate method
> 146:         return adjustWithOverride(temporal, overrideChrono, overrideZone);

The "so..." doesn't explain much, perhaps:
Placing the non-null cases in a separate method allows more flexible code optimizations"

src/java.base/share/classes/java/time/format/DateTimePrintContext.java line 241:

> 239:             Chronology effectiveChrono,
> 240:             Chronology temporalChrono
> 241:     ) {

Join with previous line.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26633#discussion_r2289343238
PR Review Comment: https://git.openjdk.org/jdk/pull/26633#discussion_r2289347338
PR Review Comment: https://git.openjdk.org/jdk/pull/26633#discussion_r2289356956


More information about the core-libs-dev mailing list