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,
429 }
430
431 vmSymbols::initialize();
432
433 SystemDictionary::initialize(CHECK);
434
435 // Create string constants
436 oop s = StringTable::intern("null", CHECK);
437 _the_null_string = OopHandle(vm_global(), s);
438 s = StringTable::intern("-2147483648", CHECK);
439 _the_min_jint_string = OopHandle(vm_global(), s);
440
441
442 #if INCLUDE_CDS
443 if (CDSConfig::is_using_archive()) {
444 // Verify shared interfaces array.
445 assert(_the_array_interfaces_array->at(0) ==
446 vmClasses::Cloneable_klass(), "u3");
447 assert(_the_array_interfaces_array->at(1) ==
448 vmClasses::Serializable_klass(), "u3");
449 } else
450 #endif
451 {
452 // Set up shared interfaces array. (Do this before supers are set up.)
453 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
454 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
455 }
456
457 _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
458 _the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
459
460 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
461
462 initialize_basic_type_klass(boolArrayKlass(), CHECK);
463 initialize_basic_type_klass(charArrayKlass(), CHECK);
464 initialize_basic_type_klass(floatArrayKlass(), CHECK);
465 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
466 initialize_basic_type_klass(byteArrayKlass(), CHECK);
467 initialize_basic_type_klass(shortArrayKlass(), CHECK);
468 initialize_basic_type_klass(intArrayKlass(), CHECK);
860
861 GCLogPrecious::initialize();
862
863 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
864 CPUTimeCounters::initialize();
865
866 #ifdef _LP64
867 MetaspaceShared::adjust_heap_sizes_for_dumping();
868 #endif // _LP64
869
870 GCConfig::arguments()->initialize_heap_sizes();
871
872 jint status = Universe::initialize_heap();
873 if (status != JNI_OK) {
874 return status;
875 }
876
877 Universe::initialize_tlab();
878
879 Metaspace::global_initialize();
880
881 // Initialize performance counters for metaspaces
882 MetaspaceCounters::initialize_performance_counters();
883
884 // Checks 'AfterMemoryInit' constraints.
885 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
886 return JNI_EINVAL;
887 }
888
889 ClassLoaderData::init_null_class_loader_data();
890
891 #if INCLUDE_CDS
892 DynamicArchive::check_for_dynamic_dump();
893 if (CDSConfig::is_using_archive()) {
894 // Read the data structures supporting the shared spaces (shared
895 // system dictionary, symbol table, etc.)
896 MetaspaceShared::initialize_shared_spaces();
897 }
898 if (CDSConfig::is_dumping_archive()) {
899 MetaspaceShared::prepare_for_dumping();
900 }
1013 _klass = ik;
1014 _method_idnum = m->method_idnum();
1015 assert(_method_idnum >= 0, "sanity check");
1016 }
1017
1018 Method* LatestMethodCache::get_method() {
1019 if (_klass == nullptr) {
1020 return nullptr;
1021 } else {
1022 Method* m = _klass->method_with_idnum(_method_idnum);
1023 assert(m != nullptr, "sanity check");
1024 return m;
1025 }
1026 }
1027
1028 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1029 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1030 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1031 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1032 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1033
1034 void Universe::initialize_known_methods(JavaThread* current) {
1035 // Set up static method for registering finalizers
1036 _finalizer_register_cache.init(current,
1037 vmClasses::Finalizer_klass(),
1038 "register",
1039 vmSymbols::object_void_signature(), true);
1040
1041 _throw_illegal_access_error_cache.init(current,
1042 vmClasses::internal_Unsafe_klass(),
1043 "throwIllegalAccessError",
1044 vmSymbols::void_method_signature(), true);
1045
1046 _throw_no_such_method_error_cache.init(current,
1047 vmClasses::internal_Unsafe_klass(),
1048 "throwNoSuchMethodError",
1049 vmSymbols::void_method_signature(), true);
1050
1051 // Set up method for registering loaded classes in class loader vector
1052 _loader_addClass_cache.init(current,
1053 vmClasses::ClassLoader_klass(),
1054 "addClass",
1055 vmSymbols::class_void_signature(), false);
1056
1057 // Set up method for stack walking
1058 _do_stack_walk_cache.init(current,
1059 vmClasses::AbstractStackWalker_klass(),
1060 "doStackWalk",
1061 vmSymbols::doStackWalk_signature(), false);
1062 }
1063
1064 void universe2_init() {
1065 EXCEPTION_MARK;
1066 Universe::genesis(CATCH);
1067 }
1068
1069 // Set after initialization of the module runtime, call_initModuleRuntime
1070 void universe_post_module_init() {
1071 Universe::_module_initialized = true;
1072 }
1073
1074 bool universe_post_init() {
1075 assert(!is_init_completed(), "Error: initialization not yet completed!");
1076 Universe::_fully_initialized = true;
1077 EXCEPTION_MARK;
1078 if (!CDSConfig::is_using_archive()) {
1079 reinitialize_vtables();
1080 reinitialize_itables();
1081 }
|
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,
431 }
432
433 vmSymbols::initialize();
434
435 SystemDictionary::initialize(CHECK);
436
437 // Create string constants
438 oop s = StringTable::intern("null", CHECK);
439 _the_null_string = OopHandle(vm_global(), s);
440 s = StringTable::intern("-2147483648", CHECK);
441 _the_min_jint_string = OopHandle(vm_global(), s);
442
443
444 #if INCLUDE_CDS
445 if (CDSConfig::is_using_archive()) {
446 // Verify shared interfaces array.
447 assert(_the_array_interfaces_array->at(0) ==
448 vmClasses::Cloneable_klass(), "u3");
449 assert(_the_array_interfaces_array->at(1) ==
450 vmClasses::Serializable_klass(), "u3");
451
452 } else
453 #endif
454 {
455 // Set up shared interfaces array. (Do this before supers are set up.)
456 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
457 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
458 }
459
460 _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
461 _the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
462
463 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
464
465 initialize_basic_type_klass(boolArrayKlass(), CHECK);
466 initialize_basic_type_klass(charArrayKlass(), CHECK);
467 initialize_basic_type_klass(floatArrayKlass(), CHECK);
468 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
469 initialize_basic_type_klass(byteArrayKlass(), CHECK);
470 initialize_basic_type_klass(shortArrayKlass(), CHECK);
471 initialize_basic_type_klass(intArrayKlass(), CHECK);
863
864 GCLogPrecious::initialize();
865
866 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
867 CPUTimeCounters::initialize();
868
869 #ifdef _LP64
870 MetaspaceShared::adjust_heap_sizes_for_dumping();
871 #endif // _LP64
872
873 GCConfig::arguments()->initialize_heap_sizes();
874
875 jint status = Universe::initialize_heap();
876 if (status != JNI_OK) {
877 return status;
878 }
879
880 Universe::initialize_tlab();
881
882 Metaspace::global_initialize();
883 // Initialize performance counters for metaspaces
884 MetaspaceCounters::initialize_performance_counters();
885
886 // Checks 'AfterMemoryInit' constraints.
887 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
888 return JNI_EINVAL;
889 }
890
891 ClassLoaderData::init_null_class_loader_data();
892
893 #if INCLUDE_CDS
894 DynamicArchive::check_for_dynamic_dump();
895 if (CDSConfig::is_using_archive()) {
896 // Read the data structures supporting the shared spaces (shared
897 // system dictionary, symbol table, etc.)
898 MetaspaceShared::initialize_shared_spaces();
899 }
900 if (CDSConfig::is_dumping_archive()) {
901 MetaspaceShared::prepare_for_dumping();
902 }
1015 _klass = ik;
1016 _method_idnum = m->method_idnum();
1017 assert(_method_idnum >= 0, "sanity check");
1018 }
1019
1020 Method* LatestMethodCache::get_method() {
1021 if (_klass == nullptr) {
1022 return nullptr;
1023 } else {
1024 Method* m = _klass->method_with_idnum(_method_idnum);
1025 assert(m != nullptr, "sanity check");
1026 return m;
1027 }
1028 }
1029
1030 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1031 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1032 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1033 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1034 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1035 Method* Universe::is_substitutable_method() { return _is_substitutable_cache.get_method(); }
1036 Method* Universe::value_object_hash_code_method() { return _value_object_hash_code_cache.get_method(); }
1037
1038 void Universe::initialize_known_methods(JavaThread* current) {
1039 // Set up static method for registering finalizers
1040 _finalizer_register_cache.init(current,
1041 vmClasses::Finalizer_klass(),
1042 "register",
1043 vmSymbols::object_void_signature(), true);
1044
1045 _throw_illegal_access_error_cache.init(current,
1046 vmClasses::internal_Unsafe_klass(),
1047 "throwIllegalAccessError",
1048 vmSymbols::void_method_signature(), true);
1049
1050 _throw_no_such_method_error_cache.init(current,
1051 vmClasses::internal_Unsafe_klass(),
1052 "throwNoSuchMethodError",
1053 vmSymbols::void_method_signature(), true);
1054
1055 // Set up method for registering loaded classes in class loader vector
1056 _loader_addClass_cache.init(current,
1057 vmClasses::ClassLoader_klass(),
1058 "addClass",
1059 vmSymbols::class_void_signature(), false);
1060
1061 // Set up method for stack walking
1062 _do_stack_walk_cache.init(current,
1063 vmClasses::AbstractStackWalker_klass(),
1064 "doStackWalk",
1065 vmSymbols::doStackWalk_signature(), false);
1066
1067 // Set up substitutability testing
1068 ResourceMark rm(current);
1069 _is_substitutable_cache.init(current,
1070 vmClasses::ValueObjectMethods_klass(),
1071 vmSymbols::isSubstitutable_name()->as_C_string(),
1072 vmSymbols::object_object_boolean_signature(), true);
1073 _value_object_hash_code_cache.init(current,
1074 vmClasses::ValueObjectMethods_klass(),
1075 vmSymbols::valueObjectHashCode_name()->as_C_string(),
1076 vmSymbols::object_int_signature(), true);
1077 }
1078
1079 void universe2_init() {
1080 EXCEPTION_MARK;
1081 Universe::genesis(CATCH);
1082 }
1083
1084 // Set after initialization of the module runtime, call_initModuleRuntime
1085 void universe_post_module_init() {
1086 Universe::_module_initialized = true;
1087 }
1088
1089 bool universe_post_init() {
1090 assert(!is_init_completed(), "Error: initialization not yet completed!");
1091 Universe::_fully_initialized = true;
1092 EXCEPTION_MARK;
1093 if (!CDSConfig::is_using_archive()) {
1094 reinitialize_vtables();
1095 reinitialize_itables();
1096 }
|