< prev index next >

src/hotspot/share/classfile/moduleEntry.cpp

Print this page
@@ -465,11 +465,11 @@
    assert(DumpSharedSpaces, "static dump only");
    oop module_obj = module();
    if (module_obj != NULL) {
      oop m = HeapShared::find_archived_heap_object(module_obj);
      assert(m != NULL, "sanity");
-     _archived_module_narrow_oop = CompressedOops::encode(m);
+     _archived_module_index = HeapShared::append_root(m);
    }
    assert(shared_protection_domain() == NULL, "never set during -Xshare:dump");
    // Clear handles and restore at run time. Handles cannot be archived.
    OopHandle null_handle;
    _module = null_handle;

@@ -479,12 +479,12 @@
    set_loader_data(loader_data);
    _reads = restore_growable_array((Array<ModuleEntry*>*)_reads);
    JFR_ONLY(INIT_ID(this);)
  }
  
- void ModuleEntry::restore_archive_oops(ClassLoaderData* loader_data) {
-   Handle module_handle(Thread::current(), HeapShared::materialize_archived_object(_archived_module_narrow_oop));
+ void ModuleEntry::restore_archived_oops(ClassLoaderData* loader_data) {
+   Handle module_handle(Thread::current(), HeapShared::get_root(_archived_module_index, /*clear=*/true));
    assert(module_handle.not_null(), "huh");
    set_module(loader_data->add_handle(module_handle));
  
    // This was cleared to zero during dump time -- we didn't save the value
    // because it may be affected by archive relocation.

@@ -493,10 +493,14 @@
    if (loader_data->class_loader() != NULL) {
      java_lang_Module::set_loader(module_handle(), loader_data->class_loader());
    }
  }
  
+ void ModuleEntry::clear_archived_oops() {
+   HeapShared::clear_root(_archived_module_index);
+ }
+ 
  static int compare_module_by_name(ModuleEntry* a, ModuleEntry* b) {
    assert(a == b || a->name() != b->name(), "no duplicated names");
    return a->name()->fast_compare(b->name());
  }
  

@@ -559,11 +563,11 @@
  
  void ModuleEntryTable::restore_archived_oops(ClassLoaderData* loader_data, Array<ModuleEntry*>* archived_modules) {
    assert(UseSharedSpaces, "runtime only");
    for (int i = 0; i < archived_modules->length(); i++) {
      ModuleEntry* archived_entry = archived_modules->at(i);
-     archived_entry->restore_archive_oops(loader_data);
+     archived_entry->restore_archived_oops(loader_data);
    }
  }
  #endif // INCLUDE_CDS_JAVA_HEAP
  
  ModuleEntry* ModuleEntryTable::new_entry(unsigned int hash, Handle module_handle,
< prev index next >