comparison src/share/vm/memory/universe.cpp @ 11173:6b0fd0964b87

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 31 Jul 2013 11:00:54 +0200
parents 836a62f43af9 71180a6e5080
children 3cce976666d9
comparison
equal deleted inserted replaced
10912:4ea54634f03e 11173:6b0fd0964b87
50 #include "oops/instanceMirrorKlass.hpp" 50 #include "oops/instanceMirrorKlass.hpp"
51 #include "oops/instanceRefKlass.hpp" 51 #include "oops/instanceRefKlass.hpp"
52 #include "oops/oop.inline.hpp" 52 #include "oops/oop.inline.hpp"
53 #include "oops/typeArrayKlass.hpp" 53 #include "oops/typeArrayKlass.hpp"
54 #include "prims/jvmtiRedefineClassesTrace.hpp" 54 #include "prims/jvmtiRedefineClassesTrace.hpp"
55 #include "runtime/aprofiler.hpp"
56 #include "runtime/arguments.hpp" 55 #include "runtime/arguments.hpp"
57 #include "runtime/deoptimization.hpp" 56 #include "runtime/deoptimization.hpp"
58 #include "runtime/fprofiler.hpp" 57 #include "runtime/fprofiler.hpp"
59 #include "runtime/handles.inline.hpp" 58 #include "runtime/handles.inline.hpp"
60 #include "runtime/init.hpp" 59 #include "runtime/init.hpp"
106 Array<Klass*>* Universe::_the_array_interfaces_array = NULL; 105 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
107 oop Universe::_the_null_string = NULL; 106 oop Universe::_the_null_string = NULL;
108 oop Universe::_the_min_jint_string = NULL; 107 oop Universe::_the_min_jint_string = NULL;
109 LatestMethodOopCache* Universe::_finalizer_register_cache = NULL; 108 LatestMethodOopCache* Universe::_finalizer_register_cache = NULL;
110 LatestMethodOopCache* Universe::_loader_addClass_cache = NULL; 109 LatestMethodOopCache* Universe::_loader_addClass_cache = NULL;
110 LatestMethodOopCache* Universe::_pd_implies_cache = NULL;
111 ActiveMethodOopsCache* Universe::_reflect_invoke_cache = NULL; 111 ActiveMethodOopsCache* Universe::_reflect_invoke_cache = NULL;
112 oop Universe::_out_of_memory_error_java_heap = NULL; 112 oop Universe::_out_of_memory_error_java_heap = NULL;
113 oop Universe::_out_of_memory_error_perm_gen = NULL; 113 oop Universe::_out_of_memory_error_metaspace = NULL;
114 oop Universe::_out_of_memory_error_class_metaspace = NULL;
114 oop Universe::_out_of_memory_error_array_size = NULL; 115 oop Universe::_out_of_memory_error_array_size = NULL;
115 oop Universe::_out_of_memory_error_gc_overhead_limit = NULL; 116 oop Universe::_out_of_memory_error_gc_overhead_limit = NULL;
116 objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL; 117 objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
117 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0; 118 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
118 bool Universe::_verify_in_progress = false; 119 bool Universe::_verify_in_progress = false;
177 178
178 f->do_oop((oop*)&_the_empty_class_klass_array); 179 f->do_oop((oop*)&_the_empty_class_klass_array);
179 f->do_oop((oop*)&_the_null_string); 180 f->do_oop((oop*)&_the_null_string);
180 f->do_oop((oop*)&_the_min_jint_string); 181 f->do_oop((oop*)&_the_min_jint_string);
181 f->do_oop((oop*)&_out_of_memory_error_java_heap); 182 f->do_oop((oop*)&_out_of_memory_error_java_heap);
182 f->do_oop((oop*)&_out_of_memory_error_perm_gen); 183 f->do_oop((oop*)&_out_of_memory_error_metaspace);
184 f->do_oop((oop*)&_out_of_memory_error_class_metaspace);
183 f->do_oop((oop*)&_out_of_memory_error_array_size); 185 f->do_oop((oop*)&_out_of_memory_error_array_size);
184 f->do_oop((oop*)&_out_of_memory_error_gc_overhead_limit); 186 f->do_oop((oop*)&_out_of_memory_error_gc_overhead_limit);
185 f->do_oop((oop*)&_preallocated_out_of_memory_error_array); 187 f->do_oop((oop*)&_preallocated_out_of_memory_error_array);
186 f->do_oop((oop*)&_null_ptr_exception_instance); 188 f->do_oop((oop*)&_null_ptr_exception_instance);
187 f->do_oop((oop*)&_arithmetic_exception_instance); 189 f->do_oop((oop*)&_arithmetic_exception_instance);
222 f->do_ptr((void**)&_the_empty_method_array); 224 f->do_ptr((void**)&_the_empty_method_array);
223 f->do_ptr((void**)&_the_empty_klass_array); 225 f->do_ptr((void**)&_the_empty_klass_array);
224 _finalizer_register_cache->serialize(f); 226 _finalizer_register_cache->serialize(f);
225 _loader_addClass_cache->serialize(f); 227 _loader_addClass_cache->serialize(f);
226 _reflect_invoke_cache->serialize(f); 228 _reflect_invoke_cache->serialize(f);
229 _pd_implies_cache->serialize(f);
227 } 230 }
228 231
229 void Universe::check_alignment(uintx size, uintx alignment, const char* name) { 232 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
230 if (size < alignment || size % alignment != 0) { 233 if (size < alignment || size % alignment != 0) {
231 vm_exit_during_initialization( 234 vm_exit_during_initialization(
527 Klass* ko = k_h(); 530 Klass* ko = k_h();
528 klassVtable* vt = ko->vtable(); 531 klassVtable* vt = ko->vtable();
529 if (vt) vt->initialize_vtable(false, CHECK); 532 if (vt) vt->initialize_vtable(false, CHECK);
530 if (ko->oop_is_instance()) { 533 if (ko->oop_is_instance()) {
531 InstanceKlass* ik = (InstanceKlass*)ko; 534 InstanceKlass* ik = (InstanceKlass*)ko;
532 for (KlassHandle s_h(THREAD, ik->subklass()); s_h() != NULL; s_h = (THREAD, s_h()->next_sibling())) { 535 for (KlassHandle s_h(THREAD, ik->subklass());
536 s_h() != NULL;
537 s_h = KlassHandle(THREAD, s_h()->next_sibling())) {
533 reinitialize_vtable_of(s_h, CHECK); 538 reinitialize_vtable_of(s_h, CHECK);
534 } 539 }
535 } 540 }
536 } 541 }
537 542
557 // backtrace. These errors are kept alive forever and may be "re-used" when all 562 // backtrace. These errors are kept alive forever and may be "re-used" when all
558 // preallocated errors with backtrace have been consumed. Also need to avoid 563 // preallocated errors with backtrace have been consumed. Also need to avoid
559 // a potential loop which could happen if an out of memory occurs when attempting 564 // a potential loop which could happen if an out of memory occurs when attempting
560 // to allocate the backtrace. 565 // to allocate the backtrace.
561 return ((throwable() != Universe::_out_of_memory_error_java_heap) && 566 return ((throwable() != Universe::_out_of_memory_error_java_heap) &&
562 (throwable() != Universe::_out_of_memory_error_perm_gen) && 567 (throwable() != Universe::_out_of_memory_error_metaspace) &&
568 (throwable() != Universe::_out_of_memory_error_class_metaspace) &&
563 (throwable() != Universe::_out_of_memory_error_array_size) && 569 (throwable() != Universe::_out_of_memory_error_array_size) &&
564 (throwable() != Universe::_out_of_memory_error_gc_overhead_limit)); 570 (throwable() != Universe::_out_of_memory_error_gc_overhead_limit));
565 } 571 }
566 572
567 573
643 649
644 // We have a heap so create the Method* caches before 650 // We have a heap so create the Method* caches before
645 // Metaspace::initialize_shared_spaces() tries to populate them. 651 // Metaspace::initialize_shared_spaces() tries to populate them.
646 Universe::_finalizer_register_cache = new LatestMethodOopCache(); 652 Universe::_finalizer_register_cache = new LatestMethodOopCache();
647 Universe::_loader_addClass_cache = new LatestMethodOopCache(); 653 Universe::_loader_addClass_cache = new LatestMethodOopCache();
654 Universe::_pd_implies_cache = new LatestMethodOopCache();
648 Universe::_reflect_invoke_cache = new ActiveMethodOopsCache(); 655 Universe::_reflect_invoke_cache = new ActiveMethodOopsCache();
649 656
650 if (UseSharedSpaces) { 657 if (UseSharedSpaces) {
651 // Read the data structures supporting the shared spaces (shared 658 // Read the data structures supporting the shared spaces (shared
652 // system dictionary, symbol table, etc.). After that, access to 659 // system dictionary, symbol table, etc.). After that, access to
1007 1014
1008 // Setup preallocated OutOfMemoryError errors 1015 // Setup preallocated OutOfMemoryError errors
1009 k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false); 1016 k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false);
1010 k_h = instanceKlassHandle(THREAD, k); 1017 k_h = instanceKlassHandle(THREAD, k);
1011 Universe::_out_of_memory_error_java_heap = k_h->allocate_instance(CHECK_false); 1018 Universe::_out_of_memory_error_java_heap = k_h->allocate_instance(CHECK_false);
1012 Universe::_out_of_memory_error_perm_gen = k_h->allocate_instance(CHECK_false); 1019 Universe::_out_of_memory_error_metaspace = k_h->allocate_instance(CHECK_false);
1020 Universe::_out_of_memory_error_class_metaspace = k_h->allocate_instance(CHECK_false);
1013 Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false); 1021 Universe::_out_of_memory_error_array_size = k_h->allocate_instance(CHECK_false);
1014 Universe::_out_of_memory_error_gc_overhead_limit = 1022 Universe::_out_of_memory_error_gc_overhead_limit =
1015 k_h->allocate_instance(CHECK_false); 1023 k_h->allocate_instance(CHECK_false);
1016 1024
1017 // Setup preallocated NullPointerException 1025 // Setup preallocated NullPointerException
1040 // We prefer to not handle this generally, so we always reinitialize these detail messages. 1048 // We prefer to not handle this generally, so we always reinitialize these detail messages.
1041 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false); 1049 Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false);
1042 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg()); 1050 java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg());
1043 1051
1044 msg = java_lang_String::create_from_str("Metadata space", CHECK_false); 1052 msg = java_lang_String::create_from_str("Metadata space", CHECK_false);
1045 java_lang_Throwable::set_message(Universe::_out_of_memory_error_perm_gen, msg()); 1053 java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg());
1054 msg = java_lang_String::create_from_str("Class Metadata space", CHECK_false);
1055 java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg());
1046 1056
1047 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false); 1057 msg = java_lang_String::create_from_str("Requested array size exceeds VM limit", CHECK_false);
1048 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg()); 1058 java_lang_Throwable::set_message(Universe::_out_of_memory_error_array_size, msg());
1049 1059
1050 msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false); 1060 msg = java_lang_String::create_from_str("GC overhead limit exceeded", CHECK_false);
1106 "java.lang.ClassLoader.addClass", false); 1116 "java.lang.ClassLoader.addClass", false);
1107 } 1117 }
1108 Universe::_loader_addClass_cache->init( 1118 Universe::_loader_addClass_cache->init(
1109 SystemDictionary::ClassLoader_klass(), m, CHECK_false); 1119 SystemDictionary::ClassLoader_klass(), m, CHECK_false);
1110 1120
1121 // Setup method for checking protection domain
1122 InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->link_class(CHECK_false);
1123 m = InstanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->
1124 find_method(vmSymbols::impliesCreateAccessControlContext_name(),
1125 vmSymbols::void_boolean_signature());
1126 // Allow NULL which should only happen with bootstrapping.
1127 if (m != NULL) {
1128 if (m->is_static()) {
1129 // NoSuchMethodException doesn't actually work because it tries to run the
1130 // <init> function before java_lang_Class is linked. Print error and exit.
1131 tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage");
1132 return false; // initialization failed
1133 }
1134 Universe::_pd_implies_cache->init(
1135 SystemDictionary::ProtectionDomain_klass(), m, CHECK_false);;
1136 }
1137
1111 // The folowing is initializing converter functions for serialization in 1138 // The folowing is initializing converter functions for serialization in
1112 // JVM.cpp. If we clean up the StrictMath code above we may want to find 1139 // JVM.cpp. If we clean up the StrictMath code above we may want to find
1113 // a better solution for this as well. 1140 // a better solution for this as well.
1114 initialize_converter_functions(); 1141 initialize_converter_functions();
1115 1142
1123 // ("weak") refs processing infrastructure initialization 1150 // ("weak") refs processing infrastructure initialization
1124 Universe::heap()->post_initialize(); 1151 Universe::heap()->post_initialize();
1125 1152
1126 // Initialize performance counters for metaspaces 1153 // Initialize performance counters for metaspaces
1127 MetaspaceCounters::initialize_performance_counters(); 1154 MetaspaceCounters::initialize_performance_counters();
1155 MemoryService::add_metaspace_memory_pools();
1128 1156
1129 GC_locker::unlock(); // allow gc after bootstrapping 1157 GC_locker::unlock(); // allow gc after bootstrapping
1130 1158
1131 MemoryService::set_universe_heap(Universe::_collectedHeap); 1159 MemoryService::set_universe_heap(Universe::_collectedHeap);
1132 return true; 1160 return true;
1523 return false; 1551 return false;
1524 } 1552 }
1525 1553
1526 1554
1527 Method* LatestMethodOopCache::get_Method() { 1555 Method* LatestMethodOopCache::get_Method() {
1556 if (klass() == NULL) return NULL;
1528 InstanceKlass* ik = InstanceKlass::cast(klass()); 1557 InstanceKlass* ik = InstanceKlass::cast(klass());
1529 Method* m = ik->method_with_idnum(method_idnum()); 1558 Method* m = ik->method_with_idnum(method_idnum());
1530 assert(m != NULL, "sanity check"); 1559 assert(m != NULL, "sanity check");
1531 return m; 1560 return m;
1532 } 1561 }