< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

  50 #include "gc/shared/tlab_globals.hpp"
  51 #include "logging/log.hpp"
  52 #include "logging/logStream.hpp"
  53 #include "memory/memoryReserver.hpp"
  54 #include "memory/metadataFactory.hpp"
  55 #include "memory/metaspaceClosure.hpp"
  56 #include "memory/metaspaceCounters.hpp"
  57 #include "memory/metaspaceUtils.hpp"
  58 #include "memory/oopFactory.hpp"
  59 #include "memory/resourceArea.hpp"
  60 #include "memory/universe.hpp"
  61 #include "oops/compressedOops.hpp"
  62 #include "oops/instanceKlass.hpp"
  63 #include "oops/instanceMirrorKlass.hpp"
  64 #include "oops/jmethodIDTable.hpp"
  65 #include "oops/klass.inline.hpp"
  66 #include "oops/objArrayOop.inline.hpp"
  67 #include "oops/objLayout.hpp"
  68 #include "oops/oop.inline.hpp"
  69 #include "oops/oopHandle.inline.hpp"

  70 #include "oops/typeArrayKlass.hpp"
  71 #include "prims/resolvedMethodTable.hpp"
  72 #include "runtime/arguments.hpp"
  73 #include "runtime/atomicAccess.hpp"
  74 #include "runtime/cpuTimeCounters.hpp"
  75 #include "runtime/flags/jvmFlagLimit.hpp"
  76 #include "runtime/handles.inline.hpp"
  77 #include "runtime/init.hpp"
  78 #include "runtime/java.hpp"
  79 #include "runtime/javaThread.hpp"
  80 #include "runtime/jniHandles.hpp"
  81 #include "runtime/threads.hpp"
  82 #include "runtime/timerTrace.hpp"
  83 #include "sanitizers/leak.hpp"
  84 #include "services/cpuTimeUsage.hpp"
  85 #include "services/memoryService.hpp"
  86 #include "utilities/align.hpp"
  87 #include "utilities/autoRestore.hpp"
  88 #include "utilities/debug.hpp"
  89 #include "utilities/formatBuffer.hpp"

  97 // interacts with the RedefineClasses API.
  98 class LatestMethodCache {
  99   // We save the InstanceKlass* and the idnum of Method* in order to get
 100   // the current Method*.
 101   InstanceKlass*        _klass;
 102   int                   _method_idnum;
 103 
 104  public:
 105   LatestMethodCache()   { _klass = nullptr; _method_idnum = -1; }
 106 
 107   void init(JavaThread* current, InstanceKlass* ik, const char* method,
 108             Symbol* signature, bool is_static);
 109   Method* get_method();
 110 };
 111 
 112 static LatestMethodCache _finalizer_register_cache;         // Finalizer.register()
 113 static LatestMethodCache _loader_addClass_cache;            // ClassLoader.addClass()
 114 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
 115 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
 116 static LatestMethodCache _do_stack_walk_cache;              // AbstractStackWalker.doStackWalk()


 117 
 118 // Known objects
 119 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
 120 ObjArrayKlass* Universe::_objectArrayKlass            = nullptr;
 121 Klass* Universe::_fillerArrayKlass                    = nullptr;
 122 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
 123 #if INCLUDE_CDS_JAVA_HEAP
 124 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
 125 #endif
 126 
 127 OopHandle Universe::_main_thread_group;
 128 OopHandle Universe::_system_thread_group;
 129 OopHandle Universe::_the_empty_class_array;
 130 OopHandle Universe::_the_null_string;
 131 OopHandle Universe::_the_min_jint_string;
 132 
 133 OopHandle Universe::_the_null_sentinel;
 134 
 135 // _out_of_memory_errors is an objArray
 136 enum OutOfMemoryInstance { _oom_java_heap,

 441     vmSymbols::initialize();
 442 
 443     // Initialize table for matching jmethodID, before SystemDictionary.
 444     JmethodIDTable::initialize();
 445 
 446     SystemDictionary::initialize(CHECK);
 447 
 448     // Create string constants
 449     oop s = StringTable::intern("null", CHECK);
 450     _the_null_string = OopHandle(vm_global(), s);
 451     s = StringTable::intern("-2147483648", CHECK);
 452     _the_min_jint_string = OopHandle(vm_global(), s);
 453 
 454 #if INCLUDE_CDS
 455     if (CDSConfig::is_using_archive()) {
 456       // Verify shared interfaces array.
 457       assert(_the_array_interfaces_array->at(0) ==
 458              vmClasses::Cloneable_klass(), "u3");
 459       assert(_the_array_interfaces_array->at(1) ==
 460              vmClasses::Serializable_klass(), "u3");

 461     } else
 462 #endif
 463     {
 464       // Set up shared interfaces array.  (Do this before supers are set up.)
 465       _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
 466       _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
 467     }
 468 
 469     _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
 470     _the_empty_klass_bitmap      = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
 471 
 472     initialize_basic_type_klass(_fillerArrayKlass, CHECK);
 473 
 474     initialize_basic_type_klass(boolArrayKlass(), CHECK);
 475     initialize_basic_type_klass(charArrayKlass(), CHECK);
 476     initialize_basic_type_klass(floatArrayKlass(), CHECK);
 477     initialize_basic_type_klass(doubleArrayKlass(), CHECK);
 478     initialize_basic_type_klass(byteArrayKlass(), CHECK);
 479     initialize_basic_type_klass(shortArrayKlass(), CHECK);
 480     initialize_basic_type_klass(intArrayKlass(), CHECK);

 488     Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK);
 489     _the_null_sentinel = OopHandle(vm_global(), tns());
 490   }
 491 
 492   // Create a handle for reference_pending_list
 493   _reference_pending_list = OopHandle(vm_global(), nullptr);
 494 
 495   // Maybe this could be lifted up now that object array can be initialized
 496   // during the bootstrapping.
 497 
 498   // OLD
 499   // Initialize _objectArrayKlass after core bootstraping to make
 500   // sure the super class is set up properly for _objectArrayKlass.
 501   // ---
 502   // NEW
 503   // Since some of the old system object arrays have been converted to
 504   // ordinary object arrays, _objectArrayKlass will be loaded when
 505   // SystemDictionary::initialize(CHECK); is run. See the extra check
 506   // for Object_klass_loaded in objArrayKlassKlass::allocate_objArray_klass_impl.
 507   {
 508     Klass* oak = vmClasses::Object_klass()->array_klass(CHECK);
 509     _objectArrayKlass = ObjArrayKlass::cast(oak);




 510   }
 511   // OLD
 512   // Add the class to the class hierarchy manually to make sure that
 513   // its vtable is initialized after core bootstrapping is completed.
 514   // ---
 515   // New
 516   // Have already been initialized.
 517   _objectArrayKlass->append_to_sibling_list();
 518 
 519   #ifdef ASSERT
 520   if (FullGCALot) {
 521     // Allocate an array of dummy objects.
 522     // We'd like these to be at the bottom of the old generation,
 523     // so that when we free one and then collect,
 524     // (almost) the whole heap moves
 525     // and we find out if we actually update all the oops correctly.
 526     // But we can't allocate directly in the old generation,
 527     // so we allocate wherever, and hope that the first collection
 528     // moves these objects to the bottom of the old generation.
 529     int size = FullGCALotDummies * 2;
 530 
 531     objArrayOop    naked_array = oopFactory::new_objArray(vmClasses::Object_klass(), size, CHECK);
 532     objArrayHandle dummy_array(THREAD, naked_array);
 533     int i = 0;
 534     while (i < size) {
 535         // Allocate dummy in old generation
 536       oop dummy = vmClasses::Object_klass()->allocate_instance(CHECK);
 537       dummy_array->obj_at_put(i++, dummy);

 629   assert_pll_ownership();
 630   return _reference_pending_list.peek() != nullptr;
 631 }
 632 
 633 oop Universe::swap_reference_pending_list(oop list) {
 634   assert_pll_locked(is_locked);
 635   return _reference_pending_list.xchg(list);
 636 }
 637 
 638 #undef assert_pll_locked
 639 #undef assert_pll_ownership
 640 
 641 static void reinitialize_vtables() {
 642   // The vtables are initialized by starting at java.lang.Object and
 643   // initializing through the subclass links, so that the super
 644   // classes are always initialized first.
 645   for (ClassHierarchyIterator iter(vmClasses::Object_klass()); !iter.done(); iter.next()) {
 646     Klass* sub = iter.klass();
 647     sub->vtable().initialize_vtable();
 648   }



 649 }
 650 
 651 static void reinitialize_itables() {
 652 
 653   class ReinitTableClosure : public KlassClosure {
 654    public:
 655     void do_klass(Klass* k) {
 656       if (k->is_instance_klass()) {
 657          InstanceKlass::cast(k)->itable().initialize_itable();
 658       }
 659     }
 660   };
 661 
 662   MutexLocker mcld(ClassLoaderDataGraph_lock);
 663   ReinitTableClosure cl;
 664   ClassLoaderDataGraph::classes_do(&cl);
 665 }
 666 
 667 bool Universe::on_page_boundary(void* addr) {
 668   return is_aligned(addr, os::vm_page_size());

 874 
 875   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 876   CPUTimeCounters::initialize();
 877 
 878   ObjLayout::initialize();
 879 
 880 #ifdef _LP64
 881   AOTMetaspace::adjust_heap_sizes_for_dumping();
 882 #endif // _LP64
 883 
 884   GCConfig::arguments()->initialize_heap_sizes();
 885 
 886   jint status = Universe::initialize_heap();
 887   if (status != JNI_OK) {
 888     return status;
 889   }
 890 
 891   Universe::initialize_tlab();
 892 
 893   Metaspace::global_initialize();
 894 
 895   // Initialize performance counters for metaspaces
 896   MetaspaceCounters::initialize_performance_counters();
 897 
 898   // Checks 'AfterMemoryInit' constraints.
 899   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 900     return JNI_EINVAL;
 901   }
 902 
 903 #if INCLUDE_CDS
 904   if (CDSConfig::is_using_archive()) {
 905     // Read the data structures supporting the shared spaces (shared
 906     // system dictionary, symbol table, etc.)
 907     AOTMetaspace::initialize_shared_spaces();
 908   }
 909 #endif
 910 
 911   ClassLoaderData::init_null_class_loader_data();
 912 
 913 #if INCLUDE_CDS
 914 #if INCLUDE_CDS_JAVA_HEAP

1038   _klass = ik;
1039   _method_idnum = m->method_idnum();
1040   assert(_method_idnum >= 0, "sanity check");
1041 }
1042 
1043 Method* LatestMethodCache::get_method() {
1044   if (_klass == nullptr) {
1045     return nullptr;
1046   } else {
1047     Method* m = _klass->method_with_idnum(_method_idnum);
1048     assert(m != nullptr, "sanity check");
1049     return m;
1050   }
1051 }
1052 
1053 Method* Universe::finalizer_register_method()     { return _finalizer_register_cache.get_method(); }
1054 Method* Universe::loader_addClass_method()        { return _loader_addClass_cache.get_method(); }
1055 Method* Universe::throw_illegal_access_error()    { return _throw_illegal_access_error_cache.get_method(); }
1056 Method* Universe::throw_no_such_method_error()    { return _throw_no_such_method_error_cache.get_method(); }
1057 Method* Universe::do_stack_walk_method()          { return _do_stack_walk_cache.get_method(); }


1058 
1059 void Universe::initialize_known_methods(JavaThread* current) {
1060   // Set up static method for registering finalizers
1061   _finalizer_register_cache.init(current,
1062                           vmClasses::Finalizer_klass(),
1063                           "register",
1064                           vmSymbols::object_void_signature(), true);
1065 
1066   _throw_illegal_access_error_cache.init(current,
1067                           vmClasses::internal_Unsafe_klass(),
1068                           "throwIllegalAccessError",
1069                           vmSymbols::void_method_signature(), true);
1070 
1071   _throw_no_such_method_error_cache.init(current,
1072                           vmClasses::internal_Unsafe_klass(),
1073                           "throwNoSuchMethodError",
1074                           vmSymbols::void_method_signature(), true);
1075 
1076   // Set up method for registering loaded classes in class loader vector
1077   _loader_addClass_cache.init(current,
1078                           vmClasses::ClassLoader_klass(),
1079                           "addClass",
1080                           vmSymbols::class_void_signature(), false);
1081 
1082   // Set up method for stack walking
1083   _do_stack_walk_cache.init(current,
1084                           vmClasses::AbstractStackWalker_klass(),
1085                           "doStackWalk",
1086                           vmSymbols::doStackWalk_signature(), false);











1087 }
1088 
1089 void universe2_init() {
1090   EXCEPTION_MARK;
1091   Universe::genesis(CATCH);
1092 }
1093 
1094 // Set after initialization of the module runtime, call_initModuleRuntime
1095 void universe_post_module_init() {
1096   Universe::_module_initialized = true;
1097 }
1098 
1099 bool universe_post_init() {
1100   assert(!is_init_completed(), "Error: initialization not yet completed!");
1101   Universe::_fully_initialized = true;
1102   EXCEPTION_MARK;
1103   if (!CDSConfig::is_using_archive()) {
1104     reinitialize_vtables();
1105     reinitialize_itables();
1106   }

  50 #include "gc/shared/tlab_globals.hpp"
  51 #include "logging/log.hpp"
  52 #include "logging/logStream.hpp"
  53 #include "memory/memoryReserver.hpp"
  54 #include "memory/metadataFactory.hpp"
  55 #include "memory/metaspaceClosure.hpp"
  56 #include "memory/metaspaceCounters.hpp"
  57 #include "memory/metaspaceUtils.hpp"
  58 #include "memory/oopFactory.hpp"
  59 #include "memory/resourceArea.hpp"
  60 #include "memory/universe.hpp"
  61 #include "oops/compressedOops.hpp"
  62 #include "oops/instanceKlass.hpp"
  63 #include "oops/instanceMirrorKlass.hpp"
  64 #include "oops/jmethodIDTable.hpp"
  65 #include "oops/klass.inline.hpp"
  66 #include "oops/objArrayOop.inline.hpp"
  67 #include "oops/objLayout.hpp"
  68 #include "oops/oop.inline.hpp"
  69 #include "oops/oopHandle.inline.hpp"
  70 #include "oops/refArrayKlass.hpp"
  71 #include "oops/typeArrayKlass.hpp"
  72 #include "prims/resolvedMethodTable.hpp"
  73 #include "runtime/arguments.hpp"
  74 #include "runtime/atomicAccess.hpp"
  75 #include "runtime/cpuTimeCounters.hpp"
  76 #include "runtime/flags/jvmFlagLimit.hpp"
  77 #include "runtime/handles.inline.hpp"
  78 #include "runtime/init.hpp"
  79 #include "runtime/java.hpp"
  80 #include "runtime/javaThread.hpp"
  81 #include "runtime/jniHandles.hpp"
  82 #include "runtime/threads.hpp"
  83 #include "runtime/timerTrace.hpp"
  84 #include "sanitizers/leak.hpp"
  85 #include "services/cpuTimeUsage.hpp"
  86 #include "services/memoryService.hpp"
  87 #include "utilities/align.hpp"
  88 #include "utilities/autoRestore.hpp"
  89 #include "utilities/debug.hpp"
  90 #include "utilities/formatBuffer.hpp"

  98 // interacts with the RedefineClasses API.
  99 class LatestMethodCache {
 100   // We save the InstanceKlass* and the idnum of Method* in order to get
 101   // the current Method*.
 102   InstanceKlass*        _klass;
 103   int                   _method_idnum;
 104 
 105  public:
 106   LatestMethodCache()   { _klass = nullptr; _method_idnum = -1; }
 107 
 108   void init(JavaThread* current, InstanceKlass* ik, const char* method,
 109             Symbol* signature, bool is_static);
 110   Method* get_method();
 111 };
 112 
 113 static LatestMethodCache _finalizer_register_cache;         // Finalizer.register()
 114 static LatestMethodCache _loader_addClass_cache;            // ClassLoader.addClass()
 115 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
 116 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
 117 static LatestMethodCache _do_stack_walk_cache;              // AbstractStackWalker.doStackWalk()
 118 static LatestMethodCache _is_substitutable_cache;           // ValueObjectMethods.isSubstitutable()
 119 static LatestMethodCache _value_object_hash_code_cache;     // ValueObjectMethods.valueObjectHashCode()
 120 
 121 // Known objects
 122 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
 123 ObjArrayKlass* Universe::_objectArrayKlass            = nullptr;
 124 Klass* Universe::_fillerArrayKlass                    = nullptr;
 125 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
 126 #if INCLUDE_CDS_JAVA_HEAP
 127 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
 128 #endif
 129 
 130 OopHandle Universe::_main_thread_group;
 131 OopHandle Universe::_system_thread_group;
 132 OopHandle Universe::_the_empty_class_array;
 133 OopHandle Universe::_the_null_string;
 134 OopHandle Universe::_the_min_jint_string;
 135 
 136 OopHandle Universe::_the_null_sentinel;
 137 
 138 // _out_of_memory_errors is an objArray
 139 enum OutOfMemoryInstance { _oom_java_heap,

 444     vmSymbols::initialize();
 445 
 446     // Initialize table for matching jmethodID, before SystemDictionary.
 447     JmethodIDTable::initialize();
 448 
 449     SystemDictionary::initialize(CHECK);
 450 
 451     // Create string constants
 452     oop s = StringTable::intern("null", CHECK);
 453     _the_null_string = OopHandle(vm_global(), s);
 454     s = StringTable::intern("-2147483648", CHECK);
 455     _the_min_jint_string = OopHandle(vm_global(), s);
 456 
 457 #if INCLUDE_CDS
 458     if (CDSConfig::is_using_archive()) {
 459       // Verify shared interfaces array.
 460       assert(_the_array_interfaces_array->at(0) ==
 461              vmClasses::Cloneable_klass(), "u3");
 462       assert(_the_array_interfaces_array->at(1) ==
 463              vmClasses::Serializable_klass(), "u3");
 464 
 465     } else
 466 #endif
 467     {
 468       // Set up shared interfaces array.  (Do this before supers are set up.)
 469       _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
 470       _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
 471     }
 472 
 473     _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
 474     _the_empty_klass_bitmap      = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
 475 
 476     initialize_basic_type_klass(_fillerArrayKlass, CHECK);
 477 
 478     initialize_basic_type_klass(boolArrayKlass(), CHECK);
 479     initialize_basic_type_klass(charArrayKlass(), CHECK);
 480     initialize_basic_type_klass(floatArrayKlass(), CHECK);
 481     initialize_basic_type_klass(doubleArrayKlass(), CHECK);
 482     initialize_basic_type_klass(byteArrayKlass(), CHECK);
 483     initialize_basic_type_klass(shortArrayKlass(), CHECK);
 484     initialize_basic_type_klass(intArrayKlass(), CHECK);

 492     Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK);
 493     _the_null_sentinel = OopHandle(vm_global(), tns());
 494   }
 495 
 496   // Create a handle for reference_pending_list
 497   _reference_pending_list = OopHandle(vm_global(), nullptr);
 498 
 499   // Maybe this could be lifted up now that object array can be initialized
 500   // during the bootstrapping.
 501 
 502   // OLD
 503   // Initialize _objectArrayKlass after core bootstraping to make
 504   // sure the super class is set up properly for _objectArrayKlass.
 505   // ---
 506   // NEW
 507   // Since some of the old system object arrays have been converted to
 508   // ordinary object arrays, _objectArrayKlass will be loaded when
 509   // SystemDictionary::initialize(CHECK); is run. See the extra check
 510   // for Object_klass_loaded in objArrayKlassKlass::allocate_objArray_klass_impl.
 511   {
 512     ArrayKlass* oak = vmClasses::Object_klass()->array_klass(CHECK);
 513     oak->append_to_sibling_list();
 514 
 515     // Create a RefArrayKlass (which is the default) and initialize.
 516     ObjArrayKlass* rak = ObjArrayKlass::cast(oak)->klass_with_properties(ArrayKlass::ArrayProperties::DEFAULT, THREAD);
 517     _objectArrayKlass = rak;
 518   }







 519 
 520   #ifdef ASSERT
 521   if (FullGCALot) {
 522     // Allocate an array of dummy objects.
 523     // We'd like these to be at the bottom of the old generation,
 524     // so that when we free one and then collect,
 525     // (almost) the whole heap moves
 526     // and we find out if we actually update all the oops correctly.
 527     // But we can't allocate directly in the old generation,
 528     // so we allocate wherever, and hope that the first collection
 529     // moves these objects to the bottom of the old generation.
 530     int size = FullGCALotDummies * 2;
 531 
 532     objArrayOop    naked_array = oopFactory::new_objArray(vmClasses::Object_klass(), size, CHECK);
 533     objArrayHandle dummy_array(THREAD, naked_array);
 534     int i = 0;
 535     while (i < size) {
 536         // Allocate dummy in old generation
 537       oop dummy = vmClasses::Object_klass()->allocate_instance(CHECK);
 538       dummy_array->obj_at_put(i++, dummy);

 630   assert_pll_ownership();
 631   return _reference_pending_list.peek() != nullptr;
 632 }
 633 
 634 oop Universe::swap_reference_pending_list(oop list) {
 635   assert_pll_locked(is_locked);
 636   return _reference_pending_list.xchg(list);
 637 }
 638 
 639 #undef assert_pll_locked
 640 #undef assert_pll_ownership
 641 
 642 static void reinitialize_vtables() {
 643   // The vtables are initialized by starting at java.lang.Object and
 644   // initializing through the subclass links, so that the super
 645   // classes are always initialized first.
 646   for (ClassHierarchyIterator iter(vmClasses::Object_klass()); !iter.done(); iter.next()) {
 647     Klass* sub = iter.klass();
 648     sub->vtable().initialize_vtable();
 649   }
 650 
 651   // This isn't added to the subclass list, so need to reinitialize vtables directly.
 652   Universe::objectArrayKlass()->vtable().initialize_vtable();
 653 }
 654 
 655 static void reinitialize_itables() {
 656 
 657   class ReinitTableClosure : public KlassClosure {
 658    public:
 659     void do_klass(Klass* k) {
 660       if (k->is_instance_klass()) {
 661          InstanceKlass::cast(k)->itable().initialize_itable();
 662       }
 663     }
 664   };
 665 
 666   MutexLocker mcld(ClassLoaderDataGraph_lock);
 667   ReinitTableClosure cl;
 668   ClassLoaderDataGraph::classes_do(&cl);
 669 }
 670 
 671 bool Universe::on_page_boundary(void* addr) {
 672   return is_aligned(addr, os::vm_page_size());

 878 
 879   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 880   CPUTimeCounters::initialize();
 881 
 882   ObjLayout::initialize();
 883 
 884 #ifdef _LP64
 885   AOTMetaspace::adjust_heap_sizes_for_dumping();
 886 #endif // _LP64
 887 
 888   GCConfig::arguments()->initialize_heap_sizes();
 889 
 890   jint status = Universe::initialize_heap();
 891   if (status != JNI_OK) {
 892     return status;
 893   }
 894 
 895   Universe::initialize_tlab();
 896 
 897   Metaspace::global_initialize();

 898   // Initialize performance counters for metaspaces
 899   MetaspaceCounters::initialize_performance_counters();
 900 
 901   // Checks 'AfterMemoryInit' constraints.
 902   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 903     return JNI_EINVAL;
 904   }
 905 
 906 #if INCLUDE_CDS
 907   if (CDSConfig::is_using_archive()) {
 908     // Read the data structures supporting the shared spaces (shared
 909     // system dictionary, symbol table, etc.)
 910     AOTMetaspace::initialize_shared_spaces();
 911   }
 912 #endif
 913 
 914   ClassLoaderData::init_null_class_loader_data();
 915 
 916 #if INCLUDE_CDS
 917 #if INCLUDE_CDS_JAVA_HEAP

1041   _klass = ik;
1042   _method_idnum = m->method_idnum();
1043   assert(_method_idnum >= 0, "sanity check");
1044 }
1045 
1046 Method* LatestMethodCache::get_method() {
1047   if (_klass == nullptr) {
1048     return nullptr;
1049   } else {
1050     Method* m = _klass->method_with_idnum(_method_idnum);
1051     assert(m != nullptr, "sanity check");
1052     return m;
1053   }
1054 }
1055 
1056 Method* Universe::finalizer_register_method()     { return _finalizer_register_cache.get_method(); }
1057 Method* Universe::loader_addClass_method()        { return _loader_addClass_cache.get_method(); }
1058 Method* Universe::throw_illegal_access_error()    { return _throw_illegal_access_error_cache.get_method(); }
1059 Method* Universe::throw_no_such_method_error()    { return _throw_no_such_method_error_cache.get_method(); }
1060 Method* Universe::do_stack_walk_method()          { return _do_stack_walk_cache.get_method(); }
1061 Method* Universe::is_substitutable_method()       { return _is_substitutable_cache.get_method(); }
1062 Method* Universe::value_object_hash_code_method() { return _value_object_hash_code_cache.get_method(); }
1063 
1064 void Universe::initialize_known_methods(JavaThread* current) {
1065   // Set up static method for registering finalizers
1066   _finalizer_register_cache.init(current,
1067                           vmClasses::Finalizer_klass(),
1068                           "register",
1069                           vmSymbols::object_void_signature(), true);
1070 
1071   _throw_illegal_access_error_cache.init(current,
1072                           vmClasses::internal_Unsafe_klass(),
1073                           "throwIllegalAccessError",
1074                           vmSymbols::void_method_signature(), true);
1075 
1076   _throw_no_such_method_error_cache.init(current,
1077                           vmClasses::internal_Unsafe_klass(),
1078                           "throwNoSuchMethodError",
1079                           vmSymbols::void_method_signature(), true);
1080 
1081   // Set up method for registering loaded classes in class loader vector
1082   _loader_addClass_cache.init(current,
1083                           vmClasses::ClassLoader_klass(),
1084                           "addClass",
1085                           vmSymbols::class_void_signature(), false);
1086 
1087   // Set up method for stack walking
1088   _do_stack_walk_cache.init(current,
1089                           vmClasses::AbstractStackWalker_klass(),
1090                           "doStackWalk",
1091                           vmSymbols::doStackWalk_signature(), false);
1092 
1093   // Set up substitutability testing
1094   ResourceMark rm(current);
1095   _is_substitutable_cache.init(current,
1096                           vmClasses::ValueObjectMethods_klass(),
1097                           vmSymbols::isSubstitutable_name()->as_C_string(),
1098                           vmSymbols::object_object_boolean_signature(), true);
1099   _value_object_hash_code_cache.init(current,
1100                           vmClasses::ValueObjectMethods_klass(),
1101                           vmSymbols::valueObjectHashCode_name()->as_C_string(),
1102                           vmSymbols::object_int_signature(), true);
1103 }
1104 
1105 void universe2_init() {
1106   EXCEPTION_MARK;
1107   Universe::genesis(CATCH);
1108 }
1109 
1110 // Set after initialization of the module runtime, call_initModuleRuntime
1111 void universe_post_module_init() {
1112   Universe::_module_initialized = true;
1113 }
1114 
1115 bool universe_post_init() {
1116   assert(!is_init_completed(), "Error: initialization not yet completed!");
1117   Universe::_fully_initialized = true;
1118   EXCEPTION_MARK;
1119   if (!CDSConfig::is_using_archive()) {
1120     reinitialize_vtables();
1121     reinitialize_itables();
1122   }
< prev index next >