< prev index next >

src/share/vm/memory/universe.cpp

Print this page
rev 12858 : 8184323: compile-time guard some UseSharedSpaces-only coding with the INCLUDE_CDS macro


 246   f->do_ptr((void**)&_the_empty_int_array);
 247   f->do_ptr((void**)&_the_empty_short_array);
 248   f->do_ptr((void**)&_the_empty_method_array);
 249   f->do_ptr((void**)&_the_empty_klass_array);
 250   _finalizer_register_cache->serialize(f);
 251   _loader_addClass_cache->serialize(f);
 252   _pd_implies_cache->serialize(f);
 253   _throw_illegal_access_error_cache->serialize(f);
 254   _do_stack_walk_cache->serialize(f);
 255 }
 256 
 257 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 258   if (size < alignment || size % alignment != 0) {
 259     vm_exit_during_initialization(
 260       err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment));
 261   }
 262 }
 263 
 264 void initialize_basic_type_klass(Klass* k, TRAPS) {
 265   Klass* ok = SystemDictionary::Object_klass();

 266   if (UseSharedSpaces) {
 267     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 268     assert(k->super() == ok, "u3");
 269     k->restore_unshareable_info(loader_data, Handle(), CHECK);
 270   } else {


 271     k->initialize_supers(ok, CHECK);
 272   }
 273   k->append_to_sibling_list();
 274 }
 275 
 276 void Universe::genesis(TRAPS) {
 277   ResourceMark rm;
 278 
 279   { FlagSetting fs(_bootstrapping, true);
 280 
 281     { MutexLocker mc(Compile_lock);
 282 
 283       // determine base vtable size; without that we cannot create the array klasses
 284       compute_base_vtable_size();
 285 
 286       if (!UseSharedSpaces) {
 287         _boolArrayKlassObj      = TypeArrayKlass::create_klass(T_BOOLEAN, sizeof(jboolean), CHECK);
 288         _charArrayKlassObj      = TypeArrayKlass::create_klass(T_CHAR,    sizeof(jchar),    CHECK);
 289         _singleArrayKlassObj    = TypeArrayKlass::create_klass(T_FLOAT,   sizeof(jfloat),   CHECK);
 290         _doubleArrayKlassObj    = TypeArrayKlass::create_klass(T_DOUBLE,  sizeof(jdouble),  CHECK);


 304 
 305         ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
 306 
 307         _the_array_interfaces_array = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL, CHECK);
 308         _the_empty_int_array        = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
 309         _the_empty_short_array      = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
 310         _the_empty_method_array     = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
 311         _the_empty_klass_array      = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
 312       }
 313     }
 314 
 315     vmSymbols::initialize(CHECK);
 316 
 317     SystemDictionary::initialize(CHECK);
 318 
 319     Klass* ok = SystemDictionary::Object_klass();
 320 
 321     _the_null_string            = StringTable::intern("null", CHECK);
 322     _the_min_jint_string       = StringTable::intern("-2147483648", CHECK);
 323 

 324     if (UseSharedSpaces) {
 325       // Verify shared interfaces array.
 326       assert(_the_array_interfaces_array->at(0) ==
 327              SystemDictionary::Cloneable_klass(), "u3");
 328       assert(_the_array_interfaces_array->at(1) ==
 329              SystemDictionary::Serializable_klass(), "u3");
 330       MetaspaceShared::fixup_shared_string_regions();
 331     } else {


 332       // Set up shared interfaces array.  (Do this before supers are set up.)
 333       _the_array_interfaces_array->at_put(0, SystemDictionary::Cloneable_klass());
 334       _the_array_interfaces_array->at_put(1, SystemDictionary::Serializable_klass());
 335     }
 336 
 337     initialize_basic_type_klass(boolArrayKlassObj(), CHECK);
 338     initialize_basic_type_klass(charArrayKlassObj(), CHECK);
 339     initialize_basic_type_klass(singleArrayKlassObj(), CHECK);
 340     initialize_basic_type_klass(doubleArrayKlassObj(), CHECK);
 341     initialize_basic_type_klass(byteArrayKlassObj(), CHECK);
 342     initialize_basic_type_klass(shortArrayKlassObj(), CHECK);
 343     initialize_basic_type_klass(intArrayKlassObj(), CHECK);
 344     initialize_basic_type_klass(longArrayKlassObj(), CHECK);
 345   } // end of core bootstrapping
 346 
 347   // Maybe this could be lifted up now that object array can be initialized
 348   // during the bootstrapping.
 349 
 350   // OLD
 351   // Initialize _objectArrayKlass after core bootstraping to make


 674 
 675   AOTLoader::universe_init();
 676 
 677   // Checks 'AfterMemoryInit' constraints.
 678   if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) {
 679     return JNI_EINVAL;
 680   }
 681 
 682   // Create memory for metadata.  Must be after initializing heap for
 683   // DumpSharedSpaces.
 684   ClassLoaderData::init_null_class_loader_data();
 685 
 686   // We have a heap so create the Method* caches before
 687   // Metaspace::initialize_shared_spaces() tries to populate them.
 688   Universe::_finalizer_register_cache = new LatestMethodCache();
 689   Universe::_loader_addClass_cache    = new LatestMethodCache();
 690   Universe::_pd_implies_cache         = new LatestMethodCache();
 691   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 692   Universe::_do_stack_walk_cache = new LatestMethodCache();
 693 

 694   if (UseSharedSpaces) {
 695     // Read the data structures supporting the shared spaces (shared
 696     // system dictionary, symbol table, etc.).  After that, access to
 697     // the file (other than the mapped regions) is no longer needed, and
 698     // the file is closed. Closing the file does not affect the
 699     // currently mapped regions.
 700     MetaspaceShared::initialize_shared_spaces();
 701     StringTable::create_table();
 702   } else {


 703     SymbolTable::create_table();
 704     StringTable::create_table();
 705 
 706     if (DumpSharedSpaces) {
 707       MetaspaceShared::prepare_for_dumping();
 708     }
 709   }
 710   if (strlen(VerifySubSet) > 0) {
 711     Universe::initialize_verify_flags();
 712   }
 713 
 714   return JNI_OK;
 715 }
 716 
 717 CollectedHeap* Universe::create_heap() {
 718   assert(_collectedHeap == NULL, "Heap already created");
 719 #if !INCLUDE_ALL_GCS
 720   if (UseParallelGC) {
 721     fatal("UseParallelGC not supported in this VM.");
 722   } else if (UseG1GC) {




 246   f->do_ptr((void**)&_the_empty_int_array);
 247   f->do_ptr((void**)&_the_empty_short_array);
 248   f->do_ptr((void**)&_the_empty_method_array);
 249   f->do_ptr((void**)&_the_empty_klass_array);
 250   _finalizer_register_cache->serialize(f);
 251   _loader_addClass_cache->serialize(f);
 252   _pd_implies_cache->serialize(f);
 253   _throw_illegal_access_error_cache->serialize(f);
 254   _do_stack_walk_cache->serialize(f);
 255 }
 256 
 257 void Universe::check_alignment(uintx size, uintx alignment, const char* name) {
 258   if (size < alignment || size % alignment != 0) {
 259     vm_exit_during_initialization(
 260       err_msg("Size of %s (" UINTX_FORMAT " bytes) must be aligned to " UINTX_FORMAT " bytes", name, size, alignment));
 261   }
 262 }
 263 
 264 void initialize_basic_type_klass(Klass* k, TRAPS) {
 265   Klass* ok = SystemDictionary::Object_klass();
 266 #if INCLUDE_CDS
 267   if (UseSharedSpaces) {
 268     ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 269     assert(k->super() == ok, "u3");
 270     k->restore_unshareable_info(loader_data, Handle(), CHECK);
 271   } else
 272 #endif
 273   {
 274     k->initialize_supers(ok, CHECK);
 275   }
 276   k->append_to_sibling_list();
 277 }
 278 
 279 void Universe::genesis(TRAPS) {
 280   ResourceMark rm;
 281 
 282   { FlagSetting fs(_bootstrapping, true);
 283 
 284     { MutexLocker mc(Compile_lock);
 285 
 286       // determine base vtable size; without that we cannot create the array klasses
 287       compute_base_vtable_size();
 288 
 289       if (!UseSharedSpaces) {
 290         _boolArrayKlassObj      = TypeArrayKlass::create_klass(T_BOOLEAN, sizeof(jboolean), CHECK);
 291         _charArrayKlassObj      = TypeArrayKlass::create_klass(T_CHAR,    sizeof(jchar),    CHECK);
 292         _singleArrayKlassObj    = TypeArrayKlass::create_klass(T_FLOAT,   sizeof(jfloat),   CHECK);
 293         _doubleArrayKlassObj    = TypeArrayKlass::create_klass(T_DOUBLE,  sizeof(jdouble),  CHECK);


 307 
 308         ClassLoaderData* null_cld = ClassLoaderData::the_null_class_loader_data();
 309 
 310         _the_array_interfaces_array = MetadataFactory::new_array<Klass*>(null_cld, 2, NULL, CHECK);
 311         _the_empty_int_array        = MetadataFactory::new_array<int>(null_cld, 0, CHECK);
 312         _the_empty_short_array      = MetadataFactory::new_array<u2>(null_cld, 0, CHECK);
 313         _the_empty_method_array     = MetadataFactory::new_array<Method*>(null_cld, 0, CHECK);
 314         _the_empty_klass_array      = MetadataFactory::new_array<Klass*>(null_cld, 0, CHECK);
 315       }
 316     }
 317 
 318     vmSymbols::initialize(CHECK);
 319 
 320     SystemDictionary::initialize(CHECK);
 321 
 322     Klass* ok = SystemDictionary::Object_klass();
 323 
 324     _the_null_string            = StringTable::intern("null", CHECK);
 325     _the_min_jint_string       = StringTable::intern("-2147483648", CHECK);
 326 
 327 #if INCLUDE_CDS
 328     if (UseSharedSpaces) {
 329       // Verify shared interfaces array.
 330       assert(_the_array_interfaces_array->at(0) ==
 331              SystemDictionary::Cloneable_klass(), "u3");
 332       assert(_the_array_interfaces_array->at(1) ==
 333              SystemDictionary::Serializable_klass(), "u3");
 334       MetaspaceShared::fixup_shared_string_regions();
 335     } else
 336 #endif
 337     {
 338       // Set up shared interfaces array.  (Do this before supers are set up.)
 339       _the_array_interfaces_array->at_put(0, SystemDictionary::Cloneable_klass());
 340       _the_array_interfaces_array->at_put(1, SystemDictionary::Serializable_klass());
 341     }
 342 
 343     initialize_basic_type_klass(boolArrayKlassObj(), CHECK);
 344     initialize_basic_type_klass(charArrayKlassObj(), CHECK);
 345     initialize_basic_type_klass(singleArrayKlassObj(), CHECK);
 346     initialize_basic_type_klass(doubleArrayKlassObj(), CHECK);
 347     initialize_basic_type_klass(byteArrayKlassObj(), CHECK);
 348     initialize_basic_type_klass(shortArrayKlassObj(), CHECK);
 349     initialize_basic_type_klass(intArrayKlassObj(), CHECK);
 350     initialize_basic_type_klass(longArrayKlassObj(), CHECK);
 351   } // end of core bootstrapping
 352 
 353   // Maybe this could be lifted up now that object array can be initialized
 354   // during the bootstrapping.
 355 
 356   // OLD
 357   // Initialize _objectArrayKlass after core bootstraping to make


 680 
 681   AOTLoader::universe_init();
 682 
 683   // Checks 'AfterMemoryInit' constraints.
 684   if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) {
 685     return JNI_EINVAL;
 686   }
 687 
 688   // Create memory for metadata.  Must be after initializing heap for
 689   // DumpSharedSpaces.
 690   ClassLoaderData::init_null_class_loader_data();
 691 
 692   // We have a heap so create the Method* caches before
 693   // Metaspace::initialize_shared_spaces() tries to populate them.
 694   Universe::_finalizer_register_cache = new LatestMethodCache();
 695   Universe::_loader_addClass_cache    = new LatestMethodCache();
 696   Universe::_pd_implies_cache         = new LatestMethodCache();
 697   Universe::_throw_illegal_access_error_cache = new LatestMethodCache();
 698   Universe::_do_stack_walk_cache = new LatestMethodCache();
 699 
 700 #if INCLUDE_CDS
 701   if (UseSharedSpaces) {
 702     // Read the data structures supporting the shared spaces (shared
 703     // system dictionary, symbol table, etc.).  After that, access to
 704     // the file (other than the mapped regions) is no longer needed, and
 705     // the file is closed. Closing the file does not affect the
 706     // currently mapped regions.
 707     MetaspaceShared::initialize_shared_spaces();
 708     StringTable::create_table();
 709   } else
 710 #endif
 711   {
 712     SymbolTable::create_table();
 713     StringTable::create_table();
 714 
 715     if (DumpSharedSpaces) {
 716       MetaspaceShared::prepare_for_dumping();
 717     }
 718   }
 719   if (strlen(VerifySubSet) > 0) {
 720     Universe::initialize_verify_flags();
 721   }
 722 
 723   return JNI_OK;
 724 }
 725 
 726 CollectedHeap* Universe::create_heap() {
 727   assert(_collectedHeap == NULL, "Heap already created");
 728 #if !INCLUDE_ALL_GCS
 729   if (UseParallelGC) {
 730     fatal("UseParallelGC not supported in this VM.");
 731   } else if (UseG1GC) {


< prev index next >