< prev index next >

src/hotspot/share/cds/archiveHeapLoader.cpp

Print this page
*** 27,10 ***
--- 27,11 ---
  #include "cds/cdsConfig.hpp"
  #include "cds/heapShared.hpp"
  #include "cds/metaspaceShared.hpp"
  #include "classfile/classLoaderDataShared.hpp"
  #include "classfile/systemDictionaryShared.hpp"
+ #include "classfile/vmClasses.hpp"
  #include "gc/shared/collectedHeap.hpp"
  #include "logging/log.hpp"
  #include "memory/iterator.inline.hpp"
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"

*** 438,10 ***
--- 439,25 ---
      HeapWord* top = (HeapWord*)_loaded_heap_top;
      Universe::heap()->fill_with_objects(bottom, top - bottom);
    }
  }
  
+ oop ArchiveHeapLoader::oop_from_offset(int offset) {
+   // Once GC starts, the offsets saved in CachedCodeDirectoryInternal::_permanent_oop_offsets
+   // will become invalid. I don't know what function can check if GCs are allowed, but surely
+   // GCs can't happen before the Object class is loaded.
+   assert(CDSConfig::is_using_archive(), "sanity");
+   assert(vmClasses::Object_klass()->class_loader_data() == nullptr,
+          "can be called only very early during VM start-up");
+   if (is_loaded()) {
+     return cast_to_oop(_loaded_heap_bottom + offset);
+   } else {
+     assert(is_mapped(), "must be");
+     return cast_to_oop(_mapped_heap_bottom + offset);
+   }
+ }
+ 
  class PatchNativePointers: public BitMapClosure {
    Metadata** _start;
  
   public:
    PatchNativePointers(Metadata** start) : _start(start) {}
< prev index next >