RFR: 8374828: Save load_barrier_on_oop_field_preloaded in aot CodeCache

Ioi Lam iklam at openjdk.org
Tue Jan 13 18:05:37 UTC 2026


On Tue, 13 Jan 2026 13:41:45 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> > What I care more about is the AOT cache shipped with the JDK, which does not embed any compiled code. It's important that these archives are offered for all GCs, despite not knowing which GC will be selected. Is that still the case?
> 
> I don't know the answer to this. @iklam or @vnkozlov could you look at this PR and comment?

Compiled code is not included in the default CDS archive (aka the AOT cache shipped with the JDK), or any "old" CDS archives generated with the -Xshare:dump option (`ac` is the "AOT Code" region):


$ java -Xshare:dump -Xlog:cds | grep region..ac
[0.416s][info][cds] Shared file region (ac) 4:        0 bytes
$ java -Xshare:dump --enable-preview -Xlog:cds | grep region..ac
[0.436s][info][cds] Shared file region (ac) 4:        0 bytes
$ java -Xshare:dump --enable-preview -XX:+UseZGC -Xlog:cds | grep region..ac
[0.429s][info][cds] Shared file region (ac) 4:        0 bytes
$ java -Xshare:dump --enable-preview -XX:+AOTClassLinking -Xlog:cds | grep region..ac
[0.415s][info][cds] Shared file region (ac) 4:        0 bytes


Compiled code *is* included in AOT archives generated with `-XX:AOTMode=create -XX:AOTCache=xxx` or `-XX:AOTCacheOutput=xxx`:


$ java -XX:+UseSerialGC -Xlog:aot -cp HelloWorld.jar -XX:AOTCacheOutput=hw.aot HelloWorld | grep region..ac
[1.722s][info][aot] Shared file region (ac) 4:        0 bytes
Picked up JAVA_TOOL_OPTIONS: -Djava.class.path=HelloWorld.jar -XX:+UseSerialGC -Xlog:aot -XX:AOTCacheOutput=hw.aot -XX:AOTConfiguration=hw.aot.config -XX:AOTMode=create
[1.387s][info][aot] Shared file region (ac) 4:   303480 bytes, addr 0x0000000800a37000 file offset 0x00a37000 crc 0x02b369fd

$ java -XX:+UseSerialGC -cp HelloWorld.jar -XX:AOTCache=hw.aot -Xlog:aot*=debug HelloWorld | grep codecache
[.....]
[0.003s][debug][aot,codecache,init] Mapped 249856 bytes at address 0x000071bc10ef1000 at AOT Code Cache
[0.003s][info ][aot,codecache,init] Loaded 322 AOT code entries from AOT Code Cache
[0.003s][debug][aot,codecache,init]   Adapters:  total=322
[0.003s][debug][aot,codecache,init]   Shared Blobs: total=0
[0.003s][debug][aot,codecache,init]   C1 Blobs: total=0
[0.003s][debug][aot,codecache,init]   C2 Blobs: total=0
[0.003s][debug][aot,codecache,init]   AOT code cache size: 243680 bytes
[0.003s][debug][aot,codecache,init] External addresses recorded
[0.003s][info ][aot,codecache,init] Early stubs recorded
[0.003s][debug][aot,codecache,init] Early shared blobs recorded
[0.003s][debug][aot,codecache,stubs] Reading blob '' (id=1, kind=Adapter) from AOT Code Cache
[0.003s][debug][aot,codecache,init ] Read 322 entries table at offset 225648 from AOT Code Cache
[0.003s][debug][aot,codecache,stubs] Read blob '' (id=1, kind=Adapter) from AOT Code Cache
[0.003s][debug][aot,codecache,stubs] Reading blob 'DI' (id=98, kind=Adapter) from AOT Code Cache
...


However, if this AOT cache is not using the same GC that was used to create the cache, the code cache will be disabled. The rest of the AOT cache will still be used.


$ java -XX:-UseSerialGC -cp HelloWorld.jar -XX:AOTCache=hw.aot -Xlog:aot*=debug HelloWorld | grep codecache
[0.004s][debug][aot,codecache,init] Mapped 249856 bytes at address 0x0000748bcee9c000 at AOT Code Cache
[0.004s][info ][aot,codecache,init] Loaded 322 AOT code entries from AOT Code Cache
[0.004s][debug][aot,codecache,init]   Adapters:  total=322
[0.004s][debug][aot,codecache,init]   Shared Blobs: total=0
[0.004s][debug][aot,codecache,init]   C1 Blobs: total=0
[0.004s][debug][aot,codecache,init]   C2 Blobs: total=0
[0.004s][debug][aot,codecache,init]   AOT code cache size: 243680 bytes
[0.004s][debug][aot,codecache,init] AOT Code Cache disabled: it was created with different GC: serial gc vs current g1 gc
[0.004s][info ][aot,codecache,init] Unable to use AOT Code Cache.


So with Valhalla, after this PR, ZGC-specific operations will be baked into the `ac` region, but this region will not be used unless ZGC is selected in the production run.

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

PR Comment: https://git.openjdk.org/jdk/pull/29129#issuecomment-3745672633


More information about the hotspot-compiler-dev mailing list