< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

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

  69 #include "oops/typeArrayKlass.hpp"
  70 #include "prims/resolvedMethodTable.hpp"
  71 #include "runtime/arguments.hpp"
  72 #include "runtime/atomicAccess.hpp"
  73 #include "runtime/cpuTimeCounters.hpp"
  74 #include "runtime/flags/jvmFlagLimit.hpp"
  75 #include "runtime/handles.inline.hpp"
  76 #include "runtime/init.hpp"
  77 #include "runtime/java.hpp"
  78 #include "runtime/javaThread.hpp"
  79 #include "runtime/jniHandles.hpp"
  80 #include "runtime/threads.hpp"
  81 #include "runtime/timerTrace.hpp"
  82 #include "sanitizers/leak.hpp"
  83 #include "services/cpuTimeUsage.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"

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

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

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

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




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

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



 657 }
 658 
 659 static void reinitialize_itables() {
 660 
 661   class ReinitTableClosure : public KlassClosure {
 662    public:
 663     void do_klass(Klass* k) {
 664       if (k->is_instance_klass()) {
 665          InstanceKlass::cast(k)->itable().initialize_itable();
 666       }
 667     }
 668   };
 669 
 670   MutexLocker mcld(ClassLoaderDataGraph_lock);
 671   ReinitTableClosure cl;
 672   ClassLoaderDataGraph::classes_do(&cl);
 673 }
 674 
 675 bool Universe::on_page_boundary(void* addr) {
 676   return is_aligned(addr, os::vm_page_size());

 882 
 883   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 884   CPUTimeCounters::initialize();
 885 
 886   ObjLayout::initialize();
 887 
 888 #ifdef _LP64
 889   AOTMetaspace::adjust_heap_sizes_for_dumping();
 890 #endif // _LP64
 891 
 892   GCConfig::arguments()->initialize_heap_sizes();
 893 
 894   jint status = Universe::initialize_heap();
 895   if (status != JNI_OK) {
 896     return status;
 897   }
 898 
 899   Universe::initialize_tlab();
 900 
 901   Metaspace::global_initialize();
 902 
 903   // Initialize performance counters for metaspaces
 904   MetaspaceCounters::initialize_performance_counters();
 905 
 906   // Checks 'AfterMemoryInit' constraints.
 907   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 908     return JNI_EINVAL;
 909   }
 910 
 911   // Add main_thread to threads list to finish barrier setup with
 912   // on_thread_attach.  Should be before starting to build Java objects in
 913   // the AOT heap loader, which invokes barriers.
 914   {
 915     JavaThread* main_thread = JavaThread::current();
 916     MutexLocker mu(Threads_lock);
 917     Threads::add(main_thread);
 918   }
 919 
 920   HeapShared::initialize_writing_mode();
 921 
 922   // Create the string table before the AOT object archive is loaded,

1061     // <init> function before java_lang_Class is linked. Print error and exit.
1062     vm_exit_during_initialization(err_msg("Unable to link/verify %s.%s method",
1063                                  ik->name()->as_C_string(), method));
1064   }
1065 
1066   _klass = ik;
1067   _method_idnum = m->method_idnum();
1068   assert(_method_idnum >= 0, "sanity check");
1069 }
1070 
1071 Method* LatestMethodCache::get_method() {
1072   if (_klass == nullptr) {
1073     return nullptr;
1074   } else {
1075     Method* m = _klass->method_with_idnum(_method_idnum);
1076     assert(m != nullptr, "sanity check");
1077     return m;
1078   }
1079 }
1080 
1081 Method* Universe::finalizer_register_method()     { return _finalizer_register_cache.get_method(); }
1082 Method* Universe::loader_addClass_method()        { return _loader_addClass_cache.get_method(); }
1083 Method* Universe::throw_illegal_access_error()    { return _throw_illegal_access_error_cache.get_method(); }
1084 Method* Universe::throw_no_such_method_error()    { return _throw_no_such_method_error_cache.get_method(); }
1085 Method* Universe::do_stack_walk_method()          { return _do_stack_walk_cache.get_method(); }




1086 
1087 void Universe::initialize_known_methods(JavaThread* current) {
1088   // Set up static method for registering finalizers
1089   _finalizer_register_cache.init(current,
1090                           vmClasses::Finalizer_klass(),
1091                           "register",
1092                           vmSymbols::object_void_signature(), true);
1093 
1094   _throw_illegal_access_error_cache.init(current,
1095                           vmClasses::internal_Unsafe_klass(),
1096                           "throwIllegalAccessError",
1097                           vmSymbols::void_method_signature(), true);
1098 
1099   _throw_no_such_method_error_cache.init(current,
1100                           vmClasses::internal_Unsafe_klass(),
1101                           "throwNoSuchMethodError",
1102                           vmSymbols::void_method_signature(), true);
1103 
1104   // Set up method for registering loaded classes in class loader vector
1105   _loader_addClass_cache.init(current,
1106                           vmClasses::ClassLoader_klass(),
1107                           "addClass",
1108                           vmSymbols::class_void_signature(), false);
1109 
1110   // Set up method for stack walking
1111   _do_stack_walk_cache.init(current,
1112                           vmClasses::AbstractStackWalker_klass(),
1113                           "doStackWalk",
1114                           vmSymbols::doStackWalk_signature(), false);



















1115 }
1116 
1117 void universe2_init() {
1118   EXCEPTION_MARK;
1119   Universe::genesis(CATCH);
1120 }
1121 
1122 // Set after initialization of the module runtime, call_initModuleRuntime
1123 void universe_post_module_init() {
1124   Universe::_module_initialized = true;
1125 }
1126 
1127 bool universe_post_init() {
1128   assert(!is_init_completed(), "Error: initialization not yet completed!");
1129   Universe::_fully_initialized = true;
1130   EXCEPTION_MARK;
1131   if (!CDSConfig::is_using_archive()) {
1132     reinitialize_vtables();
1133     reinitialize_itables();
1134   }

  49 #include "gc/shared/tlab_globals.hpp"
  50 #include "logging/log.hpp"
  51 #include "logging/logStream.hpp"
  52 #include "memory/memoryReserver.hpp"
  53 #include "memory/metadataFactory.hpp"
  54 #include "memory/metaspaceClosure.hpp"
  55 #include "memory/metaspaceCounters.hpp"
  56 #include "memory/metaspaceUtils.hpp"
  57 #include "memory/oopFactory.hpp"
  58 #include "memory/resourceArea.hpp"
  59 #include "memory/universe.hpp"
  60 #include "oops/compressedOops.hpp"
  61 #include "oops/instanceKlass.hpp"
  62 #include "oops/instanceMirrorKlass.hpp"
  63 #include "oops/jmethodIDTable.hpp"
  64 #include "oops/klass.inline.hpp"
  65 #include "oops/objArrayOop.inline.hpp"
  66 #include "oops/objLayout.hpp"
  67 #include "oops/oop.inline.hpp"
  68 #include "oops/oopHandle.inline.hpp"
  69 #include "oops/refArrayKlass.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 static LatestMethodCache _is_substitutable_cache;           // ValueObjectMethods.isSubstitutable()
 118 static LatestMethodCache _value_object_hash_code_cache;     // ValueObjectMethods.valueObjectHashCode()
 119 static LatestMethodCache _is_substitutable_alt_cache;       // ValueObjectMethods.isSubstitutableAlt()
 120 static LatestMethodCache _value_object_hash_code_alt_cache; // ValueObjectMethods.valueObjectHashCodeAlt()
 121 
 122 // Known objects
 123 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
 124 ObjArrayKlass* Universe::_objectArrayKlass            = nullptr;
 125 Klass* Universe::_fillerArrayKlass                    = nullptr;
 126 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
 127 #if INCLUDE_CDS_JAVA_HEAP
 128 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
 129 #endif
 130 
 131 OopHandle Universe::_main_thread_group;
 132 OopHandle Universe::_system_thread_group;
 133 OopHandle Universe::_the_empty_class_array;
 134 OopHandle Universe::_the_null_string;
 135 OopHandle Universe::_the_min_jint_string;
 136 
 137 OopHandle Universe::_the_null_sentinel;
 138 
 139 // _out_of_memory_errors is an objArray
 140 enum OutOfMemoryInstance { _oom_java_heap,

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

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







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

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

 888 
 889   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 890   CPUTimeCounters::initialize();
 891 
 892   ObjLayout::initialize();
 893 
 894 #ifdef _LP64
 895   AOTMetaspace::adjust_heap_sizes_for_dumping();
 896 #endif // _LP64
 897 
 898   GCConfig::arguments()->initialize_heap_sizes();
 899 
 900   jint status = Universe::initialize_heap();
 901   if (status != JNI_OK) {
 902     return status;
 903   }
 904 
 905   Universe::initialize_tlab();
 906 
 907   Metaspace::global_initialize();

 908   // Initialize performance counters for metaspaces
 909   MetaspaceCounters::initialize_performance_counters();
 910 
 911   // Checks 'AfterMemoryInit' constraints.
 912   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 913     return JNI_EINVAL;
 914   }
 915 
 916   // Add main_thread to threads list to finish barrier setup with
 917   // on_thread_attach.  Should be before starting to build Java objects in
 918   // the AOT heap loader, which invokes barriers.
 919   {
 920     JavaThread* main_thread = JavaThread::current();
 921     MutexLocker mu(Threads_lock);
 922     Threads::add(main_thread);
 923   }
 924 
 925   HeapShared::initialize_writing_mode();
 926 
 927   // Create the string table before the AOT object archive is loaded,

1066     // <init> function before java_lang_Class is linked. Print error and exit.
1067     vm_exit_during_initialization(err_msg("Unable to link/verify %s.%s method",
1068                                  ik->name()->as_C_string(), method));
1069   }
1070 
1071   _klass = ik;
1072   _method_idnum = m->method_idnum();
1073   assert(_method_idnum >= 0, "sanity check");
1074 }
1075 
1076 Method* LatestMethodCache::get_method() {
1077   if (_klass == nullptr) {
1078     return nullptr;
1079   } else {
1080     Method* m = _klass->method_with_idnum(_method_idnum);
1081     assert(m != nullptr, "sanity check");
1082     return m;
1083   }
1084 }
1085 
1086 Method* Universe::finalizer_register_method()        { return _finalizer_register_cache.get_method(); }
1087 Method* Universe::loader_addClass_method()           { return _loader_addClass_cache.get_method(); }
1088 Method* Universe::throw_illegal_access_error()       { return _throw_illegal_access_error_cache.get_method(); }
1089 Method* Universe::throw_no_such_method_error()       { return _throw_no_such_method_error_cache.get_method(); }
1090 Method* Universe::do_stack_walk_method()             { return _do_stack_walk_cache.get_method(); }
1091 Method* Universe::is_substitutable_method()          { return _is_substitutable_cache.get_method(); }
1092 Method* Universe::value_object_hash_code_method()    { return _value_object_hash_code_cache.get_method(); }
1093 Method* Universe::is_substitutableAlt_method()       { return _is_substitutable_alt_cache.get_method(); }
1094 Method* Universe::value_object_hash_codeAlt_method() { return _value_object_hash_code_alt_cache.get_method(); }
1095 
1096 void Universe::initialize_known_methods(JavaThread* current) {
1097   // Set up static method for registering finalizers
1098   _finalizer_register_cache.init(current,
1099                           vmClasses::Finalizer_klass(),
1100                           "register",
1101                           vmSymbols::object_void_signature(), true);
1102 
1103   _throw_illegal_access_error_cache.init(current,
1104                           vmClasses::internal_Unsafe_klass(),
1105                           "throwIllegalAccessError",
1106                           vmSymbols::void_method_signature(), true);
1107 
1108   _throw_no_such_method_error_cache.init(current,
1109                           vmClasses::internal_Unsafe_klass(),
1110                           "throwNoSuchMethodError",
1111                           vmSymbols::void_method_signature(), true);
1112 
1113   // Set up method for registering loaded classes in class loader vector
1114   _loader_addClass_cache.init(current,
1115                           vmClasses::ClassLoader_klass(),
1116                           "addClass",
1117                           vmSymbols::class_void_signature(), false);
1118 
1119   // Set up method for stack walking
1120   _do_stack_walk_cache.init(current,
1121                           vmClasses::AbstractStackWalker_klass(),
1122                           "doStackWalk",
1123                           vmSymbols::doStackWalk_signature(), false);
1124 
1125   // Set up substitutability testing
1126   ResourceMark rm(current);
1127   _is_substitutable_cache.init(current,
1128                           vmClasses::ValueObjectMethods_klass(),
1129                           vmSymbols::isSubstitutable_name()->as_C_string(),
1130                           vmSymbols::object_object_boolean_signature(), true);
1131   _value_object_hash_code_cache.init(current,
1132                           vmClasses::ValueObjectMethods_klass(),
1133                           vmSymbols::valueObjectHashCode_name()->as_C_string(),
1134                           vmSymbols::object_int_signature(), true);
1135   _is_substitutable_alt_cache.init(current,
1136                           vmClasses::ValueObjectMethods_klass(),
1137                           vmSymbols::isSubstitutableAlt_name()->as_C_string(),
1138                           vmSymbols::object_object_boolean_signature(), true);
1139   _value_object_hash_code_alt_cache.init(current,
1140                           vmClasses::ValueObjectMethods_klass(),
1141                           vmSymbols::valueObjectHashCodeAlt_name()->as_C_string(),
1142                           vmSymbols::object_int_signature(), true);
1143 }
1144 
1145 void universe2_init() {
1146   EXCEPTION_MARK;
1147   Universe::genesis(CATCH);
1148 }
1149 
1150 // Set after initialization of the module runtime, call_initModuleRuntime
1151 void universe_post_module_init() {
1152   Universe::_module_initialized = true;
1153 }
1154 
1155 bool universe_post_init() {
1156   assert(!is_init_completed(), "Error: initialization not yet completed!");
1157   Universe::_fully_initialized = true;
1158   EXCEPTION_MARK;
1159   if (!CDSConfig::is_using_archive()) {
1160     reinitialize_vtables();
1161     reinitialize_itables();
1162   }
< prev index next >