< prev index next >

src/hotspot/share/cds/archiveUtils.cpp

Print this page
@@ -31,10 +31,11 @@
  #include "cds/dynamicArchive.hpp"
  #include "cds/filemap.hpp"
  #include "cds/heapShared.hpp"
  #include "cds/lambdaProxyClassDictionary.hpp"
  #include "cds/metaspaceShared.hpp"
+ #include "classfile/classLoader.hpp"
  #include "classfile/systemDictionaryShared.hpp"
  #include "classfile/vmClasses.hpp"
  #include "interpreter/bootstrapInfo.hpp"
  #include "memory/metaspaceUtils.hpp"
  #include "memory/resourceArea.hpp"

@@ -48,18 +49,20 @@
  #include "utilities/spinYield.hpp"
  
  CHeapBitMap* ArchivePtrMarker::_ptrmap = nullptr;
  CHeapBitMap* ArchivePtrMarker::_rw_ptrmap = nullptr;
  CHeapBitMap* ArchivePtrMarker::_ro_ptrmap = nullptr;
+ CHeapBitMap* ArchivePtrMarker::_ac_ptrmap = nullptr;
  VirtualSpace* ArchivePtrMarker::_vs;
  
  bool ArchivePtrMarker::_compacted;
  
  void ArchivePtrMarker::initialize(CHeapBitMap* ptrmap, VirtualSpace* vs) {
    assert(_ptrmap == nullptr, "initialize only once");
    assert(_rw_ptrmap == nullptr, "initialize only once");
    assert(_ro_ptrmap == nullptr, "initialize only once");
+   assert(_ac_ptrmap == nullptr, "initialize only once");
    _vs = vs;
    _compacted = false;
    _ptrmap = ptrmap;
  
    // Use this as initial guesstimate. We should need less space in the

@@ -71,44 +74,54 @@
  
    // We need one bit per pointer in the archive.
    _ptrmap->initialize(estimated_archive_size / sizeof(intptr_t));
  }
  
- void ArchivePtrMarker::initialize_rw_ro_maps(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap) {
+ void ArchivePtrMarker::initialize_rw_ro_ac_maps(CHeapBitMap* rw_ptrmap, CHeapBitMap* ro_ptrmap, CHeapBitMap* ac_ptrmap) {
    address* buff_bottom = (address*)ArchiveBuilder::current()->buffer_bottom();
    address* rw_bottom   = (address*)ArchiveBuilder::current()->rw_region()->base();
    address* ro_bottom   = (address*)ArchiveBuilder::current()->ro_region()->base();
+   address* ac_bottom   = (address*)ArchiveBuilder::current()->ac_region()->base();
  
-   // The bit in _ptrmap that cover the very first word in the rw/ro regions.
+   // The bit in _ptrmap that cover the very first word in the rw/ro/ac regions.
    size_t rw_start = rw_bottom - buff_bottom;
    size_t ro_start = ro_bottom - buff_bottom;
+   size_t ac_start = ac_bottom - buff_bottom;
  
    // The number of bits used by the rw/ro ptrmaps. We might have lots of zero
    // bits at the bottom and top of rw/ro ptrmaps, but these zeros will be
    // removed by FileMapInfo::write_bitmap_region().
    size_t rw_size = ArchiveBuilder::current()->rw_region()->used() / sizeof(address);
    size_t ro_size = ArchiveBuilder::current()->ro_region()->used() / sizeof(address);
+   size_t ac_size = ArchiveBuilder::current()->ac_region()->used() / sizeof(address);
  
    // The last (exclusive) bit in _ptrmap that covers the rw/ro regions.
    // Note: _ptrmap is dynamically expanded only when an actual pointer is written, so
    // it may not be as large as we want.
    size_t rw_end = MIN2<size_t>(rw_start + rw_size, _ptrmap->size());
    size_t ro_end = MIN2<size_t>(ro_start + ro_size, _ptrmap->size());
+   size_t ac_end = MIN2<size_t>(ac_start + ac_size, _ptrmap->size());
  
    rw_ptrmap->initialize(rw_size);
    ro_ptrmap->initialize(ro_size);
+   ac_ptrmap->initialize(ac_size);
  
    for (size_t rw_bit = rw_start; rw_bit < rw_end; rw_bit++) {
      rw_ptrmap->at_put(rw_bit - rw_start, _ptrmap->at(rw_bit));
    }
  
    for(size_t ro_bit = ro_start; ro_bit < ro_end; ro_bit++) {
      ro_ptrmap->at_put(ro_bit - ro_start, _ptrmap->at(ro_bit));
    }
  
+   for (size_t ac_bit = ac_start; ac_bit < ac_end; ac_bit++) {
+     ac_ptrmap->at_put(ac_bit - ac_start, _ptrmap->at(ac_bit));
+   }
+ 
    _rw_ptrmap = rw_ptrmap;
    _ro_ptrmap = ro_ptrmap;
+   _ac_ptrmap = ac_ptrmap;
  }
  
  void ArchivePtrMarker::mark_pointer(address* ptr_loc) {
    assert(_ptrmap != nullptr, "not initialized");
    assert(!_compacted, "cannot mark anymore");

@@ -298,12 +311,10 @@
  void DumpRegion::pack(DumpRegion* next) {
    if (!is_packed()) {
      _end = (char*)align_up(_top, MetaspaceShared::core_region_alignment());
      _is_packed = true;
    }
-   _end = (char*)align_up(_top, MetaspaceShared::core_region_alignment());
-   _is_packed = true;
    if (next != nullptr) {
      next->_rs = _rs;
      next->_vs = _vs;
      next->_base = next->_top = this->_end;
      next->_end = _rs->end();

@@ -379,10 +390,60 @@
        }
      }
    }
  }
  
+ 
+ // "boot", "platform", "app" or nullptr
+ const char* ArchiveUtils::builtin_loader_name_or_null(oop loader) {
+   if (loader == nullptr) {
+     return "boot";
+   } else if (loader == SystemDictionary::java_platform_loader()) {
+     return "platform";
+   } else if (loader == SystemDictionary::java_system_loader()) {
+     return "app";
+   } else {
+     return nullptr;
+   }
+ }
+ 
+ // "boot", "platform", "app". Asserts if not a built-in-loader
+ const char* ArchiveUtils::builtin_loader_name(oop loader) {
+   const char* name = builtin_loader_name_or_null(loader);
+   assert(name != nullptr, "must be a built-in loader");
+   return name;
+ }
+ 
+ bool ArchiveUtils::builtin_loader_from_type(const char* loader_type, oop* value_ret) {
+   if (strcmp(loader_type, "boot") == 0) {
+     *value_ret = nullptr;
+     return true;
+   } else if (strcmp(loader_type, "platform") == 0) {
+     *value_ret = SystemDictionary::java_platform_loader();
+     return true;
+   } else if (strcmp(loader_type, "app") == 0) {
+     *value_ret = SystemDictionary::java_system_loader();
+     return true;
+   } else {
+     DEBUG_ONLY(*value_ret = cast_to_oop((void*)badOopVal));
+     return false;
+   }
+ }
+ 
+ oop ArchiveUtils::builtin_loader_from_type(int loader_type) {
+   if (loader_type == ClassLoader::BOOT_LOADER) {
+     return nullptr;
+   } else if (loader_type == ClassLoader::PLATFORM_LOADER)  {
+     return SystemDictionary::java_platform_loader();
+   } else if (loader_type == ClassLoader::APP_LOADER) {
+     return SystemDictionary::java_system_loader();
+   } else {
+     ShouldNotReachHere();
+     return nullptr;
+   }
+ }
+ 
  bool ArchiveUtils::has_aot_initialized_mirror(InstanceKlass* src_ik) {
    if (SystemDictionaryShared::is_excluded_class(src_ik)) {
      assert(!ArchiveBuilder::current()->has_been_buffered(src_ik), "sanity");
      return false;
    }
< prev index next >