< prev index next >

src/share/vm/memory/universe.cpp

Print this page




1047   // (this is currently used for a cheap & dirty solution in compiler exception handling)
1048   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false);
1049   Universe::_null_ptr_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1050   // Setup preallocated ArithmeticException
1051   // (this is currently used for a cheap & dirty solution in compiler exception handling)
1052   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ArithmeticException(), true, CHECK_false);
1053   Universe::_arithmetic_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1054   // Virtual Machine Error for when we get into a situation we can't resolve
1055   k = SystemDictionary::resolve_or_fail(
1056     vmSymbols::java_lang_VirtualMachineError(), true, CHECK_false);
1057   bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
1058   if (!linked) {
1059      tty->print_cr("Unable to link/verify VirtualMachineError class");
1060      return false; // initialization failed
1061   }
1062   Universe::_virtual_machine_error_instance =
1063     InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1064 
1065   Universe::_vm_exception = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1066 
1067   if (!DumpSharedSpaces) {
1068     // These are the only Java fields that are currently set during shared space dumping.
1069     // We prefer to not handle this generally, so we always reinitialize these detail messages.
1070     Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
1071     java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
1072 
1073     msg = java_lang_String::create_from_str("Metaspace", CHECK_false);
1074     java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
1075     msg = java_lang_String::create_from_str("Compressed class space", CHECK_false);
1076     java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
1077 
1078     msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
1079     java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
1080 
1081     msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
1082     java_lang_Throwable::set_message(Universe::_out_of_memory_error_gc_overhead_limit, msg());
1083 
1084     msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK_false);
1085     java_lang_Throwable::set_message(Universe::_out_of_memory_error_realloc_objects, msg());
1086 
1087     msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
1088     java_lang_Throwable::set_message(Universe::_arithmetic_exception_instance, msg());
1089 
1090     // Setup the array of errors that have preallocated backtrace
1091     k = Universe::_out_of_memory_error_java_heap->klass();
1092     assert(k->name() == vmSymbols::java_lang_OutOfMemoryError(), "should be out of memory error");
1093     ik = InstanceKlass::cast(k);
1094 
1095     int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0;
1096     Universe::_preallocated_out_of_memory_error_array = oopFactory::new_objArray(ik, len, CHECK_false);
1097     for (int i=0; i<len; i++) {
1098       oop err = ik->allocate_instance(CHECK_false);
1099       Handle err_h = Handle(THREAD, err);
1100       java_lang_Throwable::allocate_backtrace(err_h, CHECK_false);
1101       Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h());
1102     }
1103     Universe::_preallocated_out_of_memory_error_avail_count = (jint)len;
1104   }
1105 
1106   Universe::initialize_known_methods(CHECK_false);
1107 
1108   // This needs to be done before the first scavenge/gc, since
1109   // it's an input to soft ref clearing policy.
1110   {
1111     MutexLocker x(Heap_lock);
1112     Universe::update_heap_info_at_gc();
1113   }
1114 
1115   // ("weak") refs processing infrastructure initialization
1116   Universe::heap()->post_initialize();
1117 
1118   // Initialize performance counters for metaspaces
1119   MetaspaceCounters::initialize_performance_counters();
1120   CompressedClassSpaceCounters::initialize_performance_counters();
1121 
1122   MemoryService::add_metaspace_memory_pools();
1123 
1124   MemoryService::set_universe_heap(Universe::heap());




1047   // (this is currently used for a cheap & dirty solution in compiler exception handling)
1048   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false);
1049   Universe::_null_ptr_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1050   // Setup preallocated ArithmeticException
1051   // (this is currently used for a cheap & dirty solution in compiler exception handling)
1052   k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ArithmeticException(), true, CHECK_false);
1053   Universe::_arithmetic_exception_instance = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1054   // Virtual Machine Error for when we get into a situation we can't resolve
1055   k = SystemDictionary::resolve_or_fail(
1056     vmSymbols::java_lang_VirtualMachineError(), true, CHECK_false);
1057   bool linked = InstanceKlass::cast(k)->link_class_or_fail(CHECK_false);
1058   if (!linked) {
1059      tty->print_cr("Unable to link/verify VirtualMachineError class");
1060      return false; // initialization failed
1061   }
1062   Universe::_virtual_machine_error_instance =
1063     InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1064 
1065   Universe::_vm_exception = InstanceKlass::cast(k)->allocate_instance(CHECK_false);
1066 



1067   Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
1068   java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
1069 
1070   msg = java_lang_String::create_from_str("Metaspace", CHECK_false);
1071   java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
1072   msg = java_lang_String::create_from_str("Compressed class space", CHECK_false);
1073   java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
1074 
1075   msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
1076   java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
1077 
1078   msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
1079   java_lang_Throwable::set_message(Universe::_out_of_memory_error_gc_overhead_limit, msg());
1080 
1081   msg = java_lang_String::create_from_str("Java heap space: failed reallocation of scalar replaced objects", CHECK_false);
1082   java_lang_Throwable::set_message(Universe::_out_of_memory_error_realloc_objects, msg());
1083 
1084   msg = java_lang_String::create_from_str("/ by zero", CHECK_false);
1085   java_lang_Throwable::set_message(Universe::_arithmetic_exception_instance, msg());
1086 
1087   // Setup the array of errors that have preallocated backtrace
1088   k = Universe::_out_of_memory_error_java_heap->klass();
1089   assert(k->name() == vmSymbols::java_lang_OutOfMemoryError(), "should be out of memory error");
1090   ik = InstanceKlass::cast(k);
1091 
1092   int len = (StackTraceInThrowable) ? (int)PreallocatedOutOfMemoryErrorCount : 0;
1093   Universe::_preallocated_out_of_memory_error_array = oopFactory::new_objArray(ik, len, CHECK_false);
1094   for (int i=0; i<len; i++) {
1095     oop err = ik->allocate_instance(CHECK_false);
1096     Handle err_h = Handle(THREAD, err);
1097     java_lang_Throwable::allocate_backtrace(err_h, CHECK_false);
1098     Universe::preallocated_out_of_memory_errors()->obj_at_put(i, err_h());
1099   }
1100   Universe::_preallocated_out_of_memory_error_avail_count = (jint)len;

1101 
1102   Universe::initialize_known_methods(CHECK_false);
1103 
1104   // This needs to be done before the first scavenge/gc, since
1105   // it's an input to soft ref clearing policy.
1106   {
1107     MutexLocker x(Heap_lock);
1108     Universe::update_heap_info_at_gc();
1109   }
1110 
1111   // ("weak") refs processing infrastructure initialization
1112   Universe::heap()->post_initialize();
1113 
1114   // Initialize performance counters for metaspaces
1115   MetaspaceCounters::initialize_performance_counters();
1116   CompressedClassSpaceCounters::initialize_performance_counters();
1117 
1118   MemoryService::add_metaspace_memory_pools();
1119 
1120   MemoryService::set_universe_heap(Universe::heap());


< prev index next >