< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page
rev 52361 : [mq]: webrev.2.incr


  88 Klass* Universe::_objectArrayKlassObj                 = NULL;
  89 oop Universe::_int_mirror                             = NULL;
  90 oop Universe::_float_mirror                           = NULL;
  91 oop Universe::_double_mirror                          = NULL;
  92 oop Universe::_byte_mirror                            = NULL;
  93 oop Universe::_bool_mirror                            = NULL;
  94 oop Universe::_char_mirror                            = NULL;
  95 oop Universe::_long_mirror                            = NULL;
  96 oop Universe::_short_mirror                           = NULL;
  97 oop Universe::_void_mirror                            = NULL;
  98 oop Universe::_mirrors[T_VOID+1]                      = { NULL /*, NULL...*/ };
  99 oop Universe::_main_thread_group                      = NULL;
 100 oop Universe::_system_thread_group                    = NULL;
 101 objArrayOop Universe::_the_empty_class_klass_array    = NULL;
 102 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
 103 oop Universe::_the_null_sentinel                      = NULL;
 104 oop Universe::_the_null_string                        = NULL;
 105 oop Universe::_the_min_jint_string                   = NULL;
 106 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
 107 LatestMethodCache* Universe::_loader_addClass_cache    = NULL;
 108 LatestMethodCache* Universe::_pd_implies_cache         = NULL;
 109 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
 110 LatestMethodCache* Universe::_do_stack_walk_cache     = NULL;
 111 oop Universe::_out_of_memory_error_java_heap          = NULL;
 112 oop Universe::_out_of_memory_error_metaspace          = NULL;
 113 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_gc_overhead_limit  = NULL;
 116 oop Universe::_out_of_memory_error_realloc_objects    = NULL;
 117 oop Universe::_out_of_memory_error_retry              = NULL;
 118 oop Universe::_delayed_stack_overflow_error_message   = NULL;
 119 objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
 120 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 121 bool Universe::_verify_in_progress                    = false;
 122 long Universe::verify_flags                           = Universe::Verify_All;
 123 oop Universe::_null_ptr_exception_instance            = NULL;
 124 oop Universe::_arithmetic_exception_instance          = NULL;
 125 oop Universe::_virtual_machine_error_instance         = NULL;
 126 oop Universe::_vm_exception                           = NULL;
 127 oop Universe::_reference_pending_list                 = NULL;
 128 


 212 
 213 void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
 214   it->push(&_klass);
 215 }
 216 
 217 void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
 218   for (int i = 0; i < T_LONG+1; i++) {
 219     it->push(&_typeArrayKlassObjs[i]);
 220   }
 221   it->push(&_objectArrayKlassObj);
 222 
 223   it->push(&_the_empty_int_array);
 224   it->push(&_the_empty_short_array);
 225   it->push(&_the_empty_klass_array);
 226   it->push(&_the_empty_instance_klass_array);
 227   it->push(&_the_empty_method_array);
 228   it->push(&_the_array_interfaces_array);
 229 
 230   _finalizer_register_cache->metaspace_pointers_do(it);
 231   _loader_addClass_cache->metaspace_pointers_do(it);
 232   _pd_implies_cache->metaspace_pointers_do(it);
 233   _throw_illegal_access_error_cache->metaspace_pointers_do(it);
 234   _do_stack_walk_cache->metaspace_pointers_do(it);
 235 }
 236 
 237 // Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
 238 void Universe::serialize(SerializeClosure* f) {
 239 
 240   for (int i = 0; i < T_LONG+1; i++) {
 241     f->do_ptr((void**)&_typeArrayKlassObjs[i]);
 242   }
 243 
 244   f->do_ptr((void**)&_objectArrayKlassObj);
 245 #if INCLUDE_CDS_JAVA_HEAP
 246 #ifdef ASSERT
 247   if (DumpSharedSpaces && !HeapShared::is_heap_object_archiving_allowed()) {
 248     assert(_int_mirror == NULL    && _float_mirror == NULL &&
 249            _double_mirror == NULL && _byte_mirror == NULL  &&
 250            _bool_mirror == NULL   && _char_mirror == NULL  &&
 251            _long_mirror == NULL   && _short_mirror == NULL &&
 252            _void_mirror == NULL, "mirrors should be NULL");


 254 #endif
 255   f->do_oop(&_int_mirror);
 256   f->do_oop(&_float_mirror);
 257   f->do_oop(&_double_mirror);
 258   f->do_oop(&_byte_mirror);
 259   f->do_oop(&_bool_mirror);
 260   f->do_oop(&_char_mirror);
 261   f->do_oop(&_long_mirror);
 262   f->do_oop(&_short_mirror);
 263   f->do_oop(&_void_mirror);
 264 #endif
 265 
 266   f->do_ptr((void**)&_the_array_interfaces_array);
 267   f->do_ptr((void**)&_the_empty_int_array);
 268   f->do_ptr((void**)&_the_empty_short_array);
 269   f->do_ptr((void**)&_the_empty_method_array);
 270   f->do_ptr((void**)&_the_empty_klass_array);
 271   f->do_ptr((void**)&_the_empty_instance_klass_array);
 272   _finalizer_register_cache->serialize(f);
 273   _loader_addClass_cache->serialize(f);
 274   _pd_implies_cache->serialize(f);
 275   _throw_illegal_access_error_cache->serialize(f);
 276   _do_stack_walk_cache->serialize(f);
 277 }
 278 
 279 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 280   if (size < alignment || size % alignment != 0) {
 281     vm_exit_during_initialization(
 282       err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment));
 283   }
 284 }
 285 
 286 void initialize_basic_type_klass(Klass* k, TRAPS) {
 287   Klass* ok = SystemDictionary::Object_klass();
 288 #if INCLUDE_CDS
 289   if (UseSharedSpaces) {
 290     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 291     assert(k->super() == ok, "u3");
 292     k->restore_unshareable_info(loader_data, Handle(), CHECK);
 293   } else
 294 #endif


 663 
 664   // Initialize performance counters for metaspaces
 665   MetaspaceCounters::initialize_performance_counters();
 666   CompressedClassSpaceCounters::initialize_performance_counters();
 667 
 668   AOTLoader::universe_init();
 669 
 670   // Checks 'AfterMemoryInit' constraints.
 671   if (!JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterMemoryInit)) {
 672     return JNI_EINVAL;
 673   }
 674 
 675   // Create memory for metadata.  Must be after initializing heap for
 676   // DumpSharedSpaces.
 677   ClassLoaderData::init_null_class_loader_data();
 678 
 679   // We have a heap so create the Method* caches before
 680   // Metaspace::initialize_shared_spaces() tries to populate them.
 681   Universe::_finalizer_register_cache = new LatestMethodCache();
 682   Universe::_loader_addClass_cache    = new LatestMethodCache();
 683   Universe::_pd_implies_cache         = new LatestMethodCache();
 684   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 685   Universe::_do_stack_walk_cache = new LatestMethodCache();
 686 
 687 #if INCLUDE_CDS
 688   if (UseSharedSpaces) {
 689     // Read the data structures supporting the shared spaces (shared
 690     // system dictionary, symbol table, etc.).  After that, access to
 691     // the file (other than the mapped regions) is no longer needed, and
 692     // the file is closed. Closing the file does not affect the
 693     // currently mapped regions.
 694     MetaspaceShared::initialize_shared_spaces();
 695     StringTable::create_table();
 696   } else
 697 #endif
 698   {
 699     SymbolTable::create_table();
 700     StringTable::create_table();
 701 
 702 #if INCLUDE_CDS
 703     if (DumpSharedSpaces) {


 916   method_cache->init(ik, m);
 917 }
 918 
 919 void Universe::initialize_known_methods(TRAPS) {
 920   // Set up static method for registering finalizers
 921   initialize_known_method(_finalizer_register_cache,
 922                           SystemDictionary::Finalizer_klass(),
 923                           "register",
 924                           vmSymbols::object_void_signature(), true, CHECK);
 925 
 926   initialize_known_method(_throw_illegal_access_error_cache,
 927                           SystemDictionary::internal_Unsafe_klass(),
 928                           "throwIllegalAccessError",
 929                           vmSymbols::void_method_signature(), true, CHECK);
 930 
 931   // Set up method for registering loaded classes in class loader vector
 932   initialize_known_method(_loader_addClass_cache,
 933                           SystemDictionary::ClassLoader_klass(),
 934                           "addClass",
 935                           vmSymbols::class_void_signature(), false, CHECK);
 936 
 937   // Set up method for checking protection domain
 938   initialize_known_method(_pd_implies_cache,
 939                           SystemDictionary::ProtectionDomain_klass(),
 940                           "impliesCreateAccessControlContext",
 941                           vmSymbols::void_boolean_signature(), false, CHECK);
 942 
 943   // Set up method for stack walking
 944   initialize_known_method(_do_stack_walk_cache,
 945                           SystemDictionary::AbstractStackWalker_klass(),
 946                           "doStackWalk",
 947                           vmSymbols::doStackWalk_signature(), false, CHECK);
 948 }
 949 
 950 void universe2_init() {
 951   EXCEPTION_MARK;
 952   Universe::genesis(CATCH);
 953 }
 954 
 955 // Set after initialization of the module runtime, call_initModuleRuntime
 956 void universe_post_module_init() {
 957   Universe::_module_initialized = true;
 958 }
 959 
 960 bool universe_post_init() {
 961   assert(!is_init_completed(), "Error: initialization not yet completed!");




  88 Klass* Universe::_objectArrayKlassObj                 = NULL;
  89 oop Universe::_int_mirror                             = NULL;
  90 oop Universe::_float_mirror                           = NULL;
  91 oop Universe::_double_mirror                          = NULL;
  92 oop Universe::_byte_mirror                            = NULL;
  93 oop Universe::_bool_mirror                            = NULL;
  94 oop Universe::_char_mirror                            = NULL;
  95 oop Universe::_long_mirror                            = NULL;
  96 oop Universe::_short_mirror                           = NULL;
  97 oop Universe::_void_mirror                            = NULL;
  98 oop Universe::_mirrors[T_VOID+1]                      = { NULL /*, NULL...*/ };
  99 oop Universe::_main_thread_group                      = NULL;
 100 oop Universe::_system_thread_group                    = NULL;
 101 objArrayOop Universe::_the_empty_class_klass_array    = NULL;
 102 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
 103 oop Universe::_the_null_sentinel                      = NULL;
 104 oop Universe::_the_null_string                        = NULL;
 105 oop Universe::_the_min_jint_string                   = NULL;
 106 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
 107 LatestMethodCache* Universe::_loader_addClass_cache    = NULL;

 108 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
 109 LatestMethodCache* Universe::_do_stack_walk_cache     = NULL;
 110 oop Universe::_out_of_memory_error_java_heap          = NULL;
 111 oop Universe::_out_of_memory_error_metaspace          = NULL;
 112 oop Universe::_out_of_memory_error_class_metaspace    = NULL;
 113 oop Universe::_out_of_memory_error_array_size         = NULL;
 114 oop Universe::_out_of_memory_error_gc_overhead_limit  = NULL;
 115 oop Universe::_out_of_memory_error_realloc_objects    = NULL;
 116 oop Universe::_out_of_memory_error_retry              = NULL;
 117 oop Universe::_delayed_stack_overflow_error_message   = NULL;
 118 objArrayOop Universe::_preallocated_out_of_memory_error_array = NULL;
 119 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 120 bool Universe::_verify_in_progress                    = false;
 121 long Universe::verify_flags                           = Universe::Verify_All;
 122 oop Universe::_null_ptr_exception_instance            = NULL;
 123 oop Universe::_arithmetic_exception_instance          = NULL;
 124 oop Universe::_virtual_machine_error_instance         = NULL;
 125 oop Universe::_vm_exception                           = NULL;
 126 oop Universe::_reference_pending_list                 = NULL;
 127 


 211 
 212 void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
 213   it->push(&_klass);
 214 }
 215 
 216 void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
 217   for (int i = 0; i < T_LONG+1; i++) {
 218     it->push(&_typeArrayKlassObjs[i]);
 219   }
 220   it->push(&_objectArrayKlassObj);
 221 
 222   it->push(&_the_empty_int_array);
 223   it->push(&_the_empty_short_array);
 224   it->push(&_the_empty_klass_array);
 225   it->push(&_the_empty_instance_klass_array);
 226   it->push(&_the_empty_method_array);
 227   it->push(&_the_array_interfaces_array);
 228 
 229   _finalizer_register_cache->metaspace_pointers_do(it);
 230   _loader_addClass_cache->metaspace_pointers_do(it);

 231   _throw_illegal_access_error_cache->metaspace_pointers_do(it);
 232   _do_stack_walk_cache->metaspace_pointers_do(it);
 233 }
 234 
 235 // Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
 236 void Universe::serialize(SerializeClosure* f) {
 237 
 238   for (int i = 0; i < T_LONG+1; i++) {
 239     f->do_ptr((void**)&_typeArrayKlassObjs[i]);
 240   }
 241 
 242   f->do_ptr((void**)&_objectArrayKlassObj);
 243 #if INCLUDE_CDS_JAVA_HEAP
 244 #ifdef ASSERT
 245   if (DumpSharedSpaces && !HeapShared::is_heap_object_archiving_allowed()) {
 246     assert(_int_mirror == NULL    && _float_mirror == NULL &&
 247            _double_mirror == NULL && _byte_mirror == NULL  &&
 248            _bool_mirror == NULL   && _char_mirror == NULL  &&
 249            _long_mirror == NULL   && _short_mirror == NULL &&
 250            _void_mirror == NULL, "mirrors should be NULL");


 252 #endif
 253   f->do_oop(&_int_mirror);
 254   f->do_oop(&_float_mirror);
 255   f->do_oop(&_double_mirror);
 256   f->do_oop(&_byte_mirror);
 257   f->do_oop(&_bool_mirror);
 258   f->do_oop(&_char_mirror);
 259   f->do_oop(&_long_mirror);
 260   f->do_oop(&_short_mirror);
 261   f->do_oop(&_void_mirror);
 262 #endif
 263 
 264   f->do_ptr((void**)&_the_array_interfaces_array);
 265   f->do_ptr((void**)&_the_empty_int_array);
 266   f->do_ptr((void**)&_the_empty_short_array);
 267   f->do_ptr((void**)&_the_empty_method_array);
 268   f->do_ptr((void**)&_the_empty_klass_array);
 269   f->do_ptr((void**)&_the_empty_instance_klass_array);
 270   _finalizer_register_cache->serialize(f);
 271   _loader_addClass_cache->serialize(f);

 272   _throw_illegal_access_error_cache->serialize(f);
 273   _do_stack_walk_cache->serialize(f);
 274 }
 275 
 276 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 277   if (size < alignment || size % alignment != 0) {
 278     vm_exit_during_initialization(
 279       err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment));
 280   }
 281 }
 282 
 283 void initialize_basic_type_klass(Klass* k, TRAPS) {
 284   Klass* ok = SystemDictionary::Object_klass();
 285 #if INCLUDE_CDS
 286   if (UseSharedSpaces) {
 287     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 288     assert(k->super() == ok, "u3");
 289     k->restore_unshareable_info(loader_data, Handle(), CHECK);
 290   } else
 291 #endif


 660 
 661   // Initialize performance counters for metaspaces
 662   MetaspaceCounters::initialize_performance_counters();
 663   CompressedClassSpaceCounters::initialize_performance_counters();
 664 
 665   AOTLoader::universe_init();
 666 
 667   // Checks 'AfterMemoryInit' constraints.
 668   if (!JVMFlagConstraintList::check_constraints(JVMFlagConstraint::AfterMemoryInit)) {
 669     return JNI_EINVAL;
 670   }
 671 
 672   // Create memory for metadata.  Must be after initializing heap for
 673   // DumpSharedSpaces.
 674   ClassLoaderData::init_null_class_loader_data();
 675 
 676   // We have a heap so create the Method* caches before
 677   // Metaspace::initialize_shared_spaces() tries to populate them.
 678   Universe::_finalizer_register_cache = new LatestMethodCache();
 679   Universe::_loader_addClass_cache    = new LatestMethodCache();

 680   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 681   Universe::_do_stack_walk_cache = new LatestMethodCache();
 682 
 683 #if INCLUDE_CDS
 684   if (UseSharedSpaces) {
 685     // Read the data structures supporting the shared spaces (shared
 686     // system dictionary, symbol table, etc.).  After that, access to
 687     // the file (other than the mapped regions) is no longer needed, and
 688     // the file is closed. Closing the file does not affect the
 689     // currently mapped regions.
 690     MetaspaceShared::initialize_shared_spaces();
 691     StringTable::create_table();
 692   } else
 693 #endif
 694   {
 695     SymbolTable::create_table();
 696     StringTable::create_table();
 697 
 698 #if INCLUDE_CDS
 699     if (DumpSharedSpaces) {


 912   method_cache->init(ik, m);
 913 }
 914 
 915 void Universe::initialize_known_methods(TRAPS) {
 916   // Set up static method for registering finalizers
 917   initialize_known_method(_finalizer_register_cache,
 918                           SystemDictionary::Finalizer_klass(),
 919                           "register",
 920                           vmSymbols::object_void_signature(), true, CHECK);
 921 
 922   initialize_known_method(_throw_illegal_access_error_cache,
 923                           SystemDictionary::internal_Unsafe_klass(),
 924                           "throwIllegalAccessError",
 925                           vmSymbols::void_method_signature(), true, CHECK);
 926 
 927   // Set up method for registering loaded classes in class loader vector
 928   initialize_known_method(_loader_addClass_cache,
 929                           SystemDictionary::ClassLoader_klass(),
 930                           "addClass",
 931                           vmSymbols::class_void_signature(), false, CHECK);






 932 
 933   // Set up method for stack walking
 934   initialize_known_method(_do_stack_walk_cache,
 935                           SystemDictionary::AbstractStackWalker_klass(),
 936                           "doStackWalk",
 937                           vmSymbols::doStackWalk_signature(), false, CHECK);
 938 }
 939 
 940 void universe2_init() {
 941   EXCEPTION_MARK;
 942   Universe::genesis(CATCH);
 943 }
 944 
 945 // Set after initialization of the module runtime, call_initModuleRuntime
 946 void universe_post_module_init() {
 947   Universe::_module_initialized = true;
 948 }
 949 
 950 bool universe_post_init() {
 951   assert(!is_init_completed(), "Error: initialization not yet completed!");


< prev index next >