< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

  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     if (UseSecondarySupersTable) {
 458       Universe::_the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
 459       Universe::_the_empty_klass_bitmap      = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
 460     }
 461 
 462     initialize_basic_type_klass(_fillerArrayKlass, CHECK);
 463 
 464     initialize_basic_type_klass(boolArrayKlass(), CHECK);
 465     initialize_basic_type_klass(charArrayKlass(), CHECK);
 466     initialize_basic_type_klass(floatArrayKlass(), CHECK);
 467     initialize_basic_type_klass(doubleArrayKlass(), CHECK);
 468     initialize_basic_type_klass(byteArrayKlass(), CHECK);

 862 
 863   GCLogPrecious::initialize();
 864 
 865   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 866   CPUTimeCounters::initialize();
 867 
 868 #ifdef _LP64
 869   MetaspaceShared::adjust_heap_sizes_for_dumping();
 870 #endif // _LP64
 871 
 872   GCConfig::arguments()->initialize_heap_sizes();
 873 
 874   jint status = Universe::initialize_heap();
 875   if (status != JNI_OK) {
 876     return status;
 877   }
 878 
 879   Universe::initialize_tlab();
 880 
 881   Metaspace::global_initialize();
 882 
 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 
1036 void Universe::initialize_known_methods(JavaThread* current) {
1037   // Set up static method for registering finalizers
1038   _finalizer_register_cache.init(current,
1039                           vmClasses::Finalizer_klass(),
1040                           "register",
1041                           vmSymbols::object_void_signature(), true);
1042 
1043   _throw_illegal_access_error_cache.init(current,
1044                           vmClasses::internal_Unsafe_klass(),
1045                           "throwIllegalAccessError",
1046                           vmSymbols::void_method_signature(), true);
1047 
1048   _throw_no_such_method_error_cache.init(current,
1049                           vmClasses::internal_Unsafe_klass(),
1050                           "throwNoSuchMethodError",
1051                           vmSymbols::void_method_signature(), true);
1052 
1053   // Set up method for registering loaded classes in class loader vector
1054   _loader_addClass_cache.init(current,
1055                           vmClasses::ClassLoader_klass(),
1056                           "addClass",
1057                           vmSymbols::class_void_signature(), false);
1058 
1059   // Set up method for stack walking
1060   _do_stack_walk_cache.init(current,
1061                           vmClasses::AbstractStackWalker_klass(),
1062                           "doStackWalk",
1063                           vmSymbols::doStackWalk_signature(), false);











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   }

  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     if (UseSecondarySupersTable) {
 461       Universe::_the_array_interfaces_bitmap = Klass::compute_secondary_supers_bitmap(_the_array_interfaces_array);
 462       Universe::_the_empty_klass_bitmap      = Klass::compute_secondary_supers_bitmap(_the_empty_klass_array);
 463     }
 464 
 465     initialize_basic_type_klass(_fillerArrayKlass, CHECK);
 466 
 467     initialize_basic_type_klass(boolArrayKlass(), CHECK);
 468     initialize_basic_type_klass(charArrayKlass(), CHECK);
 469     initialize_basic_type_klass(floatArrayKlass(), CHECK);
 470     initialize_basic_type_klass(doubleArrayKlass(), CHECK);
 471     initialize_basic_type_klass(byteArrayKlass(), CHECK);

 865 
 866   GCLogPrecious::initialize();
 867 
 868   // Initialize CPUTimeCounters object, which must be done before creation of the heap.
 869   CPUTimeCounters::initialize();
 870 
 871 #ifdef _LP64
 872   MetaspaceShared::adjust_heap_sizes_for_dumping();
 873 #endif // _LP64
 874 
 875   GCConfig::arguments()->initialize_heap_sizes();
 876 
 877   jint status = Universe::initialize_heap();
 878   if (status != JNI_OK) {
 879     return status;
 880   }
 881 
 882   Universe::initialize_tlab();
 883 
 884   Metaspace::global_initialize();

 885   // Initialize performance counters for metaspaces
 886   MetaspaceCounters::initialize_performance_counters();
 887 
 888   // Checks 'AfterMemoryInit' constraints.
 889   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 890     return JNI_EINVAL;
 891   }
 892 
 893   ClassLoaderData::init_null_class_loader_data();
 894 
 895 #if INCLUDE_CDS
 896   DynamicArchive::check_for_dynamic_dump();
 897   if (CDSConfig::is_using_archive()) {
 898     // Read the data structures supporting the shared spaces (shared
 899     // system dictionary, symbol table, etc.)
 900     MetaspaceShared::initialize_shared_spaces();
 901   }
 902   if (CDSConfig::is_dumping_archive()) {
 903     MetaspaceShared::prepare_for_dumping();
 904   }

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