Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 4.14 KB

File metadata and controls

65 lines (48 loc) · 4.14 KB

This document describes the process of creating an AOTCache (using -XX:AOTCacheOutput) file by walking through the JDK codebase.

  1. First the JVM calls its main program.
  2. Then it sets up argc and argv which can be printed in gdb using -exec x/s or -exec p.
  3. There is a new thread which is spawned here.
  4. The new thread almost begins here.
  5. The VM creation calls universe_init which I think is responsible for setting up AOTCache settings.

Thread that runs Hello

The goal of this is to know how AOTCache memory is dumped into a file.

Do not click this on 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.cpp has lines 1317-1327 which setups the arguments. For example, it converts -XX:AOTCacheOutput to -XX:AOTMode=create. =record is done somewhere before.
  • src/hotspot/share/cds/aotMetaspace.cpp:1321 starts the creation of the AOTCache file.
  • src/hotspot/share/cds/aotMetaspace.cpp:345 goes to src/hotspot/share/cds/filemap.cpp:773 and 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.