< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

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

 240 
 241 objArrayOop Universe::the_empty_class_array ()  {
 242   return (objArrayOop)_the_empty_class_array.resolve();
 243 }
 244 
 245 oop Universe::main_thread_group()                 { return _main_thread_group.resolve(); }
 246 void Universe::set_main_thread_group(oop group)   { _main_thread_group = OopHandle(vm_global(), group); }
 247 
 248 oop Universe::system_thread_group()               { return _system_thread_group.resolve(); }
 249 void Universe::set_system_thread_group(oop group) { _system_thread_group = OopHandle(vm_global(), group); }
 250 
 251 oop Universe::the_null_string()                   { return _the_null_string.resolve(); }
 252 oop Universe::the_min_jint_string()               { return _the_min_jint_string.resolve(); }
 253 
 254 oop Universe::null_ptr_exception_instance()       { return _null_ptr_exception.instance(); }
 255 oop Universe::arithmetic_exception_instance()     { return _arithmetic_exception.instance(); }
 256 oop Universe::internal_error_instance()           { return _internal_error.instance(); }
 257 oop Universe::array_index_out_of_bounds_exception_instance() { return _array_index_out_of_bounds_exception.instance(); }
 258 oop Universe::array_store_exception_instance()    { return _array_store_exception.instance(); }
 259 oop Universe::class_cast_exception_instance()     { return _class_cast_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 }
 320 
 321 void Universe::load_archived_object_instances() {
 322   if (ArchiveHeapLoader::is_in_use()) {
 323     for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 324       int index = _archived_basic_type_mirror_indices[i];
 325       if (!is_reference_type((BasicType)i) && index >= 0) {
 326         oop mirror_oop = HeapShared::get_root(index);
 327         assert(mirror_oop != nullptr, "must be");
 328         _basic_type_mirrors[i] = OopHandle(vm_global(), mirror_oop);
 329       }
 330     }
 331 
 332     _null_ptr_exception.load_from_cds();
 333     _arithmetic_exception.load_from_cds();
 334     _internal_error.load_from_cds();
 335     _array_index_out_of_bounds_exception.load_from_cds();
 336     _array_store_exception.load_from_cds();
 337     _class_cast_exception.load_from_cds();

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

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

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

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

 220   void load_from_cds() {
 221     if (_archived_root_index >= 0) {
 222       oop obj = HeapShared::get_root(_archived_root_index);
 223       assert(obj != nullptr, "must be");
 224       _instance = OopHandle(Universe::vm_global(), obj);
 225     }
 226   }
 227 
 228   void serialize(SerializeClosure *f) {
 229     f->do_int(&_archived_root_index);
 230   }
 231 #endif
 232 };
 233 
 234 static BuiltinException _null_ptr_exception;
 235 static BuiltinException _arithmetic_exception;
 236 static BuiltinException _internal_error;
 237 static BuiltinException _array_index_out_of_bounds_exception;
 238 static BuiltinException _array_store_exception;
 239 static BuiltinException _class_cast_exception;
 240 static BuiltinException _preempted_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 oop Universe::preempted_exception_instance()      { return _preempted_exception.instance(); }
 262 
 263 oop Universe::the_null_sentinel()                 { return _the_null_sentinel.resolve(); }
 264 
 265 oop Universe::int_mirror()                        { return check_mirror(_basic_type_mirrors[T_INT].resolve()); }
 266 oop Universe::float_mirror()                      { return check_mirror(_basic_type_mirrors[T_FLOAT].resolve()); }
 267 oop Universe::double_mirror()                     { return check_mirror(_basic_type_mirrors[T_DOUBLE].resolve()); }
 268 oop Universe::byte_mirror()                       { return check_mirror(_basic_type_mirrors[T_BYTE].resolve()); }
 269 oop Universe::bool_mirror()                       { return check_mirror(_basic_type_mirrors[T_BOOLEAN].resolve()); }
 270 oop Universe::char_mirror()                       { return check_mirror(_basic_type_mirrors[T_CHAR].resolve()); }
 271 oop Universe::long_mirror()                       { return check_mirror(_basic_type_mirrors[T_LONG].resolve()); }
 272 oop Universe::short_mirror()                      { return check_mirror(_basic_type_mirrors[T_SHORT].resolve()); }
 273 oop Universe::void_mirror()                       { return check_mirror(_basic_type_mirrors[T_VOID].resolve()); }
 274 
 275 oop Universe::java_mirror(BasicType t) {
 276   assert((uint)t < T_VOID+1, "range check");
 277   assert(!is_reference_type(t), "sanity");
 278   return check_mirror(_basic_type_mirrors[t].resolve());
 279 }
 280 
 281 void Universe::basic_type_classes_do(KlassClosure *closure) {

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

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