This document describes the process of creating an AOTCache (using -XX:AOTCacheOutput) file by walking through the JDK codebase.
- First the JVM calls its main program.
- Then it sets up argc and argv which can be printed in
gdbusing-exec x/sor-exec p. - There is a new thread which is spawned here.
- The new thread almost begins here.
- The VM creation calls universe_init which I think is responsible for setting up AOTCache settings.
The goal of this is to know how AOTCache memory is dumped into a file.
Do not click
thison frame "filemapcpp:open_as_output()". It hangs the debugger.
rs = MemoryReserver::reserve((char*)base,
size,
Metaspace::reserve_alignment(),
os::vm_page_size(),
mtClass);This can be used for reserving memory.
_base is 0x88000000 (unsure how this is computed)
_size is 1073741824 (unsure why it decides to save ~1GB)
Metaspace::reserve_alignment seems to be metaspace::Settings::virtual_space_node_reserve_alignment_words() x BytesPerWord
os::vm_page_size() seems constant 4096
Here the space allocation completes.
It has exact same size as _size. Size is calculated based on _class_space_end - _class_space_start
Not sure what CompressedClassPointers are.
Important to put a breakpoint here as it just finishes after Metaspace::global_initialize();.
before_exit starts dumping .aot.config. This is the entry point when dumping aot config archives
This function dumps aot.config.
link_all_loaded_classes
can be used for linking classes during merge.
if (CDSConfig::is_dumping_preimage_static_archive()) {
AOTMetaspace::dump_static_archive(thread);
}The above code block comes here.
Not sure what op
stands for but it seems it is responsible for serialization in a separate thread.
This is called in before_exit but as you can see that it is only called when we are dumping conf.
fork_and_dump_final_static_archive
src/hotspot/share/cds/aotMetaspace.cpphas lines1317-1327which setups the arguments. For example, it converts-XX:AOTCacheOutputto-XX:AOTMode=create.=recordis done somewhere before.src/hotspot/share/cds/aotMetaspace.cpp:1321starts the creation of the AOTCache file.src/hotspot/share/cds/aotMetaspace.cpp:345goes tosrc/hotspot/share/cds/filemap.cpp:773and writes the AOTCache to disk.
If you want to reconstruct AOTCache contents, you effectively have to follow what ArchiveBuilder and AOTMapLogger do, rather than looking for an extra on‑disk schema beyond the header+region metadata.