MetaspaceClosure is used by archiveBuilder.cpp to copy class metadata into the AOT archive. It is designed to recursively follow pointers such as Klass::_super. However, today it can only follow pointers that are subtypes of MetaspaceObj:
https://github.com/openjdk/jdk/blob/5fd095fb9b8f1d2000760519d42d7d0068b82651/src/hotspot/share/memory/metaspaceClosure.hpp#L340-L361
As we extend the AOT functionality, it becomes necessary to copy metadata that are not allocated as MetaspaceObjs.
For example, InstanceKlass::_package is of the PackageEntry type, which is allocated as a CHeapObj. It cannot be easily converted into a MetaspaceObj, as PackageEntry can be allocated inside a mutex, but MetaspaceObj must not be allocated while holding a mutex (MetaspaceObj allocation can trigger GC).
In addition, PackageEntry::_qualified_exports is a GrowableArray, which can dynamic grow/shrink, so it's not appropriate to allocate it as a MetaspaceObj.
Currently, PackageEntry is copied into the AOT cache using a custom copier:
https://github.com/openjdk/jdk/blob/fa8ea6b32d463a84affa529d37cfb97280503fc6/src/hotspot/share/classfile/packageEntry.cpp#L226-L276
However, we don't want to keep writing such custom copiers. For example, in Valhalla there's a need to copy GrowableArrays related to method adapters.
In the RFE, we extend MetaspaceClosure to cover PackageEntry, ModuleEntry and GrowableArray, and rewrite/simplify the code for copying such data into the AOT cache.
This will make it simpler to add other types of data into the AOT cache.
https://github.com/openjdk/jdk/blob/5fd095fb9b8f1d2000760519d42d7d0068b82651/src/hotspot/share/memory/metaspaceClosure.hpp#L340-L361
As we extend the AOT functionality, it becomes necessary to copy metadata that are not allocated as MetaspaceObjs.
For example, InstanceKlass::_package is of the PackageEntry type, which is allocated as a CHeapObj. It cannot be easily converted into a MetaspaceObj, as PackageEntry can be allocated inside a mutex, but MetaspaceObj must not be allocated while holding a mutex (MetaspaceObj allocation can trigger GC).
In addition, PackageEntry::_qualified_exports is a GrowableArray, which can dynamic grow/shrink, so it's not appropriate to allocate it as a MetaspaceObj.
Currently, PackageEntry is copied into the AOT cache using a custom copier:
https://github.com/openjdk/jdk/blob/fa8ea6b32d463a84affa529d37cfb97280503fc6/src/hotspot/share/classfile/packageEntry.cpp#L226-L276
However, we don't want to keep writing such custom copiers. For example, in Valhalla there's a need to copy GrowableArrays related to method adapters.
In the RFE, we extend MetaspaceClosure to cover PackageEntry, ModuleEntry and GrowableArray, and rewrite/simplify the code for copying such data into the AOT cache.
This will make it simpler to add other types of data into the AOT cache.
- blocks
-
JDK-8373348 [lworld] Cache AdapterHandleEntry::_sig_cc field in AOTCache
-
- Open
-