< prev index next >

src/hotspot/share/memory/universe.cpp

Print this page

 104                            _oom_retry,
 105                            _oom_count };
 106 
 107 OopHandle Universe::_out_of_memory_errors;
 108 OopHandle Universe::_delayed_stack_overflow_error_message;
 109 OopHandle Universe::_preallocated_out_of_memory_error_array;
 110 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 111 
 112 OopHandle Universe::_null_ptr_exception_instance;
 113 OopHandle Universe::_arithmetic_exception_instance;
 114 OopHandle Universe::_virtual_machine_error_instance;
 115 
 116 OopHandle Universe::_reference_pending_list;
 117 
 118 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
 119 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
 120 LatestMethodCache* Universe::_loader_addClass_cache    = NULL;
 121 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
 122 LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL;
 123 LatestMethodCache* Universe::_do_stack_walk_cache     = NULL;


 124 
 125 long Universe::verify_flags                           = Universe::Verify_All;
 126 
 127 Array<int>* Universe::_the_empty_int_array            = NULL;
 128 Array<u2>* Universe::_the_empty_short_array           = NULL;
 129 Array<Klass*>* Universe::_the_empty_klass_array     = NULL;
 130 Array<InstanceKlass*>* Universe::_the_empty_instance_klass_array  = NULL;


 131 Array<Method*>* Universe::_the_empty_method_array   = NULL;
 132 
 133 // These variables are guarded by FullGCALot_lock.
 134 debug_only(OopHandle Universe::_fullgc_alot_dummy_array;)
 135 debug_only(int Universe::_fullgc_alot_dummy_next = 0;)
 136 
 137 // Heap
 138 int             Universe::_verify_count = 0;
 139 
 140 // Oop verification (see MacroAssembler::verify_oop)
 141 uintptr_t       Universe::_verify_oop_mask = 0;
 142 uintptr_t       Universe::_verify_oop_bits = (uintptr_t) -1;
 143 
 144 int             Universe::_base_vtable_size = 0;
 145 bool            Universe::_bootstrapping = false;
 146 bool            Universe::_module_initialized = false;
 147 bool            Universe::_fully_initialized = false;
 148 
 149 OopStorage*     Universe::_vm_weak = NULL;
 150 OopStorage*     Universe::_vm_global = NULL;

 201     closure->do_klass(_typeArrayKlassObjs[i]);
 202   }
 203 }
 204 
 205 void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
 206   it->push(&_klass);
 207 }
 208 
 209 void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
 210   for (int i = 0; i < T_LONG+1; i++) {
 211     it->push(&_typeArrayKlassObjs[i]);
 212   }
 213   it->push(&_objectArrayKlassObj);
 214 
 215   it->push(&_the_empty_int_array);
 216   it->push(&_the_empty_short_array);
 217   it->push(&_the_empty_klass_array);
 218   it->push(&_the_empty_instance_klass_array);
 219   it->push(&_the_empty_method_array);
 220   it->push(&_the_array_interfaces_array);


 221 
 222   _finalizer_register_cache->metaspace_pointers_do(it);
 223   _loader_addClass_cache->metaspace_pointers_do(it);
 224   _throw_illegal_access_error_cache->metaspace_pointers_do(it);
 225   _throw_no_such_method_error_cache->metaspace_pointers_do(it);
 226   _do_stack_walk_cache->metaspace_pointers_do(it);


 227 }
 228 
 229 // Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
 230 void Universe::serialize(SerializeClosure* f) {
 231 
 232 #if INCLUDE_CDS_JAVA_HEAP
 233   {
 234     oop mirror_oop;
 235     for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 236       if (f->reading()) {
 237         f->do_oop(&mirror_oop); // read from archive
 238         assert(oopDesc::is_oop_or_null(mirror_oop), "is oop");
 239         // Only create an OopHandle for non-null mirrors
 240         if (mirror_oop != NULL) {
 241           _mirrors[i] = OopHandle(vm_global(), mirror_oop);
 242         }
 243       } else {
 244         if (HeapShared::can_write()) {
 245           mirror_oop = _mirrors[i].resolve();
 246         } else {

 249         f->do_oop(&mirror_oop); // write to archive
 250       }
 251       if (mirror_oop != NULL) { // may be null if archived heap is disabled
 252         java_lang_Class::update_archived_primitive_mirror_native_pointers(mirror_oop);
 253       }
 254     }
 255   }
 256 #endif
 257 
 258   for (int i = 0; i < T_LONG+1; i++) {
 259     f->do_ptr((void**)&_typeArrayKlassObjs[i]);
 260   }
 261 
 262   f->do_ptr((void**)&_objectArrayKlassObj);
 263   f->do_ptr((void**)&_the_array_interfaces_array);
 264   f->do_ptr((void**)&_the_empty_int_array);
 265   f->do_ptr((void**)&_the_empty_short_array);
 266   f->do_ptr((void**)&_the_empty_method_array);
 267   f->do_ptr((void**)&_the_empty_klass_array);
 268   f->do_ptr((void**)&_the_empty_instance_klass_array);


 269   _finalizer_register_cache->serialize(f);
 270   _loader_addClass_cache->serialize(f);
 271   _throw_illegal_access_error_cache->serialize(f);
 272   _throw_no_such_method_error_cache->serialize(f);
 273   _do_stack_walk_cache->serialize(f);


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

 303 void Universe::genesis(TRAPS) {
 304   ResourceMark rm(THREAD);
 305   HandleMark   hm(THREAD);
 306 
 307   { AutoModifyRestore<bool> temporarily(_bootstrapping, true);
 308 
 309     { MutexLocker mc(THREAD, Compile_lock);
 310 
 311       java_lang_Class::allocate_fixup_lists();
 312 
 313       // determine base vtable size; without that we cannot create the array klasses
 314       compute_base_vtable_size();
 315 
 316       if (!UseSharedSpaces) {
 317         for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
 318           _typeArrayKlassObjs[i] = TypeArrayKlass::create_klass((BasicType)i, CHECK);
 319         }
 320 
 321         ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
 322 
 323         _the_array_interfaces_array     = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL, CHECK);
 324         _the_empty_int_array            = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
 325         _the_empty_short_array          = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
 326         _the_empty_method_array         = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
 327         _the_empty_klass_array          = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
 328         _the_empty_instance_klass_array = MetadataFactory::new_array<InstanceKlass*>(null_cld, 0, CHECK);
 329       }
 330     }
 331 
 332     vmSymbols::initialize();
 333 
 334     SystemDictionary::initialize(CHECK);
 335 
 336     // Create string constants
 337     oop s = StringTable::intern("null", CHECK);
 338     _the_null_string = OopHandle(vm_global(), s);
 339     s = StringTable::intern("-2147483648", CHECK);
 340     _the_min_jint_string = OopHandle(vm_global(), s);
 341 
 342 
 343 #if INCLUDE_CDS
 344     if (UseSharedSpaces) {
 345       // Verify shared interfaces array.
 346       assert(_the_array_interfaces_array->at(0) ==
 347              vmClasses::Cloneable_klass(), "u3");
 348       assert(_the_array_interfaces_array->at(1) ==
 349              vmClasses::Serializable_klass(), "u3");







 350     } else
 351 #endif
 352     {
 353       // Set up shared interfaces array.  (Do this before supers are set up.)
 354       _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
 355       _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());

 356     }
 357 
 358     initialize_basic_type_klass(boolArrayKlassObj(), CHECK);
 359     initialize_basic_type_klass(charArrayKlassObj(), CHECK);
 360     initialize_basic_type_klass(floatArrayKlassObj(), CHECK);
 361     initialize_basic_type_klass(doubleArrayKlassObj(), CHECK);
 362     initialize_basic_type_klass(byteArrayKlassObj(), CHECK);
 363     initialize_basic_type_klass(shortArrayKlassObj(), CHECK);
 364     initialize_basic_type_klass(intArrayKlassObj(), CHECK);
 365     initialize_basic_type_klass(longArrayKlassObj(), CHECK);
 366   } // end of core bootstrapping
 367 
 368   {
 369     Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK);
 370     _the_null_sentinel = OopHandle(vm_global(), tns());
 371   }
 372 
 373   // Create a handle for reference_pending_list
 374   _reference_pending_list = OopHandle(vm_global(), NULL);
 375 

 440       for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 441         if (!is_reference_type((BasicType)i)) {
 442           oop m = _mirrors[i].resolve();
 443           assert(m != NULL, "archived mirrors should not be NULL");
 444         }
 445       }
 446     } else
 447       // _mirror[T_INT} could be NULL if archived heap is not mapped.
 448 #endif
 449     {
 450       for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 451         BasicType bt = (BasicType)i;
 452         if (!is_reference_type(bt)) {
 453           oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK);
 454           _mirrors[i] = OopHandle(vm_global(), m);
 455         }
 456       }
 457     }
 458 }
 459 

















 460 void Universe::fixup_mirrors(TRAPS) {
 461   // Bootstrap problem: all classes gets a mirror (java.lang.Class instance) assigned eagerly,
 462   // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply
 463   // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
 464   // that the number of objects allocated at this point is very small.
 465   assert(vmClasses::Class_klass_loaded(), "java.lang.Class should be loaded");
 466   HandleMark hm(THREAD);
 467 
 468   if (!UseSharedSpaces) {
 469     // Cache the start of the static fields
 470     InstanceMirrorKlass::init_offset_of_static_fields();
 471   }
 472 
 473   GrowableArray <Klass*>* list = java_lang_Class::fixup_mirror_list();
 474   int list_length = list->length();
 475   for (int i = 0; i < list_length; i++) {
 476     Klass* k = list->at(i);
 477     assert(k->is_klass(), "List should only hold classes");
 478     java_lang_Class::fixup_mirror(k, CATCH);
 479   }

 721   guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?");
 722   guarantee(sizeof(oop) % sizeof(HeapWord) == 0,
 723             "oop size is not not a multiple of HeapWord size");
 724 
 725   TraceTime timer("Genesis", TRACETIME_LOG(Info, startuptime));
 726 
 727   initialize_global_behaviours();
 728 
 729   GCLogPrecious::initialize();
 730 
 731   GCConfig::arguments()->initialize_heap_sizes();
 732 
 733   jint status = Universe::initialize_heap();
 734   if (status != JNI_OK) {
 735     return status;
 736   }
 737 
 738   Universe::initialize_tlab();
 739 
 740   Metaspace::global_initialize();
 741 
 742   // Initialize performance counters for metaspaces
 743   MetaspaceCounters::initialize_performance_counters();
 744 
 745   // Checks 'AfterMemoryInit' constraints.
 746   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 747     return JNI_EINVAL;
 748   }
 749 
 750   // Create memory for metadata.  Must be after initializing heap for
 751   // DumpSharedSpaces.
 752   ClassLoaderData::init_null_class_loader_data();
 753 
 754   // We have a heap so create the Method* caches before
 755   // Metaspace::initialize_shared_spaces() tries to populate them.
 756   Universe::_finalizer_register_cache = new LatestMethodCache();
 757   Universe::_loader_addClass_cache    = new LatestMethodCache();
 758   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 759   Universe::_throw_no_such_method_error_cache = new LatestMethodCache();
 760   Universe::_do_stack_walk_cache = new LatestMethodCache();


 761 
 762 #if INCLUDE_CDS
 763   if (UseSharedSpaces) {
 764     // Read the data structures supporting the shared spaces (shared
 765     // system dictionary, symbol table, etc.).  After that, access to
 766     // the file (other than the mapped regions) is no longer needed, and
 767     // the file is closed. Closing the file does not affect the
 768     // currently mapped regions.
 769     MetaspaceShared::initialize_shared_spaces();
 770     StringTable::create_table();
 771     if (HeapShared::is_loaded()) {
 772       StringTable::transfer_shared_strings_to_local_table();
 773     }
 774   } else
 775 #endif
 776   {
 777     SymbolTable::create_table();
 778     StringTable::create_table();
 779   }
 780 

 906                           vmClasses::internal_Unsafe_klass(),
 907                           "throwIllegalAccessError",
 908                           vmSymbols::void_method_signature(), true, CHECK);
 909 
 910   initialize_known_method(_throw_no_such_method_error_cache,
 911                           vmClasses::internal_Unsafe_klass(),
 912                           "throwNoSuchMethodError",
 913                           vmSymbols::void_method_signature(), true, CHECK);
 914 
 915   // Set up method for registering loaded classes in class loader vector
 916   initialize_known_method(_loader_addClass_cache,
 917                           vmClasses::ClassLoader_klass(),
 918                           "addClass",
 919                           vmSymbols::class_void_signature(), false, CHECK);
 920 
 921   // Set up method for stack walking
 922   initialize_known_method(_do_stack_walk_cache,
 923                           vmClasses::AbstractStackWalker_klass(),
 924                           "doStackWalk",
 925                           vmSymbols::doStackWalk_signature(), false, CHECK);











 926 }
 927 
 928 void universe2_init() {
 929   EXCEPTION_MARK;
 930   Universe::genesis(CATCH);
 931 }
 932 
 933 // Set after initialization of the module runtime, call_initModuleRuntime
 934 void universe_post_module_init() {
 935   Universe::_module_initialized = true;
 936 }
 937 
 938 bool universe_post_init() {
 939   assert(!is_init_completed(), "Error: initialization not yet completed!");
 940   Universe::_fully_initialized = true;
 941   EXCEPTION_MARK;
 942   if (!UseSharedSpaces) {
 943     reinitialize_vtables();
 944     reinitialize_itables();
 945   }

 104                            _oom_retry,
 105                            _oom_count };
 106 
 107 OopHandle Universe::_out_of_memory_errors;
 108 OopHandle Universe::_delayed_stack_overflow_error_message;
 109 OopHandle Universe::_preallocated_out_of_memory_error_array;
 110 volatile jint Universe::_preallocated_out_of_memory_error_avail_count = 0;
 111 
 112 OopHandle Universe::_null_ptr_exception_instance;
 113 OopHandle Universe::_arithmetic_exception_instance;
 114 OopHandle Universe::_virtual_machine_error_instance;
 115 
 116 OopHandle Universe::_reference_pending_list;
 117 
 118 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
 119 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
 120 LatestMethodCache* Universe::_loader_addClass_cache    = NULL;
 121 LatestMethodCache* Universe::_throw_illegal_access_error_cache = NULL;
 122 LatestMethodCache* Universe::_throw_no_such_method_error_cache = NULL;
 123 LatestMethodCache* Universe::_do_stack_walk_cache     = NULL;
 124 LatestMethodCache* Universe::_is_substitutable_cache  = NULL;
 125 LatestMethodCache* Universe::_primitive_type_hash_code_cache = NULL;
 126 
 127 long Universe::verify_flags                           = Universe::Verify_All;
 128 
 129 Array<int>* Universe::_the_empty_int_array            = NULL;
 130 Array<u2>* Universe::_the_empty_short_array           = NULL;
 131 Array<Klass*>* Universe::_the_empty_klass_array     = NULL;
 132 Array<InstanceKlass*>* Universe::_the_empty_instance_klass_array  = NULL;
 133 Array<InstanceKlass*>* Universe::_the_single_IdentityObject_klass_array = NULL;
 134 Array<InstanceKlass*>* Universe::_the_single_PrimitiveObject_klass_array = NULL;
 135 Array<Method*>* Universe::_the_empty_method_array   = NULL;
 136 
 137 // These variables are guarded by FullGCALot_lock.
 138 debug_only(OopHandle Universe::_fullgc_alot_dummy_array;)
 139 debug_only(int Universe::_fullgc_alot_dummy_next = 0;)
 140 
 141 // Heap
 142 int             Universe::_verify_count = 0;
 143 
 144 // Oop verification (see MacroAssembler::verify_oop)
 145 uintptr_t       Universe::_verify_oop_mask = 0;
 146 uintptr_t       Universe::_verify_oop_bits = (uintptr_t) -1;
 147 
 148 int             Universe::_base_vtable_size = 0;
 149 bool            Universe::_bootstrapping = false;
 150 bool            Universe::_module_initialized = false;
 151 bool            Universe::_fully_initialized = false;
 152 
 153 OopStorage*     Universe::_vm_weak = NULL;
 154 OopStorage*     Universe::_vm_global = NULL;

 205     closure->do_klass(_typeArrayKlassObjs[i]);
 206   }
 207 }
 208 
 209 void LatestMethodCache::metaspace_pointers_do(MetaspaceClosure* it) {
 210   it->push(&_klass);
 211 }
 212 
 213 void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
 214   for (int i = 0; i < T_LONG+1; i++) {
 215     it->push(&_typeArrayKlassObjs[i]);
 216   }
 217   it->push(&_objectArrayKlassObj);
 218 
 219   it->push(&_the_empty_int_array);
 220   it->push(&_the_empty_short_array);
 221   it->push(&_the_empty_klass_array);
 222   it->push(&_the_empty_instance_klass_array);
 223   it->push(&_the_empty_method_array);
 224   it->push(&_the_array_interfaces_array);
 225   it->push(&_the_single_IdentityObject_klass_array);
 226   it->push(&_the_single_PrimitiveObject_klass_array);
 227 
 228   _finalizer_register_cache->metaspace_pointers_do(it);
 229   _loader_addClass_cache->metaspace_pointers_do(it);
 230   _throw_illegal_access_error_cache->metaspace_pointers_do(it);
 231   _throw_no_such_method_error_cache->metaspace_pointers_do(it);
 232   _do_stack_walk_cache->metaspace_pointers_do(it);
 233   _is_substitutable_cache->metaspace_pointers_do(it);
 234   _primitive_type_hash_code_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 #if INCLUDE_CDS_JAVA_HEAP
 241   {
 242     oop mirror_oop;
 243     for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 244       if (f->reading()) {
 245         f->do_oop(&mirror_oop); // read from archive
 246         assert(oopDesc::is_oop_or_null(mirror_oop), "is oop");
 247         // Only create an OopHandle for non-null mirrors
 248         if (mirror_oop != NULL) {
 249           _mirrors[i] = OopHandle(vm_global(), mirror_oop);
 250         }
 251       } else {
 252         if (HeapShared::can_write()) {
 253           mirror_oop = _mirrors[i].resolve();
 254         } else {

 257         f->do_oop(&mirror_oop); // write to archive
 258       }
 259       if (mirror_oop != NULL) { // may be null if archived heap is disabled
 260         java_lang_Class::update_archived_primitive_mirror_native_pointers(mirror_oop);
 261       }
 262     }
 263   }
 264 #endif
 265 
 266   for (int i = 0; i < T_LONG+1; i++) {
 267     f->do_ptr((void**)&_typeArrayKlassObjs[i]);
 268   }
 269 
 270   f->do_ptr((void**)&_objectArrayKlassObj);
 271   f->do_ptr((void**)&_the_array_interfaces_array);
 272   f->do_ptr((void**)&_the_empty_int_array);
 273   f->do_ptr((void**)&_the_empty_short_array);
 274   f->do_ptr((void**)&_the_empty_method_array);
 275   f->do_ptr((void**)&_the_empty_klass_array);
 276   f->do_ptr((void**)&_the_empty_instance_klass_array);
 277   f->do_ptr((void**)&_the_single_IdentityObject_klass_array);
 278   f->do_ptr((void**)&_the_single_PrimitiveObject_klass_array);
 279   _finalizer_register_cache->serialize(f);
 280   _loader_addClass_cache->serialize(f);
 281   _throw_illegal_access_error_cache->serialize(f);
 282   _throw_no_such_method_error_cache->serialize(f);
 283   _do_stack_walk_cache->serialize(f);
 284   _is_substitutable_cache->serialize(f);
 285   _primitive_type_hash_code_cache->serialize(f);
 286 }
 287 
 288 
 289 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 290   if (size < alignment || size % alignment != 0) {
 291     vm_exit_during_initialization(
 292       err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment));
 293   }
 294 }
 295 
 296 void initialize_basic_type_klass(Klass* k, TRAPS) {
 297   Klass* ok = vmClasses::Object_klass();
 298 #if INCLUDE_CDS
 299   if (UseSharedSpaces) {
 300     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 301     assert(k->super() == ok, "u3");
 302     if (k->is_instance_klass()) {
 303       InstanceKlass::cast(k)->restore_unshareable_info(loader_data, Handle(), NULL, CHECK);
 304     } else {
 305       ArrayKlass::cast(k)->restore_unshareable_info(loader_data, Handle(), CHECK);

 315 void Universe::genesis(TRAPS) {
 316   ResourceMark rm(THREAD);
 317   HandleMark   hm(THREAD);
 318 
 319   { AutoModifyRestore<bool> temporarily(_bootstrapping, true);
 320 
 321     { MutexLocker mc(THREAD, Compile_lock);
 322 
 323       java_lang_Class::allocate_fixup_lists();
 324 
 325       // determine base vtable size; without that we cannot create the array klasses
 326       compute_base_vtable_size();
 327 
 328       if (!UseSharedSpaces) {
 329         for (int i = T_BOOLEAN; i < T_LONG+1; i++) {
 330           _typeArrayKlassObjs[i] = TypeArrayKlass::create_klass((BasicType)i, CHECK);
 331         }
 332 
 333         ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
 334 
 335         _the_array_interfaces_array     = MetadataFactory::new_array<Klass*>(null_cld, 3, NULL, CHECK);
 336         _the_empty_int_array            = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
 337         _the_empty_short_array          = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
 338         _the_empty_method_array         = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
 339         _the_empty_klass_array          = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
 340         _the_empty_instance_klass_array = MetadataFactory::new_array<InstanceKlass*>(null_cld, 0, CHECK);
 341       }
 342     }
 343 
 344     vmSymbols::initialize();
 345 
 346     SystemDictionary::initialize(CHECK);
 347 
 348     // Create string constants
 349     oop s = StringTable::intern("null", CHECK);
 350     _the_null_string = OopHandle(vm_global(), s);
 351     s = StringTable::intern("-2147483648", CHECK);
 352     _the_min_jint_string = OopHandle(vm_global(), s);
 353 
 354 
 355 #if INCLUDE_CDS
 356     if (UseSharedSpaces) {
 357       // Verify shared interfaces array.
 358       assert(_the_array_interfaces_array->at(0) ==
 359              vmClasses::Cloneable_klass(), "u3");
 360       assert(_the_array_interfaces_array->at(1) ==
 361              vmClasses::Serializable_klass(), "u3");
 362       assert(_the_array_interfaces_array->at(2) ==
 363                    vmClasses::IdentityObject_klass(), "u3");
 364 
 365       assert(_the_single_IdentityObject_klass_array->at(0) ==
 366           vmClasses::IdentityObject_klass(), "u3");
 367       assert(_the_single_PrimitiveObject_klass_array->at(0) ==
 368           vmClasses::PrimitiveObject_klass(), "u3");
 369     } else
 370 #endif
 371     {
 372       // Set up shared interfaces array.  (Do this before supers are set up.)
 373       _the_array_interfaces_array->at_put(0, vmClasses::Cloneable_klass());
 374       _the_array_interfaces_array->at_put(1, vmClasses::Serializable_klass());
 375       _the_array_interfaces_array->at_put(2, vmClasses::IdentityObject_klass());
 376     }
 377 
 378     initialize_basic_type_klass(boolArrayKlassObj(), CHECK);
 379     initialize_basic_type_klass(charArrayKlassObj(), CHECK);
 380     initialize_basic_type_klass(floatArrayKlassObj(), CHECK);
 381     initialize_basic_type_klass(doubleArrayKlassObj(), CHECK);
 382     initialize_basic_type_klass(byteArrayKlassObj(), CHECK);
 383     initialize_basic_type_klass(shortArrayKlassObj(), CHECK);
 384     initialize_basic_type_klass(intArrayKlassObj(), CHECK);
 385     initialize_basic_type_klass(longArrayKlassObj(), CHECK);
 386   } // end of core bootstrapping
 387 
 388   {
 389     Handle tns = java_lang_String::create_from_str("<null_sentinel>", CHECK);
 390     _the_null_sentinel = OopHandle(vm_global(), tns());
 391   }
 392 
 393   // Create a handle for reference_pending_list
 394   _reference_pending_list = OopHandle(vm_global(), NULL);
 395 

 460       for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 461         if (!is_reference_type((BasicType)i)) {
 462           oop m = _mirrors[i].resolve();
 463           assert(m != NULL, "archived mirrors should not be NULL");
 464         }
 465       }
 466     } else
 467       // _mirror[T_INT} could be NULL if archived heap is not mapped.
 468 #endif
 469     {
 470       for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
 471         BasicType bt = (BasicType)i;
 472         if (!is_reference_type(bt)) {
 473           oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK);
 474           _mirrors[i] = OopHandle(vm_global(), m);
 475         }
 476       }
 477     }
 478 }
 479 
 480 void Universe::initialize_the_single_IdentityObject_klass_array(InstanceKlass* ik, TRAPS) {
 481     assert(_the_single_IdentityObject_klass_array == NULL, "Must not be initialized twice");
 482     assert(ik->name() == vmSymbols::java_lang_IdentityObject(), "Must be");
 483     Array<InstanceKlass*>* array = MetadataFactory::new_array<InstanceKlass*>(ik->class_loader_data(), 1, NULL, CHECK);
 484     array->at_put(0, ik);
 485     _the_single_IdentityObject_klass_array = array;
 486 }
 487 
 488 void Universe::initialize_the_single_PrimitiveObject_klass_array(InstanceKlass* ik, TRAPS) {
 489     assert(_the_single_PrimitiveObject_klass_array == NULL, "Must not be initialized twice");
 490     assert(ik->name() == vmSymbols::java_lang_PrimitiveObject(), "Must be");
 491     Array<InstanceKlass*>* array = MetadataFactory::new_array<InstanceKlass*>(ik->class_loader_data(), 1, NULL, CHECK);
 492     array->at_put(0, ik);
 493     _the_single_PrimitiveObject_klass_array = array;
 494 }
 495 
 496 
 497 void Universe::fixup_mirrors(TRAPS) {
 498   // Bootstrap problem: all classes gets a mirror (java.lang.Class instance) assigned eagerly,
 499   // but we cannot do that for classes created before java.lang.Class is loaded. Here we simply
 500   // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
 501   // that the number of objects allocated at this point is very small.
 502   assert(vmClasses::Class_klass_loaded(), "java.lang.Class should be loaded");
 503   HandleMark hm(THREAD);
 504 
 505   if (!UseSharedSpaces) {
 506     // Cache the start of the static fields
 507     InstanceMirrorKlass::init_offset_of_static_fields();
 508   }
 509 
 510   GrowableArray <Klass*>* list = java_lang_Class::fixup_mirror_list();
 511   int list_length = list->length();
 512   for (int i = 0; i < list_length; i++) {
 513     Klass* k = list->at(i);
 514     assert(k->is_klass(), "List should only hold classes");
 515     java_lang_Class::fixup_mirror(k, CATCH);
 516   }

 758   guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?");
 759   guarantee(sizeof(oop) % sizeof(HeapWord) == 0,
 760             "oop size is not not a multiple of HeapWord size");
 761 
 762   TraceTime timer("Genesis", TRACETIME_LOG(Info, startuptime));
 763 
 764   initialize_global_behaviours();
 765 
 766   GCLogPrecious::initialize();
 767 
 768   GCConfig::arguments()->initialize_heap_sizes();
 769 
 770   jint status = Universe::initialize_heap();
 771   if (status != JNI_OK) {
 772     return status;
 773   }
 774 
 775   Universe::initialize_tlab();
 776 
 777   Metaspace::global_initialize();

 778   // Initialize performance counters for metaspaces
 779   MetaspaceCounters::initialize_performance_counters();
 780 
 781   // Checks 'AfterMemoryInit' constraints.
 782   if (!JVMFlagLimit::check_all_constraints(JVMFlagConstraintPhase::AfterMemoryInit)) {
 783     return JNI_EINVAL;
 784   }
 785 
 786   // Create memory for metadata.  Must be after initializing heap for
 787   // DumpSharedSpaces.
 788   ClassLoaderData::init_null_class_loader_data();
 789 
 790   // We have a heap so create the Method* caches before
 791   // Metaspace::initialize_shared_spaces() tries to populate them.
 792   Universe::_finalizer_register_cache = new LatestMethodCache();
 793   Universe::_loader_addClass_cache    = new LatestMethodCache();
 794   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 795   Universe::_throw_no_such_method_error_cache = new LatestMethodCache();
 796   Universe::_do_stack_walk_cache = new LatestMethodCache();
 797   Universe::_is_substitutable_cache = new LatestMethodCache();
 798   Universe::_primitive_type_hash_code_cache = new LatestMethodCache();
 799 
 800 #if INCLUDE_CDS
 801   if (UseSharedSpaces) {
 802     // Read the data structures supporting the shared spaces (shared
 803     // system dictionary, symbol table, etc.).  After that, access to
 804     // the file (other than the mapped regions) is no longer needed, and
 805     // the file is closed. Closing the file does not affect the
 806     // currently mapped regions.
 807     MetaspaceShared::initialize_shared_spaces();
 808     StringTable::create_table();
 809     if (HeapShared::is_loaded()) {
 810       StringTable::transfer_shared_strings_to_local_table();
 811     }
 812   } else
 813 #endif
 814   {
 815     SymbolTable::create_table();
 816     StringTable::create_table();
 817   }
 818 

 944                           vmClasses::internal_Unsafe_klass(),
 945                           "throwIllegalAccessError",
 946                           vmSymbols::void_method_signature(), true, CHECK);
 947 
 948   initialize_known_method(_throw_no_such_method_error_cache,
 949                           vmClasses::internal_Unsafe_klass(),
 950                           "throwNoSuchMethodError",
 951                           vmSymbols::void_method_signature(), true, CHECK);
 952 
 953   // Set up method for registering loaded classes in class loader vector
 954   initialize_known_method(_loader_addClass_cache,
 955                           vmClasses::ClassLoader_klass(),
 956                           "addClass",
 957                           vmSymbols::class_void_signature(), false, CHECK);
 958 
 959   // Set up method for stack walking
 960   initialize_known_method(_do_stack_walk_cache,
 961                           vmClasses::AbstractStackWalker_klass(),
 962                           "doStackWalk",
 963                           vmSymbols::doStackWalk_signature(), false, CHECK);
 964 
 965   // Set up substitutability testing
 966   ResourceMark rm;
 967   initialize_known_method(_is_substitutable_cache,
 968                           vmClasses::PrimitiveObjectMethods_klass(),
 969                           vmSymbols::isSubstitutable_name()->as_C_string(),
 970                           vmSymbols::object_object_boolean_signature(), true, CHECK);
 971   initialize_known_method(_primitive_type_hash_code_cache,
 972                           vmClasses::PrimitiveObjectMethods_klass(),
 973                           vmSymbols::primitiveObjectHashCode_name()->as_C_string(),
 974                           vmSymbols::object_int_signature(), true, CHECK);
 975 }
 976 
 977 void universe2_init() {
 978   EXCEPTION_MARK;
 979   Universe::genesis(CATCH);
 980 }
 981 
 982 // Set after initialization of the module runtime, call_initModuleRuntime
 983 void universe_post_module_init() {
 984   Universe::_module_initialized = true;
 985 }
 986 
 987 bool universe_post_init() {
 988   assert(!is_init_completed(), "Error: initialization not yet completed!");
 989   Universe::_fully_initialized = true;
 990   EXCEPTION_MARK;
 991   if (!UseSharedSpaces) {
 992     reinitialize_vtables();
 993     reinitialize_itables();
 994   }
< prev index next >