< prev index next >

src/hotspot/share/cds/dynamicArchive.cpp

Print this page
*** 21,17 ***
   * questions.
   *
   */
  
  #include "precompiled.hpp"
  #include "cds/archiveBuilder.hpp"
  #include "cds/archiveHeapWriter.hpp"
  #include "cds/archiveUtils.inline.hpp"
  #include "cds/cds_globals.hpp"
  #include "cds/cdsConfig.hpp"
- #include "cds/classPrelinker.hpp"
  #include "cds/dynamicArchive.hpp"
  #include "cds/regeneratedClasses.hpp"
  #include "classfile/classLoader.hpp"
  #include "classfile/classLoaderData.inline.hpp"
  #include "classfile/symbolTable.hpp"
  #include "classfile/systemDictionaryShared.hpp"
--- 21,18 ---
   * questions.
   *
   */
  
  #include "precompiled.hpp"
+ #include "cds/aotClassLinker.hpp"
  #include "cds/archiveBuilder.hpp"
  #include "cds/archiveHeapWriter.hpp"
  #include "cds/archiveUtils.inline.hpp"
  #include "cds/cds_globals.hpp"
  #include "cds/cdsConfig.hpp"
  #include "cds/dynamicArchive.hpp"
+ #include "cds/metaspaceShared.hpp"
  #include "cds/regeneratedClasses.hpp"
  #include "classfile/classLoader.hpp"
  #include "classfile/classLoaderData.inline.hpp"
  #include "classfile/symbolTable.hpp"
  #include "classfile/systemDictionaryShared.hpp"

*** 110,11 ***
      verify_universe("Before CDS dynamic dump");
      DEBUG_ONLY(SystemDictionaryShared::NoClassLoadingMark nclm);
  
      // Block concurrent class unloading from changing the _dumptime_table
      MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
!     SystemDictionaryShared::check_excluded_classes();
  
      if (SystemDictionaryShared::is_dumptime_table_empty()) {
        log_warning(cds, dynamic)("There is no class to be included in the dynamic archive.");
        return;
      }
--- 111,11 ---
      verify_universe("Before CDS dynamic dump");
      DEBUG_ONLY(SystemDictionaryShared::NoClassLoadingMark nclm);
  
      // Block concurrent class unloading from changing the _dumptime_table
      MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
!     SystemDictionaryShared::find_all_archivable_classes();
  
      if (SystemDictionaryShared::is_dumptime_table_empty()) {
        log_warning(cds, dynamic)("There is no class to be included in the dynamic archive.");
        return;
      }

*** 133,10 ***
--- 134,15 ---
      dump_ro_metadata();
      relocate_metaspaceobj_embedded_pointers();
  
      verify_estimate_size(_estimated_metaspaceobj_bytes, "MetaspaceObjs");
  
+     sort_methods();
+ 
+     log_info(cds)("Make classes shareable");
+     make_klasses_shareable();
+ 
      char* serialized_data;
      {
        // Write the symbol table and system dictionaries to the RO space.
        // Note that these tables still point to the *original* objects, so
        // they would need to call DynamicArchive::original_to_target() to

*** 144,27 ***
        assert(current_dump_region() == ro_region(), "Must be RO space");
        SymbolTable::write_to_archive(symbols());
  
        ArchiveBuilder::OtherROAllocMark mark;
        SystemDictionaryShared::write_to_archive(false);
        DynamicArchive::dump_array_klasses();
  
        serialized_data = ro_region()->top();
        WriteClosure wc(ro_region());
        ArchiveBuilder::serialize_dynamic_archivable_items(&wc);
      }
  
      verify_estimate_size(_estimated_hashtable_bytes, "Hashtables");
  
-     sort_methods();
- 
-     log_info(cds)("Make classes shareable");
-     make_klasses_shareable();
- 
      log_info(cds)("Adjust lambda proxy class dictionary");
      SystemDictionaryShared::adjust_lambda_proxy_class_dictionary();
  
      relocate_to_requested();
  
      write_archive(serialized_data);
      release_header();
      DynamicArchive::post_dump();
--- 150,28 ---
        assert(current_dump_region() == ro_region(), "Must be RO space");
        SymbolTable::write_to_archive(symbols());
  
        ArchiveBuilder::OtherROAllocMark mark;
        SystemDictionaryShared::write_to_archive(false);
+ 
        DynamicArchive::dump_array_klasses();
+       AOTClassLinker::write_to_archive();
+       TrainingData::dump_training_data();
  
        serialized_data = ro_region()->top();
        WriteClosure wc(ro_region());
        ArchiveBuilder::serialize_dynamic_archivable_items(&wc);
      }
  
      verify_estimate_size(_estimated_hashtable_bytes, "Hashtables");
  
      log_info(cds)("Adjust lambda proxy class dictionary");
      SystemDictionaryShared::adjust_lambda_proxy_class_dictionary();
  
+     log_info(cds)("Make training data shareable");
+     make_training_data_shareable();
+ 
      relocate_to_requested();
  
      write_archive(serialized_data);
      release_header();
      DynamicArchive::post_dump();

*** 176,10 ***
--- 183,11 ---
    }
  
    virtual void iterate_roots(MetaspaceClosure* it) {
      FileMapInfo::metaspace_pointers_do(it);
      SystemDictionaryShared::dumptime_classes_do(it);
+     TrainingData::iterate_roots(it);
      iterate_primitive_array_klasses(it);
    }
  
    void iterate_primitive_array_klasses(MetaspaceClosure* it) {
      for (int i = T_BOOLEAN; i <= T_LONG; i++) {

*** 232,11 ***
    _header = nullptr;
  }
  
  void DynamicArchiveBuilder::post_dump() {
    ArchivePtrMarker::reset_map_and_vs();
!   ClassPrelinker::dispose();
  }
  
  void DynamicArchiveBuilder::sort_methods() {
    InstanceKlass::disable_method_binary_search();
    for (int i = 0; i < klasses()->length(); i++) {
--- 240,11 ---
    _header = nullptr;
  }
  
  void DynamicArchiveBuilder::post_dump() {
    ArchivePtrMarker::reset_map_and_vs();
!   AOTClassLinker::dispose();
  }
  
  void DynamicArchiveBuilder::sort_methods() {
    InstanceKlass::disable_method_binary_search();
    for (int i = 0; i < klasses()->length(); i++) {

*** 503,13 ***
--- 511,22 ---
    }
  
    log_info(cds, dynamic)("Preparing for dynamic dump at exit in thread %s", current->name());
  
    JavaThread* THREAD = current; // For TRAPS processing related to link_shared_classes
+ 
+   {
+     // FIXME-HACK - make sure we have at least one class in the dynamic archive
+     TempNewSymbol class_name = SymbolTable::new_symbol("sun/nio/cs/IBM850"); // unusual class; shouldn't be used by our tests cases.
+     SystemDictionary::resolve_or_null(class_name, Handle(), Handle(), THREAD);
+     guarantee(!HAS_PENDING_EXCEPTION, "must have this class");
+   }
+ 
    MetaspaceShared::link_shared_classes(false/*not from jcmd*/, THREAD);
    if (!HAS_PENDING_EXCEPTION) {
      // copy shared path table to saved.
+     TrainingData::init_dumptime_table(CHECK); // captures TrainingDataSetLocker
      if (!HAS_PENDING_EXCEPTION) {
        VM_PopulateDynamicDumpSharedSpace op(archive_name);
        VMThread::execute(&op);
        return;
      }

*** 529,10 ***
--- 546,11 ---
    assert(CDSConfig::is_using_archive() && RecordDynamicDumpInfo, "already checked in arguments.cpp");
    assert(ArchiveClassesAtExit == nullptr, "already checked in arguments.cpp");
    assert(CDSConfig::is_dumping_dynamic_archive(), "already checked by check_for_dynamic_dump() during VM startup");
    MetaspaceShared::link_shared_classes(true/*from jcmd*/, CHECK);
    // copy shared path table to saved.
+   TrainingData::init_dumptime_table(CHECK); // captures TrainingDataSetLocker
    VM_PopulateDynamicDumpSharedSpace op(archive_name);
    VMThread::execute(&op);
  }
  
  bool DynamicArchive::validate(FileMapInfo* dynamic_info) {
< prev index next >