< 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/atomic.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/memoryService.hpp"
  85 #include "utilities/align.hpp"
  86 #include "utilities/autoRestore.hpp"
  87 #include "utilities/debug.hpp"
  88 #include "utilities/formatBuffer.hpp"
  89 #include "utilities/macros.hpp"

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


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

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

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

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




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

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



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

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

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


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











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

  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/atomic.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/memoryService.hpp"
  86 #include "utilities/align.hpp"
  87 #include "utilities/autoRestore.hpp"
  88 #include "utilities/debug.hpp"
  89 #include "utilities/formatBuffer.hpp"
  90 #include "utilities/macros.hpp"

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

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

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







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

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

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

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

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