93 // interacts with the RedefineClasses API.
94 class LatestMethodCache {
95 // We save the InstanceKlass* and the idnum of Method* in order to get
96 // the current Method*.
97 InstanceKlass* _klass;
98 int _method_idnum;
99
100 public:
101 LatestMethodCache() { _klass = nullptr; _method_idnum = -1; }
102
103 void init(JavaThread* current, InstanceKlass* ik, const char* method,
104 Symbol* signature, bool is_static);
105 Method* get_method();
106 };
107
108 static LatestMethodCache _finalizer_register_cache; // Finalizer.register()
109 static LatestMethodCache _loader_addClass_cache; // ClassLoader.addClass()
110 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
111 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
112 static LatestMethodCache _do_stack_walk_cache; // AbstractStackWalker.doStackWalk()
113
114 // Known objects
115 TypeArrayKlass* Universe::_typeArrayKlasses[T_LONG+1] = { nullptr /*, nullptr...*/ };
116 ObjArrayKlass* Universe::_objectArrayKlass = nullptr;
117 Klass* Universe::_fillerArrayKlass = nullptr;
118 OopHandle Universe::_basic_type_mirrors[T_VOID+1];
119 #if INCLUDE_CDS_JAVA_HEAP
120 int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
121 #endif
122
123 OopHandle Universe::_main_thread_group;
124 OopHandle Universe::_system_thread_group;
125 OopHandle Universe::_the_empty_class_array;
126 OopHandle Universe::_the_null_string;
127 OopHandle Universe::_the_min_jint_string;
128
129 OopHandle Universe::_the_null_sentinel;
130
131 // _out_of_memory_errors is an objArray
132 enum OutOfMemoryInstance { _oom_java_heap,
435 }
436
437 vmSymbols::initialize();
438
439 SystemDictionary::initialize(CHECK);
440
441 // Create string constants
442 oop s = StringTable::intern("null", CHECK);
443 _the_null_string = OopHandle(vm_global(), s);
444 s = StringTable::intern("-2147483648", CHECK);
445 _the_min_jint_string = OopHandle(vm_global(), s);
446
447
448 #if INCLUDE_CDS
449 if (CDSConfig::is_using_archive()) {
450 // Verify shared interfaces array.
451 assert(_the_array_interfaces_array->at(0) ==
452 vmClasses::Cloneable_klass(), "u3");
453 assert(_the_array_interfaces_array->at(1) ==
454 vmClasses::Serializable_klass(), "u3");
455 } else
456 #endif
457 {
458 // Set up shared interfaces array. (Do this before supers are set up.)
459 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
460 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
461 }
462
463 _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
464 _the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
465
466 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
467
468 initialize_basic_type_klass(boolArrayKlass(), CHECK);
469 initialize_basic_type_klass(charArrayKlass(), CHECK);
470 initialize_basic_type_klass(floatArrayKlass(), CHECK);
471 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
472 initialize_basic_type_klass(byteArrayKlass(), CHECK);
473 initialize_basic_type_klass(shortArrayKlass(), CHECK);
474 initialize_basic_type_klass(intArrayKlass(), CHECK);
868
869 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
870 CPUTimeCounters::initialize();
871
872 ObjLayout::initialize();
873
874 #ifdef _LP64
875 MetaspaceShared::adjust_heap_sizes_for_dumping();
876 #endif // _LP64
877
878 GCConfig::arguments()->initialize_heap_sizes();
879
880 jint status = Universe::initialize_heap();
881 if (status != JNI_OK) {
882 return status;
883 }
884
885 Universe::initialize_tlab();
886
887 Metaspace::global_initialize();
888
889 // Initialize performance counters for metaspaces
890 MetaspaceCounters::initialize_performance_counters();
891
892 // Checks 'AfterMemoryInit' constraints.
893 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
894 return JNI_EINVAL;
895 }
896
897 ClassLoaderData::init_null_class_loader_data();
898
899 #if INCLUDE_CDS
900 DynamicArchive::check_for_dynamic_dump();
901 if (CDSConfig::is_using_archive()) {
902 // Read the data structures supporting the shared spaces (shared
903 // system dictionary, symbol table, etc.)
904 MetaspaceShared::initialize_shared_spaces();
905 }
906 if (CDSConfig::is_dumping_archive()) {
907 MetaspaceShared::prepare_for_dumping();
908 }
1024 _klass = ik;
1025 _method_idnum = m->method_idnum();
1026 assert(_method_idnum >= 0, "sanity check");
1027 }
1028
1029 Method* LatestMethodCache::get_method() {
1030 if (_klass == nullptr) {
1031 return nullptr;
1032 } else {
1033 Method* m = _klass->method_with_idnum(_method_idnum);
1034 assert(m != nullptr, "sanity check");
1035 return m;
1036 }
1037 }
1038
1039 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1040 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1041 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1042 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1043 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1044
1045 void Universe::initialize_known_methods(JavaThread* current) {
1046 // Set up static method for registering finalizers
1047 _finalizer_register_cache.init(current,
1048 vmClasses::Finalizer_klass(),
1049 "register",
1050 vmSymbols::object_void_signature(), true);
1051
1052 _throw_illegal_access_error_cache.init(current,
1053 vmClasses::internal_Unsafe_klass(),
1054 "throwIllegalAccessError",
1055 vmSymbols::void_method_signature(), true);
1056
1057 _throw_no_such_method_error_cache.init(current,
1058 vmClasses::internal_Unsafe_klass(),
1059 "throwNoSuchMethodError",
1060 vmSymbols::void_method_signature(), true);
1061
1062 // Set up method for registering loaded classes in class loader vector
1063 _loader_addClass_cache.init(current,
1064 vmClasses::ClassLoader_klass(),
1065 "addClass",
1066 vmSymbols::class_void_signature(), false);
1067
1068 // Set up method for stack walking
1069 _do_stack_walk_cache.init(current,
1070 vmClasses::AbstractStackWalker_klass(),
1071 "doStackWalk",
1072 vmSymbols::doStackWalk_signature(), false);
1073 }
1074
1075 void universe2_init() {
1076 EXCEPTION_MARK;
1077 Universe::genesis(CATCH);
1078 }
1079
1080 // Set after initialization of the module runtime, call_initModuleRuntime
1081 void universe_post_module_init() {
1082 Universe::_module_initialized = true;
1083 }
1084
1085 bool universe_post_init() {
1086 assert(!is_init_completed(), "Error: initialization not yet completed!");
1087 Universe::_fully_initialized = true;
1088 EXCEPTION_MARK;
1089 if (!CDSConfig::is_using_archive()) {
1090 reinitialize_vtables();
1091 reinitialize_itables();
1092 }
|
93 // interacts with the RedefineClasses API.
94 class LatestMethodCache {
95 // We save the InstanceKlass* and the idnum of Method* in order to get
96 // the current Method*.
97 InstanceKlass* _klass;
98 int _method_idnum;
99
100 public:
101 LatestMethodCache() { _klass = nullptr; _method_idnum = -1; }
102
103 void init(JavaThread* current, InstanceKlass* ik, const char* method,
104 Symbol* signature, bool is_static);
105 Method* get_method();
106 };
107
108 static LatestMethodCache _finalizer_register_cache; // Finalizer.register()
109 static LatestMethodCache _loader_addClass_cache; // ClassLoader.addClass()
110 static LatestMethodCache _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError()
111 static LatestMethodCache _throw_no_such_method_error_cache; // Unsafe.throwNoSuchMethodError()
112 static LatestMethodCache _do_stack_walk_cache; // AbstractStackWalker.doStackWalk()
113 static LatestMethodCache _is_substitutable_cache; // ValueObjectMethods.isSubstitutable()
114 static LatestMethodCache _value_object_hash_code_cache; // ValueObjectMethods.valueObjectHashCode()
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,
437 }
438
439 vmSymbols::initialize();
440
441 SystemDictionary::initialize(CHECK);
442
443 // Create string constants
444 oop s = StringTable::intern("null", CHECK);
445 _the_null_string = OopHandle(vm_global(), s);
446 s = StringTable::intern("-2147483648", CHECK);
447 _the_min_jint_string = OopHandle(vm_global(), s);
448
449
450 #if INCLUDE_CDS
451 if (CDSConfig::is_using_archive()) {
452 // Verify shared interfaces array.
453 assert(_the_array_interfaces_array->at(0) ==
454 vmClasses::Cloneable_klass(), "u3");
455 assert(_the_array_interfaces_array->at(1) ==
456 vmClasses::Serializable_klass(), "u3");
457
458 } else
459 #endif
460 {
461 // Set up shared interfaces array. (Do this before supers are set up.)
462 _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
463 _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
464 }
465
466 _the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
467 _the_empty_klass_bitmap = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
468
469 initialize_basic_type_klass(_fillerArrayKlass, CHECK);
470
471 initialize_basic_type_klass(boolArrayKlass(), CHECK);
472 initialize_basic_type_klass(charArrayKlass(), CHECK);
473 initialize_basic_type_klass(floatArrayKlass(), CHECK);
474 initialize_basic_type_klass(doubleArrayKlass(), CHECK);
475 initialize_basic_type_klass(byteArrayKlass(), CHECK);
476 initialize_basic_type_klass(shortArrayKlass(), CHECK);
477 initialize_basic_type_klass(intArrayKlass(), CHECK);
871
872 // Initialize CPUTimeCounters object, which must be done before creation of the heap.
873 CPUTimeCounters::initialize();
874
875 ObjLayout::initialize();
876
877 #ifdef _LP64
878 MetaspaceShared::adjust_heap_sizes_for_dumping();
879 #endif // _LP64
880
881 GCConfig::arguments()->initialize_heap_sizes();
882
883 jint status = Universe::initialize_heap();
884 if (status != JNI_OK) {
885 return status;
886 }
887
888 Universe::initialize_tlab();
889
890 Metaspace::global_initialize();
891 // Initialize performance counters for metaspaces
892 MetaspaceCounters::initialize_performance_counters();
893
894 // Checks 'AfterMemoryInit' constraints.
895 if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
896 return JNI_EINVAL;
897 }
898
899 ClassLoaderData::init_null_class_loader_data();
900
901 #if INCLUDE_CDS
902 DynamicArchive::check_for_dynamic_dump();
903 if (CDSConfig::is_using_archive()) {
904 // Read the data structures supporting the shared spaces (shared
905 // system dictionary, symbol table, etc.)
906 MetaspaceShared::initialize_shared_spaces();
907 }
908 if (CDSConfig::is_dumping_archive()) {
909 MetaspaceShared::prepare_for_dumping();
910 }
1026 _klass = ik;
1027 _method_idnum = m->method_idnum();
1028 assert(_method_idnum >= 0, "sanity check");
1029 }
1030
1031 Method* LatestMethodCache::get_method() {
1032 if (_klass == nullptr) {
1033 return nullptr;
1034 } else {
1035 Method* m = _klass->method_with_idnum(_method_idnum);
1036 assert(m != nullptr, "sanity check");
1037 return m;
1038 }
1039 }
1040
1041 Method* Universe::finalizer_register_method() { return _finalizer_register_cache.get_method(); }
1042 Method* Universe::loader_addClass_method() { return _loader_addClass_cache.get_method(); }
1043 Method* Universe::throw_illegal_access_error() { return _throw_illegal_access_error_cache.get_method(); }
1044 Method* Universe::throw_no_such_method_error() { return _throw_no_such_method_error_cache.get_method(); }
1045 Method* Universe::do_stack_walk_method() { return _do_stack_walk_cache.get_method(); }
1046 Method* Universe::is_substitutable_method() { return _is_substitutable_cache.get_method(); }
1047 Method* Universe::value_object_hash_code_method() { return _value_object_hash_code_cache.get_method(); }
1048
1049 void Universe::initialize_known_methods(JavaThread* current) {
1050 // Set up static method for registering finalizers
1051 _finalizer_register_cache.init(current,
1052 vmClasses::Finalizer_klass(),
1053 "register",
1054 vmSymbols::object_void_signature(), true);
1055
1056 _throw_illegal_access_error_cache.init(current,
1057 vmClasses::internal_Unsafe_klass(),
1058 "throwIllegalAccessError",
1059 vmSymbols::void_method_signature(), true);
1060
1061 _throw_no_such_method_error_cache.init(current,
1062 vmClasses::internal_Unsafe_klass(),
1063 "throwNoSuchMethodError",
1064 vmSymbols::void_method_signature(), true);
1065
1066 // Set up method for registering loaded classes in class loader vector
1067 _loader_addClass_cache.init(current,
1068 vmClasses::ClassLoader_klass(),
1069 "addClass",
1070 vmSymbols::class_void_signature(), false);
1071
1072 // Set up method for stack walking
1073 _do_stack_walk_cache.init(current,
1074 vmClasses::AbstractStackWalker_klass(),
1075 "doStackWalk",
1076 vmSymbols::doStackWalk_signature(), false);
1077
1078 // Set up substitutability testing
1079 ResourceMark rm(current);
1080 _is_substitutable_cache.init(current,
1081 vmClasses::ValueObjectMethods_klass(),
1082 vmSymbols::isSubstitutable_name()->as_C_string(),
1083 vmSymbols::object_object_boolean_signature(), true);
1084 _value_object_hash_code_cache.init(current,
1085 vmClasses::ValueObjectMethods_klass(),
1086 vmSymbols::valueObjectHashCode_name()->as_C_string(),
1087 vmSymbols::object_int_signature(), true);
1088 }
1089
1090 void universe2_init() {
1091 EXCEPTION_MARK;
1092 Universe::genesis(CATCH);
1093 }
1094
1095 // Set after initialization of the module runtime, call_initModuleRuntime
1096 void universe_post_module_init() {
1097 Universe::_module_initialized = true;
1098 }
1099
1100 bool universe_post_init() {
1101 assert(!is_init_completed(), "Error: initialization not yet completed!");
1102 Universe::_fully_initialized = true;
1103 EXCEPTION_MARK;
1104 if (!CDSConfig::is_using_archive()) {
1105 reinitialize_vtables();
1106 reinitialize_itables();
1107 }
|