HeapShared::get_archived_object_permanent_index() is a new API added in Leyden/premain to support the AOT compiler. It is possible for the AOT compiler to ask for a "permanent index" for any archived oop (including those that are covered by HeapShared::get_root()).
This API is not implemented in streaming mode:
$ gdb --args java -cp HelloWorld.jar -XX:+UseZGC -XX:AOTMode=create -Xlog:aot,cds -XX:AOTCache=hw.aot -XX:AOTConfiguration=hw.aotconfig
Thread 56 "C2 Comp..hread8" hit Breakpoint 2, HeapShared::get_archived_object_permanent_index (obj=0x40000a1cf78)
at /jdk3/le4/open/src/hotspot/share/cds/heapShared.cpp:502
502 MutexLocker ml(ArchivedObjectTables_lock, Mutex::_no_safepoint_check_flag);
(gdb) n
504 if (!CDSConfig::is_dumping_heap()) {
(gdb)
507 if (_dumptime_permanent_oop_table == nullptr) {
(gdb)
508 return -1;
(gdb) where
#0 HeapShared::get_archived_object_permanent_index (obj=0x40000a1cf78) at /jdk3/le4/open/src/hotspot/share/cds/heapShared.cpp:502
#1 0x00007ffff5830ea2 in AOTCacheAccess::get_archived_object_permanent_index (obj=0x40000a1cf78)
at /jdk3/le4/open/src/hotspot/share/cds/aotCacheAccess.cpp:78
#2 0x00007ffff5849f81 in AOTCodeCache::write_oop (this=0x7ffff01652d0, obj=0x40000a1cf78)
at /jdk3/le4/open/src/hotspot/share/code/aotCodeCache.cpp:2578
#3 0x00007ffff5848471 in AOTCodeCache::write_nmethod_reloc_immediates (this=0x7ffff01652d0, oop_list=..., metadata_list=...)
at /jdk3/le4/open/src/hotspot/share/code/aotCodeCache.cpp:2225
#4 0x00007ffff5845d06 in AOTCodeCache::write_nmethod (this=0x7ffff01652d0, nm=0x7fffdf481e08, for_preload=true)
at /jdk3/le4/open/src/hotspot/share/code/aotCodeCache.cpp:1725
#5 0x00007ffff58452f3 in AOTCodeCache::store_nmethod (nm=0x7fffdf481e08, compiler=0x7ffff023acb0, for_preload=true)
at /jdk3/le4/open/src/hotspot/share/code/aotCodeCache.cpp:1593
Because of this, the AOT code is less efficient. When the permanent index cannot be obtained for an oop, we will get an uncommon trap.