< 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"

@@ -426,23 +427,34 @@
      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) {}
  
    bool do_bit(size_t offset) {
      Metadata** p = _start + offset;
      *p = (Metadata*)(address(*p) + MetaspaceShared::relocation_delta());
-     // Currently we have only Klass pointers in heap objects.
-     // This needs to be relaxed when we support other types of native
-     // pointers such as Method.
-     assert(((Klass*)(*p))->is_klass(), "must be");
      return true;
    }
  };
  
  void ArchiveHeapLoader::patch_native_pointers() {
< prev index next >