< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

 221   void load_from_cds() {
 222     if (_archived_root_index >= 0) {
 223       oop obj = HeapShared::get_root(_archived_root_index);
 224       assert(obj != nullptr, "must be");
 225       _instance = OopHandle(Universe::vm_global(), obj);
 226     }
 227   }
 228 
 229   void serialize(SerializeClosure *f) {
 230     f->do_int(&_archived_root_index);
 231   }
 232 #endif
 233 };
 234 
 235 static BuiltinException _null_ptr_exception;
 236 static BuiltinException _arithmetic_exception;
 237 static BuiltinException _internal_error;
 238 static BuiltinException _array_index_out_of_bounds_exception;
 239 static BuiltinException _array_store_exception;
 240 static BuiltinException _class_cast_exception;

 241 
 242 objArrayOop Universe::the_empty_class_array ()  {
 243   return (objArrayOop)_the_empty_class_array.resolve();
 244 }
 245 
 246 oop Universe::main_thread_group()                 { return _main_thread_group.resolve(); }
 247 void Universe::set_main_thread_group(oop group)   { _main_thread_group = OopHandle(vm_global(), group); }
 248 
 249 oop Universe::system_thread_group()               { return _system_thread_group.resolve(); }
 250 void Universe::set_system_thread_group(oop group) { _system_thread_group = OopHandle(vm_global(), group); }
 251 
 252 oop Universe::the_null_string()                   { return _the_null_string.resolve(); }
 253 oop Universe::the_min_jint_string()               { return _the_min_jint_string.resolve(); }
 254 
 255 oop Universe::null_ptr_exception_instance()       { return _null_ptr_exception.instance(); }
 256 oop Universe::arithmetic_exception_instance()     { return _arithmetic_exception.instance(); }
 257 oop Universe::internal_error_instance()           { return _internal_error.instance(); }
 258 oop Universe::array_index_out_of_bounds_exception_instance() { return _array_index_out_of_bounds_exception.instance(); }
 259 oop Universe::array_store_exception_instance()    { return _array_store_exception.instance(); }
 260 oop Universe::class_cast_exception_instance()     { return _class_cast_exception.instance(); }

 261 
 262 oop Universe::the_null_sentinel()                 { return _the_null_sentinel.resolve(); }
 263 
 264 oop Universe::int_mirror()                        { return check_mirror(_basic_type_mirrors[T_INT].resolve()); }
 265 oop Universe::float_mirror()                      { return check_mirror(_basic_type_mirrors[T_FLOAT].resolve()); }
 266 oop Universe::double_mirror()                     { return check_mirror(_basic_type_mirrors[T_DOUBLE].resolve()); }
 267 oop Universe::byte_mirror()                       { return check_mirror(_basic_type_mirrors[T_BYTE].resolve()); }
 268 oop Universe::bool_mirror()                       { return check_mirror(_basic_type_mirrors[T_BOOLEAN].resolve()); }
 269 oop Universe::char_mirror()                       { return check_mirror(_basic_type_mirrors[T_CHAR].resolve()); }
 270 oop Universe::long_mirror()                       { return check_mirror(_basic_type_mirrors[T_LONG].resolve()); }
 271 oop Universe::short_mirror()                      { return check_mirror(_basic_type_mirrors[T_SHORT].resolve()); }
 272 oop Universe::void_mirror()                       { return check_mirror(_basic_type_mirrors[T_VOID].resolve()); }
 273 
 274 oop Universe::java_mirror(BasicType t) {
 275   assert((uint)t < T_VOID+1, "range check");
 276   assert(!is_reference_type(t), "sanity");
 277   return check_mirror(_basic_type_mirrors[t].resolve());
 278 }
 279 
 280 void Universe::basic_type_classes_do(KlassClosure *closure) {

 300   it->push(&_the_empty_klass_array);
 301   it->push(&_the_empty_instance_klass_array);
 302   it->push(&_the_empty_method_array);
 303   it->push(&_the_array_interfaces_array);
 304 }
 305 
 306 #if INCLUDE_CDS_JAVA_HEAP
 307 void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) {
 308   assert(CDSConfig::is_dumping_heap(), "sanity");
 309   assert(!is_reference_type(t), "sanity");
 310   _archived_basic_type_mirror_indices[t] = index;
 311 }
 312 
 313 void Universe::archive_exception_instances() {
 314   _null_ptr_exception.store_in_cds();
 315   _arithmetic_exception.store_in_cds();
 316   _internal_error.store_in_cds();
 317   _array_index_out_of_bounds_exception.store_in_cds();
 318   _array_store_exception.store_in_cds();
 319   _class_cast_exception.store_in_cds();

 320 }
 321 
 322 void Universe::load_archived_object_instances() {
 323   if (ArchiveHeapLoader::is_in_use()) {
 324     for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 325       int index = _archived_basic_type_mirror_indices[i];
 326       if (!is_reference_type((BasicType)i) && index >= 0) {
 327         oop mirror_oop = HeapShared::get_root(index);
 328         assert(mirror_oop != nullptr, "must be");
 329         _basic_type_mirrors[i] = OopHandle(vm_global(), mirror_oop);
 330       }
 331     }
 332 
 333     _null_ptr_exception.load_from_cds();
 334     _arithmetic_exception.load_from_cds();
 335     _internal_error.load_from_cds();
 336     _array_index_out_of_bounds_exception.load_from_cds();
 337     _array_store_exception.load_from_cds();
 338     _class_cast_exception.load_from_cds();

 339   }
 340 }
 341 #endif
 342 
 343 void Universe::serialize(SerializeClosure* f) {
 344 
 345 #if INCLUDE_CDS_JAVA_HEAP
 346   for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 347     f->do_int(&_archived_basic_type_mirror_indices[i]);
 348     // if f->reading(): We can't call HeapShared::get_root() yet, as the heap
 349     // contents may need to be relocated. _basic_type_mirrors[i] will be
 350     // updated later in Universe::load_archived_object_instances().
 351   }
 352   _null_ptr_exception.serialize(f);
 353   _arithmetic_exception.serialize(f);
 354   _internal_error.serialize(f);
 355   _array_index_out_of_bounds_exception.serialize(f);
 356   _array_store_exception.serialize(f);
 357   _class_cast_exception.serialize(f);

 358 #endif
 359 
 360   f->do_ptr(&_fillerArrayKlass);
 361   for (int i = 0; i < T_LONG+1; i++) {
 362     f->do_ptr(&_typeArrayKlasses[i]);
 363   }
 364 
 365   f->do_ptr(&_objectArrayKlass);
 366   f->do_ptr(&_the_array_interfaces_array);
 367   f->do_ptr(&_the_empty_int_array);
 368   f->do_ptr(&_the_empty_short_array);
 369   f->do_ptr(&_the_empty_method_array);
 370   f->do_ptr(&_the_empty_klass_array);
 371   f->do_ptr(&_the_empty_instance_klass_array);
 372 }
 373 
 374 
 375 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 376   if (size < alignment || size % alignment != 0) {
 377     vm_exit_during_initialization(

1116 
1117   objArrayOop the_empty_class_array = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_false);
1118   Universe::_the_empty_class_array = OopHandle(Universe::vm_global(), the_empty_class_array);
1119 
1120   // Setup preallocated OutOfMemoryError errors
1121   Universe::create_preallocated_out_of_memory_errors(CHECK_false);
1122 
1123   oop instance;
1124   // Setup preallocated cause message for delayed StackOverflowError
1125   if (StackReservedPages > 0) {
1126     instance = java_lang_String::create_oop_from_str("Delayed StackOverflowError due to ReservedStackAccess annotated method", CHECK_false);
1127     Universe::_delayed_stack_overflow_error_message = OopHandle(Universe::vm_global(), instance);
1128   }
1129 
1130   // Setup preallocated exceptions used for a cheap & dirty solution in compiler exception handling
1131   _null_ptr_exception.init_if_empty(vmSymbols::java_lang_NullPointerException(), CHECK_false);
1132   _arithmetic_exception.init_if_empty(vmSymbols::java_lang_ArithmeticException(), CHECK_false);
1133   _array_index_out_of_bounds_exception.init_if_empty(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), CHECK_false);
1134   _array_store_exception.init_if_empty(vmSymbols::java_lang_ArrayStoreException(), CHECK_false);
1135   _class_cast_exception.init_if_empty(vmSymbols::java_lang_ClassCastException(), CHECK_false);

1136 
1137   // Virtual Machine Error for when we get into a situation we can't resolve
1138   Klass* k = vmClasses::InternalError_klass();
1139   bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
1140   if (!linked) {
1141      tty->print_cr("Unable to link/verify InternalError class");
1142      return false; // initialization failed
1143   }
1144   _internal_error.init_if_empty(vmSymbols::java_lang_InternalError(), CHECK_false);
1145 
1146   Handle msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
1147   java_lang_Throwable::set_message(Universe::arithmetic_exception_instance(), msg());
1148 
1149   // Setup preallocated StackOverflowError for use with class initialization failure
1150   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_StackOverflowError(), true, CHECK_false);
1151   instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1152   Universe::_class_init_stack_overflow_error = OopHandle(Universe::vm_global(), instance);
1153 
1154   Universe::initialize_known_methods(THREAD);
1155 

 221   void load_from_cds() {
 222     if (_archived_root_index >= 0) {
 223       oop obj = HeapShared::get_root(_archived_root_index);
 224       assert(obj != nullptr, "must be");
 225       _instance = OopHandle(Universe::vm_global(), obj);
 226     }
 227   }
 228 
 229   void serialize(SerializeClosure *f) {
 230     f->do_int(&_archived_root_index);
 231   }
 232 #endif
 233 };
 234 
 235 static BuiltinException _null_ptr_exception;
 236 static BuiltinException _arithmetic_exception;
 237 static BuiltinException _internal_error;
 238 static BuiltinException _array_index_out_of_bounds_exception;
 239 static BuiltinException _array_store_exception;
 240 static BuiltinException _class_cast_exception;
 241 static BuiltinException _preempted_exception;
 242 
 243 objArrayOop Universe::the_empty_class_array ()  {
 244   return (objArrayOop)_the_empty_class_array.resolve();
 245 }
 246 
 247 oop Universe::main_thread_group()                 { return _main_thread_group.resolve(); }
 248 void Universe::set_main_thread_group(oop group)   { _main_thread_group = OopHandle(vm_global(), group); }
 249 
 250 oop Universe::system_thread_group()               { return _system_thread_group.resolve(); }
 251 void Universe::set_system_thread_group(oop group) { _system_thread_group = OopHandle(vm_global(), group); }
 252 
 253 oop Universe::the_null_string()                   { return _the_null_string.resolve(); }
 254 oop Universe::the_min_jint_string()               { return _the_min_jint_string.resolve(); }
 255 
 256 oop Universe::null_ptr_exception_instance()       { return _null_ptr_exception.instance(); }
 257 oop Universe::arithmetic_exception_instance()     { return _arithmetic_exception.instance(); }
 258 oop Universe::internal_error_instance()           { return _internal_error.instance(); }
 259 oop Universe::array_index_out_of_bounds_exception_instance() { return _array_index_out_of_bounds_exception.instance(); }
 260 oop Universe::array_store_exception_instance()    { return _array_store_exception.instance(); }
 261 oop Universe::class_cast_exception_instance()     { return _class_cast_exception.instance(); }
 262 oop Universe::preempted_exception_instance()      { return _preempted_exception.instance(); }
 263 
 264 oop Universe::the_null_sentinel()                 { return _the_null_sentinel.resolve(); }
 265 
 266 oop Universe::int_mirror()                        { return check_mirror(_basic_type_mirrors[T_INT].resolve()); }
 267 oop Universe::float_mirror()                      { return check_mirror(_basic_type_mirrors[T_FLOAT].resolve()); }
 268 oop Universe::double_mirror()                     { return check_mirror(_basic_type_mirrors[T_DOUBLE].resolve()); }
 269 oop Universe::byte_mirror()                       { return check_mirror(_basic_type_mirrors[T_BYTE].resolve()); }
 270 oop Universe::bool_mirror()                       { return check_mirror(_basic_type_mirrors[T_BOOLEAN].resolve()); }
 271 oop Universe::char_mirror()                       { return check_mirror(_basic_type_mirrors[T_CHAR].resolve()); }
 272 oop Universe::long_mirror()                       { return check_mirror(_basic_type_mirrors[T_LONG].resolve()); }
 273 oop Universe::short_mirror()                      { return check_mirror(_basic_type_mirrors[T_SHORT].resolve()); }
 274 oop Universe::void_mirror()                       { return check_mirror(_basic_type_mirrors[T_VOID].resolve()); }
 275 
 276 oop Universe::java_mirror(BasicType t) {
 277   assert((uint)t < T_VOID+1, "range check");
 278   assert(!is_reference_type(t), "sanity");
 279   return check_mirror(_basic_type_mirrors[t].resolve());
 280 }
 281 
 282 void Universe::basic_type_classes_do(KlassClosure *closure) {

 302   it->push(&_the_empty_klass_array);
 303   it->push(&_the_empty_instance_klass_array);
 304   it->push(&_the_empty_method_array);
 305   it->push(&_the_array_interfaces_array);
 306 }
 307 
 308 #if INCLUDE_CDS_JAVA_HEAP
 309 void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) {
 310   assert(CDSConfig::is_dumping_heap(), "sanity");
 311   assert(!is_reference_type(t), "sanity");
 312   _archived_basic_type_mirror_indices[t] = index;
 313 }
 314 
 315 void Universe::archive_exception_instances() {
 316   _null_ptr_exception.store_in_cds();
 317   _arithmetic_exception.store_in_cds();
 318   _internal_error.store_in_cds();
 319   _array_index_out_of_bounds_exception.store_in_cds();
 320   _array_store_exception.store_in_cds();
 321   _class_cast_exception.store_in_cds();
 322   _preempted_exception.store_in_cds();
 323 }
 324 
 325 void Universe::load_archived_object_instances() {
 326   if (ArchiveHeapLoader::is_in_use()) {
 327     for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 328       int index = _archived_basic_type_mirror_indices[i];
 329       if (!is_reference_type((BasicType)i) && index >= 0) {
 330         oop mirror_oop = HeapShared::get_root(index);
 331         assert(mirror_oop != nullptr, "must be");
 332         _basic_type_mirrors[i] = OopHandle(vm_global(), mirror_oop);
 333       }
 334     }
 335 
 336     _null_ptr_exception.load_from_cds();
 337     _arithmetic_exception.load_from_cds();
 338     _internal_error.load_from_cds();
 339     _array_index_out_of_bounds_exception.load_from_cds();
 340     _array_store_exception.load_from_cds();
 341     _class_cast_exception.load_from_cds();
 342     _preempted_exception.load_from_cds();
 343   }
 344 }
 345 #endif
 346 
 347 void Universe::serialize(SerializeClosure* f) {
 348 
 349 #if INCLUDE_CDS_JAVA_HEAP
 350   for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 351     f->do_int(&_archived_basic_type_mirror_indices[i]);
 352     // if f->reading(): We can't call HeapShared::get_root() yet, as the heap
 353     // contents may need to be relocated. _basic_type_mirrors[i] will be
 354     // updated later in Universe::load_archived_object_instances().
 355   }
 356   _null_ptr_exception.serialize(f);
 357   _arithmetic_exception.serialize(f);
 358   _internal_error.serialize(f);
 359   _array_index_out_of_bounds_exception.serialize(f);
 360   _array_store_exception.serialize(f);
 361   _class_cast_exception.serialize(f);
 362   _preempted_exception.serialize(f);
 363 #endif
 364 
 365   f->do_ptr(&_fillerArrayKlass);
 366   for (int i = 0; i < T_LONG+1; i++) {
 367     f->do_ptr(&_typeArrayKlasses[i]);
 368   }
 369 
 370   f->do_ptr(&_objectArrayKlass);
 371   f->do_ptr(&_the_array_interfaces_array);
 372   f->do_ptr(&_the_empty_int_array);
 373   f->do_ptr(&_the_empty_short_array);
 374   f->do_ptr(&_the_empty_method_array);
 375   f->do_ptr(&_the_empty_klass_array);
 376   f->do_ptr(&_the_empty_instance_klass_array);
 377 }
 378 
 379 
 380 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 381   if (size < alignment || size % alignment != 0) {
 382     vm_exit_during_initialization(

1121 
1122   objArrayOop the_empty_class_array = oopFactory::new_objArray(vmClasses::Class_klass(), 0, CHECK_false);
1123   Universe::_the_empty_class_array = OopHandle(Universe::vm_global(), the_empty_class_array);
1124 
1125   // Setup preallocated OutOfMemoryError errors
1126   Universe::create_preallocated_out_of_memory_errors(CHECK_false);
1127 
1128   oop instance;
1129   // Setup preallocated cause message for delayed StackOverflowError
1130   if (StackReservedPages > 0) {
1131     instance = java_lang_String::create_oop_from_str("Delayed StackOverflowError due to ReservedStackAccess annotated method", CHECK_false);
1132     Universe::_delayed_stack_overflow_error_message = OopHandle(Universe::vm_global(), instance);
1133   }
1134 
1135   // Setup preallocated exceptions used for a cheap & dirty solution in compiler exception handling
1136   _null_ptr_exception.init_if_empty(vmSymbols::java_lang_NullPointerException(), CHECK_false);
1137   _arithmetic_exception.init_if_empty(vmSymbols::java_lang_ArithmeticException(), CHECK_false);
1138   _array_index_out_of_bounds_exception.init_if_empty(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), CHECK_false);
1139   _array_store_exception.init_if_empty(vmSymbols::java_lang_ArrayStoreException(), CHECK_false);
1140   _class_cast_exception.init_if_empty(vmSymbols::java_lang_ClassCastException(), CHECK_false);
1141   _preempted_exception.init_if_empty(vmSymbols::jdk_internal_vm_PreemptedException(), CHECK_false);
1142 
1143   // Virtual Machine Error for when we get into a situation we can't resolve
1144   Klass* k = vmClasses::InternalError_klass();
1145   bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
1146   if (!linked) {
1147      tty->print_cr("Unable to link/verify InternalError class");
1148      return false; // initialization failed
1149   }
1150   _internal_error.init_if_empty(vmSymbols::java_lang_InternalError(), CHECK_false);
1151 
1152   Handle msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
1153   java_lang_Throwable::set_message(Universe::arithmetic_exception_instance(), msg());
1154 
1155   // Setup preallocated StackOverflowError for use with class initialization failure
1156   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_StackOverflowError(), true, CHECK_false);
1157   instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1158   Universe::_class_init_stack_overflow_error = OopHandle(Universe::vm_global(), instance);
1159 
1160   Universe::initialize_known_methods(THREAD);
1161 
< prev index next >