< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

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

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

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

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

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

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

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

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

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

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

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

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