21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/javaClasses.hpp"
30 #include "classfile/stringTable.hpp"
31 #include "classfile/systemDictionary.hpp"
32 #include "classfile/vmSymbols.hpp"
33 #include "code/codeCache.hpp"
34 #include "code/dependencies.hpp"
35 #include "gc/shared/cardTableBarrierSet.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/gcArguments.hpp"
38 #include "gc/shared/gcLocker.hpp"
39 #include "gc/shared/generation.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/space.hpp"
42 #include "interpreter/interpreter.hpp"
43 #include "logging/log.hpp"
44 #include "logging/logStream.hpp"
45 #include "memory/filemap.hpp"
46 #include "memory/metadataFactory.hpp"
47 #include "memory/metaspaceClosure.hpp"
48 #include "memory/metaspaceShared.hpp"
49 #include "memory/oopFactory.hpp"
50 #include "memory/resourceArea.hpp"
51 #include "memory/universe.hpp"
52 #include "memory/universe.hpp"
53 #include "oops/constantPool.hpp"
54 #include "oops/instanceClassLoaderKlass.hpp"
55 #include "oops/instanceKlass.hpp"
56 #include "oops/instanceMirrorKlass.hpp"
57 #include "oops/instanceRefKlass.hpp"
58 #include "oops/objArrayOop.inline.hpp"
59 #include "oops/oop.inline.hpp"
60 #include "oops/typeArrayKlass.hpp"
80 #include "utilities/formatBuffer.hpp"
81 #include "utilities/hashtable.inline.hpp"
82 #include "utilities/macros.hpp"
83 #include "utilities/ostream.hpp"
84 #include "utilities/preserveException.hpp"
85 #if INCLUDE_CDS
86 #include "classfile/sharedClassUtil.hpp"
87 #endif
88
89 // Known objects
90 Klass* Universe::_boolArrayKlassObj = NULL;
91 Klass* Universe::_byteArrayKlassObj = NULL;
92 Klass* Universe::_charArrayKlassObj = NULL;
93 Klass* Universe::_intArrayKlassObj = NULL;
94 Klass* Universe::_shortArrayKlassObj = NULL;
95 Klass* Universe::_longArrayKlassObj = NULL;
96 Klass* Universe::_singleArrayKlassObj = NULL;
97 Klass* Universe::_doubleArrayKlassObj = NULL;
98 Klass* Universe::_typeArrayKlassObjs[T_VOID+1] = { NULL /*, NULL...*/ };
99 Klass* Universe::_objectArrayKlassObj = NULL;
100 oop Universe::_int_mirror = NULL;
101 oop Universe::_float_mirror = NULL;
102 oop Universe::_double_mirror = NULL;
103 oop Universe::_byte_mirror = NULL;
104 oop Universe::_bool_mirror = NULL;
105 oop Universe::_char_mirror = NULL;
106 oop Universe::_long_mirror = NULL;
107 oop Universe::_short_mirror = NULL;
108 oop Universe::_void_mirror = NULL;
109 oop Universe::_mirrors[T_VOID+1] = { NULL /*, NULL...*/ };
110 oop Universe::_main_thread_group = NULL;
111 oop Universe::_system_thread_group = NULL;
112 objArrayOop Universe::_the_empty_class_klass_array = NULL;
113 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
114 oop Universe::_the_null_sentinel = NULL;
115 oop Universe::_the_null_string = NULL;
116 oop Universe::_the_min_jint_string = NULL;
117 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
118 LatestMethodCache* Universe::_loader_addClass_cache = NULL;
119 LatestMethodCache* Universe::_pd_implies_cache = NULL;
671 return (void*)_non_oop_bits;
672 }
673
674 jint universe_init() {
675 assert(!Universe::_fully_initialized, "called after initialize_vtables");
676 guarantee(1 << LogHeapWordSize == sizeof(HeapWord),
677 "LogHeapWordSize is incorrect.");
678 guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?");
679 guarantee(sizeof(oop) % sizeof(HeapWord) == 0,
680 "oop size is not not a multiple of HeapWord size");
681
682 TraceTime timer("Genesis", TRACETIME_LOG(Info, startuptime));
683
684 JavaClasses::compute_hard_coded_offsets();
685
686 jint status = Universe::initialize_heap();
687 if (status != JNI_OK) {
688 return status;
689 }
690
691 Metaspace::global_initialize();
692
693 // Initialize performance counters for metaspaces
694 MetaspaceCounters::initialize_performance_counters();
695 CompressedClassSpaceCounters::initialize_performance_counters();
696
697 AOTLoader::universe_init();
698
699 // Checks 'AfterMemoryInit' constraints.
700 if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) {
701 return JNI_EINVAL;
702 }
703
704 // Create memory for metadata. Must be after initializing heap for
705 // DumpSharedSpaces.
706 ClassLoaderData::init_null_class_loader_data();
707
708 // We have a heap so create the Method* caches before
709 // Metaspace::initialize_shared_spaces() tries to populate them.
710 Universe::_finalizer_register_cache = new LatestMethodCache();
1326 #ifndef PRODUCT
1327 else {
1328 // sharing initilization should have already set up _klass
1329 assert(_klass != NULL, "just checking");
1330 }
1331 #endif
1332
1333 _method_idnum = m->method_idnum();
1334 assert(_method_idnum >= 0, "sanity check");
1335 }
1336
1337
1338 Method* LatestMethodCache::get_method() {
1339 if (klass() == NULL) return NULL;
1340 InstanceKlass* ik = InstanceKlass::cast(klass());
1341 Method* m = ik->method_with_idnum(method_idnum());
1342 assert(m != NULL, "sanity check");
1343 return m;
1344 }
1345
1346
1347 #ifdef ASSERT
1348 // Release dummy object(s) at bottom of heap
1349 bool Universe::release_fullgc_alot_dummy() {
1350 MutexLocker ml(FullGCALot_lock);
1351 if (_fullgc_alot_dummy_array != NULL) {
1352 if (_fullgc_alot_dummy_next >= _fullgc_alot_dummy_array->length()) {
1353 // No more dummies to release, release entire array instead
1354 _fullgc_alot_dummy_array = NULL;
1355 return false;
1356 }
1357 if (!UseConcMarkSweepGC) {
1358 // Release dummy at bottom of old generation
1359 _fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
1360 }
1361 // Release dummy at bottom of permanent generation
1362 _fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
1363 }
1364 return true;
1365 }
|
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/classLoader.hpp"
28 #include "classfile/classLoaderData.hpp"
29 #include "classfile/javaClasses.hpp"
30 #include "classfile/stringTable.hpp"
31 #include "classfile/systemDictionary.hpp"
32 #include "classfile/vmSymbols.hpp"
33 #include "code/codeCache.hpp"
34 #include "code/dependencies.hpp"
35 #include "gc/shared/cardTableBarrierSet.hpp"
36 #include "gc/shared/collectedHeap.inline.hpp"
37 #include "gc/shared/gcArguments.hpp"
38 #include "gc/shared/gcLocker.hpp"
39 #include "gc/shared/generation.hpp"
40 #include "gc/shared/gcTraceTime.inline.hpp"
41 #include "gc/shared/oopStorage.hpp"
42 #include "gc/shared/space.hpp"
43 #include "interpreter/interpreter.hpp"
44 #include "logging/log.hpp"
45 #include "logging/logStream.hpp"
46 #include "memory/filemap.hpp"
47 #include "memory/metadataFactory.hpp"
48 #include "memory/metaspaceClosure.hpp"
49 #include "memory/metaspaceShared.hpp"
50 #include "memory/oopFactory.hpp"
51 #include "memory/resourceArea.hpp"
52 #include "memory/universe.hpp"
53 #include "memory/universe.hpp"
54 #include "oops/constantPool.hpp"
55 #include "oops/instanceClassLoaderKlass.hpp"
56 #include "oops/instanceKlass.hpp"
57 #include "oops/instanceMirrorKlass.hpp"
58 #include "oops/instanceRefKlass.hpp"
59 #include "oops/objArrayOop.inline.hpp"
60 #include "oops/oop.inline.hpp"
61 #include "oops/typeArrayKlass.hpp"
81 #include "utilities/formatBuffer.hpp"
82 #include "utilities/hashtable.inline.hpp"
83 #include "utilities/macros.hpp"
84 #include "utilities/ostream.hpp"
85 #include "utilities/preserveException.hpp"
86 #if INCLUDE_CDS
87 #include "classfile/sharedClassUtil.hpp"
88 #endif
89
90 // Known objects
91 Klass* Universe::_boolArrayKlassObj = NULL;
92 Klass* Universe::_byteArrayKlassObj = NULL;
93 Klass* Universe::_charArrayKlassObj = NULL;
94 Klass* Universe::_intArrayKlassObj = NULL;
95 Klass* Universe::_shortArrayKlassObj = NULL;
96 Klass* Universe::_longArrayKlassObj = NULL;
97 Klass* Universe::_singleArrayKlassObj = NULL;
98 Klass* Universe::_doubleArrayKlassObj = NULL;
99 Klass* Universe::_typeArrayKlassObjs[T_VOID+1] = { NULL /*, NULL...*/ };
100 Klass* Universe::_objectArrayKlassObj = NULL;
101 OopStorage* Universe::_vm_weak_oop_storage = NULL;
102 oop Universe::_int_mirror = NULL;
103 oop Universe::_float_mirror = NULL;
104 oop Universe::_double_mirror = NULL;
105 oop Universe::_byte_mirror = NULL;
106 oop Universe::_bool_mirror = NULL;
107 oop Universe::_char_mirror = NULL;
108 oop Universe::_long_mirror = NULL;
109 oop Universe::_short_mirror = NULL;
110 oop Universe::_void_mirror = NULL;
111 oop Universe::_mirrors[T_VOID+1] = { NULL /*, NULL...*/ };
112 oop Universe::_main_thread_group = NULL;
113 oop Universe::_system_thread_group = NULL;
114 objArrayOop Universe::_the_empty_class_klass_array = NULL;
115 Array<Klass*>* Universe::_the_array_interfaces_array = NULL;
116 oop Universe::_the_null_sentinel = NULL;
117 oop Universe::_the_null_string = NULL;
118 oop Universe::_the_min_jint_string = NULL;
119 LatestMethodCache* Universe::_finalizer_register_cache = NULL;
120 LatestMethodCache* Universe::_loader_addClass_cache = NULL;
121 LatestMethodCache* Universe::_pd_implies_cache = NULL;
673 return (void*)_non_oop_bits;
674 }
675
676 jint universe_init() {
677 assert(!Universe::_fully_initialized, "called after initialize_vtables");
678 guarantee(1 << LogHeapWordSize == sizeof(HeapWord),
679 "LogHeapWordSize is incorrect.");
680 guarantee(sizeof(oop) >= sizeof(HeapWord), "HeapWord larger than oop?");
681 guarantee(sizeof(oop) % sizeof(HeapWord) == 0,
682 "oop size is not not a multiple of HeapWord size");
683
684 TraceTime timer("Genesis", TRACETIME_LOG(Info, startuptime));
685
686 JavaClasses::compute_hard_coded_offsets();
687
688 jint status = Universe::initialize_heap();
689 if (status != JNI_OK) {
690 return status;
691 }
692
693 Universe::initialize_oop_storage();
694
695 Metaspace::global_initialize();
696
697 // Initialize performance counters for metaspaces
698 MetaspaceCounters::initialize_performance_counters();
699 CompressedClassSpaceCounters::initialize_performance_counters();
700
701 AOTLoader::universe_init();
702
703 // Checks 'AfterMemoryInit' constraints.
704 if (!CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterMemoryInit)) {
705 return JNI_EINVAL;
706 }
707
708 // Create memory for metadata. Must be after initializing heap for
709 // DumpSharedSpaces.
710 ClassLoaderData::init_null_class_loader_data();
711
712 // We have a heap so create the Method* caches before
713 // Metaspace::initialize_shared_spaces() tries to populate them.
714 Universe::_finalizer_register_cache = new LatestMethodCache();
1330 #ifndef PRODUCT
1331 else {
1332 // sharing initilization should have already set up _klass
1333 assert(_klass != NULL, "just checking");
1334 }
1335 #endif
1336
1337 _method_idnum = m->method_idnum();
1338 assert(_method_idnum >= 0, "sanity check");
1339 }
1340
1341
1342 Method* LatestMethodCache::get_method() {
1343 if (klass() == NULL) return NULL;
1344 InstanceKlass* ik = InstanceKlass::cast(klass());
1345 Method* m = ik->method_with_idnum(method_idnum());
1346 assert(m != NULL, "sanity check");
1347 return m;
1348 }
1349
1350 void Universe::initialize_oop_storage() {
1351 _vm_weak_oop_storage =
1352 new OopStorage("VM Weak Oop Handles",
1353 VMWeakAlloc_lock,
1354 VMWeakActive_lock);
1355 }
1356
1357 OopStorage* Universe::vm_weak_oop_storage() {
1358 assert(_vm_weak_oop_storage != NULL, "Uninitialized");
1359 return _vm_weak_oop_storage;
1360 }
1361
1362 #ifdef ASSERT
1363 // Release dummy object(s) at bottom of heap
1364 bool Universe::release_fullgc_alot_dummy() {
1365 MutexLocker ml(FullGCALot_lock);
1366 if (_fullgc_alot_dummy_array != NULL) {
1367 if (_fullgc_alot_dummy_next >= _fullgc_alot_dummy_array->length()) {
1368 // No more dummies to release, release entire array instead
1369 _fullgc_alot_dummy_array = NULL;
1370 return false;
1371 }
1372 if (!UseConcMarkSweepGC) {
1373 // Release dummy at bottom of old generation
1374 _fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
1375 }
1376 // Release dummy at bottom of permanent generation
1377 _fullgc_alot_dummy_array->obj_at_put(_fullgc_alot_dummy_next++, NULL);
1378 }
1379 return true;
1380 }
|