RFR: 8293291: Simplify relocation of native pointers in archive heap
    Calvin Cheung 
    ccheung at openjdk.org
       
    Fri Sep 16 22:47:06 UTC 2022
    
    
  
On Thu, 15 Sep 2022 20:49:24 GMT, Ioi Lam <iklam at openjdk.org> wrote:
> Some objects in the archive heap contain native pointers. E.g., archived `java.lang.Class` objects contain a pointer to its `Klass*`.
> 
> At runtime, if the archived metadata are mapped at an alternative address, all of the `Klass*` pointers must be relocated. Instead of doing this in an ad-hoc way, this PR uses a bitmap, `FileMapRegion::ptrmap_view()`, to track the position of all the native pointers.
> 
> This PR is done in preparation for supporting new types of archived heap objects that have native pointers. E.g., `java.lang.invoke.ResolvedMethodName` has a pointer to a `Method*`.
> 
> 
> Notes for reviewers:
> 
> - At dump time, the native pointers are remembered in `HeapShared::mark_native_pointers()`.
> - At runtime, the native pointers are patched in `ArchiveHeapLoader::patch_native_pointers()`.
> - The ad-hoc relocation code has been removed from javaClasses.cpp and systemDictionaryShared.cpp
> - Many of the changes are for renaming from "oopmaps" to "bitmaps": the old code handled only a single type of pointers (oop references). The new code handles two types of bitmaps ("oopmap" is for oop references, "ptrmap" is for native pointers).
I've a few minor comments. Thanks.
src/hotspot/share/cds/filemap.cpp line 1693:
> 1691:       int oopmap_idx = i * 2;
> 1692:       int ptrmap_idx = i * 2 + 1;
> 1693:       space_at(region_idx)->init_bitmaps(bitmaps->at(i*2), bitmaps->at(i*2 + 1));
Please add some comment on oopmap_idx and ptrmap_idx.
Line 1693 could be:
`space_at(region_idx)->init_bitmaps(bitmaps->at(oopmap_idx), bitmaps->at(ptrmap_idx));`
src/hotspot/share/cds/heapShared.cpp line 1848:
> 1846:   }
> 1847: 
> 1848:   log_info(cds, heap)("calculate_ptrmap: marked %d non-null native pointers our of "
typo: our -> out
src/hotspot/share/cds/metaspaceShared.cpp line 907:
> 905:                                                    GrowableArray<ArchiveHeapOopmapInfo>* oopmaps) {
> 906:   for (int i=0; i<regions->length(); i++) {
> 907:     ResourceBitMap oopmap = HeapShared::calculate_oopmap(regions->at(i));
Pre-existing: line 908.
While you're touching this code, please add a space before and after the '=' and '<'.
src/hotspot/share/include/cds.h line 59:
> 57:                               // for alignment purposed.
> 58:   size_t  _oopmap_offset;     // Bitmap for relocating oop fields in archived heap objects.
> 59:                               // (The base address is the botom of the BM region)
typo: botom -> bottom
src/hotspot/share/include/cds.h line 62:
> 60:   size_t  _oopmap_size_in_bits;
> 61:   size_t  _ptrmap_offset;     // Bitmap for relocating native pointer fields in archived heap objects.
> 62:                               // (The base address is the botom of the BM region).
typo: botom -> bottom
-------------
PR: https://git.openjdk.org/jdk/pull/10296
    
    
More information about the hotspot-runtime-dev
mailing list