92 // interacts with the RedefineClasses API.
93 class LatestMethodCache {
94 // We save the InstanceKlass* and the idnum of Method* in order to get
95 // the current Method*.
96 InstanceKlass* _klass;
97 int _method_idnum;
98
99 public:
100 LatestMethodCache() { _klass = nullptr; _method_idnum = -1; }
101
102 void init(JavaThread* current, InstanceKlass* ik, const char* method,
103 Symbol* signature, bool is_static);
104 Method* get_method();
105 };
106
107 static LatestMethodCache _finalizer_register_cache; // Finalizer.register()
108 static LatestMethodCache _loader_addClass_cache; // ClassLoader.addClass()
109 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
110 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
111 static LatestMethodCache _do_stack_walk_cache; // AbstractStackWalker.doStackWalk()
112
113 // Known objects
114 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
115 ObjArrayKlass* Universe::_objectArrayKlass = nullptr;
116 Klass* Universe::_fillerArrayKlass = nullptr;
117 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
118 #if INCLUDE_CDS_JAVA_HEAP
119 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
120 #endif
121
122 OopHandle Universe::_main_thread_group;
123 OopHandle Universe::_system_thread_group;
124 OopHandle Universe::_the_empty_class_array;
125 OopHandle Universe::_the_null_string;
126 OopHandle Universe::_the_min_jint_string;
127
128 OopHandle Universe::_the_null_sentinel;
129
130 // _out_of_memory_errors is an objArray
131 enum OutOfMemoryInstance { _oom_java_heap,
414 }
415
416 vmSymbols::initialize();
417
418 SystemDictionary::initialize(CHECK);
419
420 // Create string constants
421 oop s = StringTable::intern("null", CHECK);
422 _the_null_string = OopHandle(vm_global(), s);
423 s = StringTable::intern("-2147483648", CHECK);
424 _the_min_jint_string = OopHandle(vm_global(), s);
425
426
427 #if INCLUDE_CDS
428 if (CDSConfig::is_using_archive()) {
429 // Verify shared interfaces array.
430 assert(_the_array_interfaces_array->at(0) ==
431 vmClasses::Cloneable_klass(), "u3");
432 assert(_the_array_interfaces_array->at(1) ==
433 vmClasses::Serializable_klass(), "u3");
434 } else
435 #endif
436 {
437 // Set up shared interfaces array. (Do this before supers are set up.)
438 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
439 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
440 }
441
442 if (UseSecondarySupersTable) {
443 Universe::_the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
444 Universe::_the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
445 }
446
447 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
448
449 initialize_basic_type_klass(boolArrayKlass(), CHECK);
450 initialize_basic_type_klass(charArrayKlass(), CHECK);
451 initialize_basic_type_klass(floatArrayKlass(), CHECK);
452 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
453 initialize_basic_type_klass(byteArrayKlass(), CHECK);
847
848 GCLogPrecious::initialize();
849
850 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
851 CPUTimeCounters::initialize();
852
853 #ifdef _LP64
854 MetaspaceShared::adjust_heap_sizes_for_dumping();
855 #endif // _LP64
856
857 GCConfig::arguments()->initialize_heap_sizes();
858
859 jint status = Universe::initialize_heap();
860 if (status != JNI_OK) {
861 return status;
862 }
863
864 Universe::initialize_tlab();
865
866 Metaspace::global_initialize();
867
868 // Initialize performance counters for metaspaces
869 MetaspaceCounters::initialize_performance_counters();
870
871 // Checks 'AfterMemoryInit' constraints.
872 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
873 return JNI_EINVAL;
874 }
875
876 ClassLoaderData::init_null_class_loader_data();
877
878 #if INCLUDE_CDS
879 DynamicArchive::check_for_dynamic_dump();
880 if (CDSConfig::is_using_archive()) {
881 // Read the data structures supporting the shared spaces (shared
882 // system dictionary, symbol table, etc.)
883 MetaspaceShared::initialize_shared_spaces();
884 }
885 if (CDSConfig::is_dumping_archive()) {
886 MetaspaceShared::prepare_for_dumping();
887 }
1000 _klass = ik;
1001 _method_idnum = m->method_idnum();
1002 assert(_method_idnum >= 0, "sanity check");
1003 }
1004
1005 Method* LatestMethodCache::get_method() {
1006 if (_klass == nullptr) {
1007 return nullptr;
1008 } else {
1009 Method* m = _klass->method_with_idnum(_method_idnum);
1010 assert(m != nullptr, "sanity check");
1011 return m;
1012 }
1013 }
1014
1015 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1016 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1017 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1018 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1019 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1020
1021 void Universe::initialize_known_methods(JavaThread* current) {
1022 // Set up static method for registering finalizers
1023 _finalizer_register_cache.init(current,
1024 vmClasses::Finalizer_klass(),
1025 "register",
1026 vmSymbols::object_void_signature(), true);
1027
1028 _throw_illegal_access_error_cache.init(current,
1029 vmClasses::internal_Unsafe_klass(),
1030 "throwIllegalAccessError",
1031 vmSymbols::void_method_signature(), true);
1032
1033 _throw_no_such_method_error_cache.init(current,
1034 vmClasses::internal_Unsafe_klass(),
1035 "throwNoSuchMethodError",
1036 vmSymbols::void_method_signature(), true);
1037
1038 // Set up method for registering loaded classes in class loader vector
1039 _loader_addClass_cache.init(current,
1040 vmClasses::ClassLoader_klass(),
1041 "addClass",
1042 vmSymbols::class_void_signature(), false);
1043
1044 // Set up method for stack walking
1045 _do_stack_walk_cache.init(current,
1046 vmClasses::AbstractStackWalker_klass(),
1047 "doStackWalk",
1048 vmSymbols::doStackWalk_signature(), false);
1049 }
1050
1051 void universe2_init() {
1052 EXCEPTION_MARK;
1053 Universe::genesis(CATCH);
1054 }
1055
1056 // Set after initialization of the module runtime, call_initModuleRuntime
1057 void universe_post_module_init() {
1058 Universe::_module_initialized = true;
1059 }
1060
1061 bool universe_post_init() {
1062 assert(!is_init_completed(), "Error: initialization not yet completed!");
1063 Universe::_fully_initialized = true;
1064 EXCEPTION_MARK;
1065 if (!CDSConfig::is_using_archive()) {
1066 reinitialize_vtables();
1067 reinitialize_itables();
1068 }
|
92 // interacts with the RedefineClasses API.
93 class LatestMethodCache {
94 // We save the InstanceKlass* and the idnum of Method* in order to get
95 // the current Method*.
96 InstanceKlass* _klass;
97 int _method_idnum;
98
99 public:
100 LatestMethodCache() { _klass = nullptr; _method_idnum = -1; }
101
102 void init(JavaThread* current, InstanceKlass* ik, const char* method,
103 Symbol* signature, bool is_static);
104 Method* get_method();
105 };
106
107 static LatestMethodCache _finalizer_register_cache; // Finalizer.register()
108 static LatestMethodCache _loader_addClass_cache; // ClassLoader.addClass()
109 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
110 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
111 static LatestMethodCache _do_stack_walk_cache; // AbstractStackWalker.doStackWalk()
112 static LatestMethodCache _is_substitutable_cache; // ValueObjectMethods.isSubstitutable()
113 static LatestMethodCache _value_object_hash_code_cache; // ValueObjectMethods.valueObjectHashCode()
114
115 // Known objects
116 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
117 ObjArrayKlass* Universe::_objectArrayKlass = nullptr;
118 Klass* Universe::_fillerArrayKlass = nullptr;
119 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
120 #if INCLUDE_CDS_JAVA_HEAP
121 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
122 #endif
123
124 OopHandle Universe::_main_thread_group;
125 OopHandle Universe::_system_thread_group;
126 OopHandle Universe::_the_empty_class_array;
127 OopHandle Universe::_the_null_string;
128 OopHandle Universe::_the_min_jint_string;
129
130 OopHandle Universe::_the_null_sentinel;
131
132 // _out_of_memory_errors is an objArray
133 enum OutOfMemoryInstance { _oom_java_heap,
416 }
417
418 vmSymbols::initialize();
419
420 SystemDictionary::initialize(CHECK);
421
422 // Create string constants
423 oop s = StringTable::intern("null", CHECK);
424 _the_null_string = OopHandle(vm_global(), s);
425 s = StringTable::intern("-2147483648", CHECK);
426 _the_min_jint_string = OopHandle(vm_global(), s);
427
428
429 #if INCLUDE_CDS
430 if (CDSConfig::is_using_archive()) {
431 // Verify shared interfaces array.
432 assert(_the_array_interfaces_array->at(0) ==
433 vmClasses::Cloneable_klass(), "u3");
434 assert(_the_array_interfaces_array->at(1) ==
435 vmClasses::Serializable_klass(), "u3");
436
437 } else
438 #endif
439 {
440 // Set up shared interfaces array. (Do this before supers are set up.)
441 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
442 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
443 }
444
445 if (UseSecondarySupersTable) {
446 Universe::_the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
447 Universe::_the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
448 }
449
450 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
451
452 initialize_basic_type_klass(boolArrayKlass(), CHECK);
453 initialize_basic_type_klass(charArrayKlass(), CHECK);
454 initialize_basic_type_klass(floatArrayKlass(), CHECK);
455 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
456 initialize_basic_type_klass(byteArrayKlass(), CHECK);
850
851 GCLogPrecious::initialize();
852
853 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
854 CPUTimeCounters::initialize();
855
856 #ifdef _LP64
857 MetaspaceShared::adjust_heap_sizes_for_dumping();
858 #endif // _LP64
859
860 GCConfig::arguments()->initialize_heap_sizes();
861
862 jint status = Universe::initialize_heap();
863 if (status != JNI_OK) {
864 return status;
865 }
866
867 Universe::initialize_tlab();
868
869 Metaspace::global_initialize();
870 // Initialize performance counters for metaspaces
871 MetaspaceCounters::initialize_performance_counters();
872
873 // Checks 'AfterMemoryInit' constraints.
874 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
875 return JNI_EINVAL;
876 }
877
878 ClassLoaderData::init_null_class_loader_data();
879
880 #if INCLUDE_CDS
881 DynamicArchive::check_for_dynamic_dump();
882 if (CDSConfig::is_using_archive()) {
883 // Read the data structures supporting the shared spaces (shared
884 // system dictionary, symbol table, etc.)
885 MetaspaceShared::initialize_shared_spaces();
886 }
887 if (CDSConfig::is_dumping_archive()) {
888 MetaspaceShared::prepare_for_dumping();
889 }
1002 _klass = ik;
1003 _method_idnum = m->method_idnum();
1004 assert(_method_idnum >= 0, "sanity check");
1005 }
1006
1007 Method* LatestMethodCache::get_method() {
1008 if (_klass == nullptr) {
1009 return nullptr;
1010 } else {
1011 Method* m = _klass->method_with_idnum(_method_idnum);
1012 assert(m != nullptr, "sanity check");
1013 return m;
1014 }
1015 }
1016
1017 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1018 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1019 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1020 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1021 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1022 Method* Universe::is_substitutable_method() { return _is_substitutable_cache.get_method(); }
1023 Method* Universe::value_object_hash_code_method() { return _value_object_hash_code_cache.get_method(); }
1024
1025 void Universe::initialize_known_methods(JavaThread* current) {
1026 // Set up static method for registering finalizers
1027 _finalizer_register_cache.init(current,
1028 vmClasses::Finalizer_klass(),
1029 "register",
1030 vmSymbols::object_void_signature(), true);
1031
1032 _throw_illegal_access_error_cache.init(current,
1033 vmClasses::internal_Unsafe_klass(),
1034 "throwIllegalAccessError",
1035 vmSymbols::void_method_signature(), true);
1036
1037 _throw_no_such_method_error_cache.init(current,
1038 vmClasses::internal_Unsafe_klass(),
1039 "throwNoSuchMethodError",
1040 vmSymbols::void_method_signature(), true);
1041
1042 // Set up method for registering loaded classes in class loader vector
1043 _loader_addClass_cache.init(current,
1044 vmClasses::ClassLoader_klass(),
1045 "addClass",
1046 vmSymbols::class_void_signature(), false);
1047
1048 // Set up method for stack walking
1049 _do_stack_walk_cache.init(current,
1050 vmClasses::AbstractStackWalker_klass(),
1051 "doStackWalk",
1052 vmSymbols::doStackWalk_signature(), false);
1053
1054 // Set up substitutability testing
1055 ResourceMark rm(current);
1056 _is_substitutable_cache.init(current,
1057 vmClasses::ValueObjectMethods_klass(),
1058 vmSymbols::isSubstitutable_name()->as_C_string(),
1059 vmSymbols::object_object_boolean_signature(), true);
1060 _value_object_hash_code_cache.init(current,
1061 vmClasses::ValueObjectMethods_klass(),
1062 vmSymbols::valueObjectHashCode_name()->as_C_string(),
1063 vmSymbols::object_int_signature(), true);
1064 }
1065
1066 void universe2_init() {
1067 EXCEPTION_MARK;
1068 Universe::genesis(CATCH);
1069 }
1070
1071 // Set after initialization of the module runtime, call_initModuleRuntime
1072 void universe_post_module_init() {
1073 Universe::_module_initialized = true;
1074 }
1075
1076 bool universe_post_init() {
1077 assert(!is_init_completed(), "Error: initialization not yet completed!");
1078 Universe::_fully_initialized = true;
1079 EXCEPTION_MARK;
1080 if (!CDSConfig::is_using_archive()) {
1081 reinitialize_vtables();
1082 reinitialize_itables();
1083 }
|