< prev index next >

src/hotspot/share/runtime/init.cpp

Print this page
*** 20,12 ***
--- 20,14 ---
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   *
   */
  
+ #include "cds/metaspaceShared.hpp"
  #include "classfile/stringTable.hpp"
  #include "classfile/symbolTable.hpp"
+ #include "classfile/systemDictionary.hpp"
  #include "code/aotCodeCache.hpp"
  #include "compiler/compiler_globals.hpp"
  #include "gc/shared/collectedHeap.hpp"
  #include "gc/shared/gcHeapSummary.hpp"
  #include "interpreter/bytecodes.hpp"

*** 45,10 ***
--- 47,11 ---
  #include "runtime/init.hpp"
  #include "runtime/safepoint.hpp"
  #include "runtime/sharedRuntime.hpp"
  #include "sanitizers/leak.hpp"
  #include "utilities/macros.hpp"
+ #include "utilities/xmlstream.hpp"
  #if INCLUDE_JVMCI
  #include "jvmci/jvmci.hpp"
  #endif
  
  // Initialization done by VM thread in vm_init_globals()

*** 66,13 ***
  void classLoader_init1();
  void compilationPolicy_init();
  void codeCache_init();
  void VM_Version_init();
  void icache_init2();
  void initial_stubs_init();
  
! jint universe_init();           // depends on codeCache_init and initial_stubs_init
  // depends on universe_init, must be before interpreter_init (currently only on SPARC)
  void gc_barrier_stubs_init();
  void continuations_init();      // depends on flags (UseCompressedOops) and barrier sets
  void continuation_stubs_init(); // depend on continuations_init
  void interpreter_init_stub();   // before any methods loaded
--- 69,14 ---
  void classLoader_init1();
  void compilationPolicy_init();
  void codeCache_init();
  void VM_Version_init();
  void icache_init2();
+ void preuniverse_stubs_init();
  void initial_stubs_init();
  
! jint universe_init();           // depends on codeCache_init and preuniverse_stubs_init
  // depends on universe_init, must be before interpreter_init (currently only on SPARC)
  void gc_barrier_stubs_init();
  void continuations_init();      // depends on flags (UseCompressedOops) and barrier sets
  void continuation_stubs_init(); // depend on continuations_init
  void interpreter_init_stub();   // before any methods loaded

*** 88,10 ***
--- 92,18 ---
  bool compilerOracle_init();
  bool compileBroker_init();
  void dependencyContext_init();
  void dependencies_init();
  
+ // initialize upcalls before class loading
+ bool runtimeUpcalls_open_registration();
+ bool runtimeUpcallNop_register_upcalls();
+ #if INCLUDE_CDS
+ bool cdsEndTrainingUpcall_register_upcalls();
+ #endif // INCLUDE_CDS
+ void runtimeUpcalls_close_registration();
+ 
  // Initialization after compiler initialization
  bool universe_post_init();  // must happen after compiler_init
  void javaClasses_init();    // must happen after vtable initialization
  void compiler_stubs_init(bool in_compiler_thread); // compiler's StubRoutines stubs
  void final_stubs_init();    // final StubRoutines stubs

*** 100,10 ***
--- 112,12 ---
  // JNI/JVM/JVMTI functions and signal handlers to work properly
  // during VM shutdown
  void perfMemory_exit();
  void ostream_exit();
  
+ void perf_jvm_init();
+ 
  void vm_init_globals() {
    check_ThreadShadow();
    basic_types_init();
    eventlog_init();
    mutex_init();

*** 113,10 ***
--- 127,13 ---
    ExternalsRecorder_init(); // After mutex_init() and before CodeCache_init
  }
  
  
  jint init_globals() {
+   perf_jvm_init();
+   MethodHandles::init_counters();
+ 
    management_init();
    JvmtiExport::initialize_oop_storage();
  #if INCLUDE_JVMTI
    if (AlwaysRecordEvolDependencies) {
      JvmtiExport::set_can_hotswap_or_post_breakpoint(true);

*** 124,31 ***
    }
  #endif
    bytecodes_init();
    classLoader_init1();
    compilationPolicy_init();
    codeCache_init();
    VM_Version_init();              // depends on codeCache_init for emitting code
    icache_init2();                 // depends on VM_Version for choosing the mechanism
!   // stub routines in initial blob are referenced by later generated code
!   initial_stubs_init();
!   // stack overflow exception blob is referenced by the interpreter
!   SharedRuntime::generate_initial_stubs();
-   jint status = universe_init();  // dependent on codeCache_init and
-                                   // initial_stubs_init and metaspace_init.
-   if (status != JNI_OK)
      return status;
! 
  #ifdef LEAK_SANITIZER
    {
      // Register the Java heap with LSan.
      VirtualSpaceSummary summary = Universe::heap()->create_heap_space_summary();
      LSAN_REGISTER_ROOT_REGION(summary.start(), summary.reserved_size());
    }
  #endif // LEAK_SANITIZER
!   AOTCodeCache::init2();     // depends on universe_init
    AsyncLogWriter::initialize();
    gc_barrier_stubs_init();   // depends on universe_init, must be before interpreter_init
    continuations_init();      // must precede continuation stub generation
    continuation_stubs_init(); // depends on continuations_init
  #if INCLUDE_JFR
    SharedRuntime::generate_jfr_stubs();
--- 141,34 ---
    }
  #endif
    bytecodes_init();
    classLoader_init1();
    compilationPolicy_init();
+   MetaspaceShared::open_static_archive();
    codeCache_init();
    VM_Version_init();              // depends on codeCache_init for emitting code
    icache_init2();                 // depends on VM_Version for choosing the mechanism
!   // initialize stubs needed before we can init the universe
!   preuniverse_stubs_init();
!   jint status = universe_init();  // dependent on codeCache_init and preuniverse_stubs_init
!   if (status != JNI_OK) {
      return status;
!   }
  #ifdef LEAK_SANITIZER
    {
      // Register the Java heap with LSan.
      VirtualSpaceSummary summary = Universe::heap()->create_heap_space_summary();
      LSAN_REGISTER_ROOT_REGION(summary.start(), summary.reserved_size());
    }
  #endif // LEAK_SANITIZER
!   AOTCodeCache::init2();     // depends on universe_init, must be before initial_stubs_init
    AsyncLogWriter::initialize();
+ 
+   initial_stubs_init();      // initial stub routines
+   // stack overflow exception blob is referenced by the interpreter
+   SharedRuntime::generate_initial_stubs();
+   AOTCodeCache::init_early_stubs_table();  // need this after initial_stubs
    gc_barrier_stubs_init();   // depends on universe_init, must be before interpreter_init
    continuations_init();      // must precede continuation stub generation
    continuation_stubs_init(); // depends on continuations_init
  #if INCLUDE_JFR
    SharedRuntime::generate_jfr_stubs();

*** 163,10 ***
--- 183,23 ---
    return JNI_OK;
  }
  
  jint init_globals2() {
    universe2_init();          // dependent on codeCache_init and initial_stubs_init
+ 
+   // initialize upcalls before class loading / initialization
+   runtimeUpcalls_open_registration();
+   if (!runtimeUpcallNop_register_upcalls()) {
+     return JNI_EINVAL;
+   }
+ #if INCLUDE_CDS
+   if (!cdsEndTrainingUpcall_register_upcalls()) {
+     return JNI_EINVAL;
+   }
+ #endif // INCLUDE_CDS
+   runtimeUpcalls_close_registration();
+ 
    javaClasses_init();        // must happen after vtable initialization, before referenceProcessor_init
    interpreter_init_code();   // after javaClasses_init and before any method gets linked
    referenceProcessor_init();
    jni_handles_init();
  #if INCLUDE_VM_STRUCTS

*** 186,10 ***
--- 219,14 ---
  #if INCLUDE_JVMCI
    if (EnableJVMCI) {
      JVMCI::initialize_globals();
    }
  #endif
+   // Initialize TrainingData only we're recording/replaying
+   if (TrainingData::have_data() || TrainingData::need_data()) {
+     TrainingData::initialize();
+   }
  
    // Initialize TrainingData only we're recording/replaying
    if (TrainingData::have_data() || TrainingData::need_data()) {
     TrainingData::initialize();
    }

*** 197,16 ***
--- 234,19 ---
    if (!universe_post_init()) {
      return JNI_ERR;
    }
    compiler_stubs_init(false /* in_compiler_thread */); // compiler's intrinsics stubs
    final_stubs_init();    // final StubRoutines stubs
+   AOTCodeCache::init_stubs_table();
    MethodHandles::generate_adapters();
  
    // All the flags that get adjusted by VM_Version_init and os::init_2
    // have been set so dump the flags now.
    if (PrintFlagsFinal || PrintFlagsRanges) {
      JVMFlag::printFlags(tty, false, PrintFlagsRanges);
+   } else if (AOTRecordTraining && xtty != nullptr) {
+     JVMFlag::printFlags(xtty->log_only(), false, PrintFlagsRanges);
    }
  
    return JNI_OK;
  }
  
< prev index next >