88
88
#include " utilities/ostream.hpp"
89
89
#include " utilities/preserveException.hpp"
90
90
91
- #define PRIMITIVE_MIRRORS_DO (func ) \
92
- func (_int_mirror) \
93
- func(_float_mirror) \
94
- func(_double_mirror) \
95
- func(_byte_mirror) \
96
- func(_bool_mirror) \
97
- func(_char_mirror) \
98
- func(_long_mirror) \
99
- func(_short_mirror) \
100
- func(_void_mirror)
101
-
102
- #define DEFINE_PRIMITIVE_MIRROR (m ) \
103
- oop Universe::m = NULL ;
104
-
105
91
// Known objects
106
- PRIMITIVE_MIRRORS_DO (DEFINE_PRIMITIVE_MIRROR)
107
92
Klass* Universe::_typeArrayKlassObjs[T_LONG+1 ] = { NULL /* , NULL...*/ };
108
93
Klass* Universe::_objectArrayKlassObj = NULL ;
109
- oop Universe::_mirrors[T_VOID+1 ] = { NULL /* , NULL... */ } ;
94
+ OopHandle Universe::_mirrors[T_VOID+1 ];
110
95
111
96
OopHandle Universe::_main_thread_group;
112
97
OopHandle Universe::_system_thread_group;
@@ -197,6 +182,35 @@ oop Universe::virtual_machine_error_instance() { return _virtual_machine_erro
197
182
198
183
oop Universe::the_null_sentinel () { return _the_null_sentinel.resolve (); }
199
184
185
+ oop Universe::int_mirror () { return check_mirror (_mirrors[T_INT].resolve ()); }
186
+ oop Universe::float_mirror () { return check_mirror (_mirrors[T_FLOAT].resolve ()); }
187
+ oop Universe::double_mirror () { return check_mirror (_mirrors[T_DOUBLE].resolve ()); }
188
+ oop Universe::byte_mirror () { return check_mirror (_mirrors[T_BYTE].resolve ()); }
189
+ oop Universe::bool_mirror () { return check_mirror (_mirrors[T_BOOLEAN].resolve ()); }
190
+ oop Universe::char_mirror () { return check_mirror (_mirrors[T_CHAR].resolve ()); }
191
+ oop Universe::long_mirror () { return check_mirror (_mirrors[T_LONG].resolve ()); }
192
+ oop Universe::short_mirror () { return check_mirror (_mirrors[T_SHORT].resolve ()); }
193
+ oop Universe::void_mirror () { return check_mirror (_mirrors[T_VOID].resolve ()); }
194
+
195
+ oop Universe::java_mirror (BasicType t) {
196
+ assert ((uint )t < T_VOID+1 , " range check" );
197
+ return check_mirror (_mirrors[t].resolve ());
198
+ }
199
+
200
+ // Used by CDS dumping
201
+ void Universe::replace_mirror (BasicType t, oop new_mirror) {
202
+ Universe::_mirrors[t].replace (new_mirror);
203
+ }
204
+
205
+ // Not sure why CDS has to do this
206
+ void Universe::clear_basic_type_mirrors () {
207
+ for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
208
+ if (!is_reference_type ((BasicType)i)) {
209
+ Universe::_mirrors[i].replace (NULL );
210
+ }
211
+ }
212
+ }
213
+
200
214
void Universe::basic_type_classes_do (void f (Klass*)) {
201
215
for (int i = T_BOOLEAN; i < T_LONG+1 ; i++) {
202
216
f (_typeArrayKlassObjs[i]);
@@ -209,16 +223,7 @@ void Universe::basic_type_classes_do(KlassClosure *closure) {
209
223
}
210
224
}
211
225
212
- #define DO_PRIMITIVE_MIRROR (m ) \
213
- f->do_oop ((oop*) &m);
214
-
215
226
void Universe::oops_do (OopClosure* f) {
216
- PRIMITIVE_MIRRORS_DO (DO_PRIMITIVE_MIRROR);
217
-
218
- for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
219
- f->do_oop (&_mirrors[i]);
220
- }
221
- assert (_mirrors[0 ] == NULL && _mirrors[T_BOOLEAN - 1 ] == NULL , " checking" );
222
227
223
228
f->do_oop (&_reference_pending_list);
224
229
ThreadsSMRSupport::exiting_threads_oops_do (f);
@@ -248,29 +253,36 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
248
253
_do_stack_walk_cache->metaspace_pointers_do (it);
249
254
}
250
255
251
- #define ASSERT_MIRROR_NULL (m ) \
252
- assert (m == NULL , " archived mirrors should be NULL" );
253
-
254
- #define SERIALIZE_MIRROR (m ) \
255
- f->do_oop (&m); \
256
- if (m != NULL ) { java_lang_Class::update_archived_primitive_mirror_native_pointers (m); }
257
-
258
256
// Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
259
257
void Universe::serialize (SerializeClosure* f) {
260
258
259
+ #if INCLUDE_CDS_JAVA_HEAP
260
+ {
261
+ oop mirror_oop;
262
+ for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
263
+ if (f->reading ()) {
264
+ f->do_oop (&mirror_oop); // read from archive
265
+ assert (oopDesc::is_oop_or_null (mirror_oop), " is oop" );
266
+ // Only create an OopHandle for non-null mirrors
267
+ if (mirror_oop != NULL ) {
268
+ _mirrors[i] = OopHandle (vm_global (), mirror_oop);
269
+ }
270
+ } else {
271
+ mirror_oop = _mirrors[i].resolve ();
272
+ f->do_oop (&mirror_oop); // write to archive
273
+ }
274
+ if (mirror_oop != NULL ) { // may be null if archived heap is disabled
275
+ java_lang_Class::update_archived_primitive_mirror_native_pointers (mirror_oop);
276
+ }
277
+ }
278
+ }
279
+ #endif
280
+
261
281
for (int i = 0 ; i < T_LONG+1 ; i++) {
262
282
f->do_ptr ((void **)&_typeArrayKlassObjs[i]);
263
283
}
264
284
265
285
f->do_ptr ((void **)&_objectArrayKlassObj);
266
-
267
- #if INCLUDE_CDS_JAVA_HEAP
268
- DEBUG_ONLY (if (DumpSharedSpaces && !HeapShared::is_heap_object_archiving_allowed ()) {
269
- PRIMITIVE_MIRRORS_DO (ASSERT_MIRROR_NULL);
270
- });
271
- PRIMITIVE_MIRRORS_DO (SERIALIZE_MIRROR);
272
- #endif
273
-
274
286
f->do_ptr ((void **)&_the_array_interfaces_array);
275
287
f->do_ptr ((void **)&_the_empty_int_array);
276
288
f->do_ptr ((void **)&_the_empty_short_array);
@@ -284,6 +296,7 @@ void Universe::serialize(SerializeClosure* f) {
284
296
_do_stack_walk_cache->serialize (f);
285
297
}
286
298
299
+
287
300
void Universe::check_alignment (uintx size, uintx alignment, const char * name) {
288
301
if (size < alignment || size % alignment != 0 ) {
289
302
vm_exit_during_initialization (
@@ -435,51 +448,32 @@ void Universe::genesis(TRAPS) {
435
448
#endif
436
449
}
437
450
438
- #define ASSERT_MIRROR_NOT_NULL (m ) \
439
- assert (m != NULL , " archived mirrors should not be NULL" );
440
-
441
451
void Universe::initialize_basic_type_mirrors (TRAPS) {
442
452
#if INCLUDE_CDS_JAVA_HEAP
443
453
if (UseSharedSpaces &&
444
454
HeapShared::open_archive_heap_region_mapped () &&
445
- _int_mirror != NULL ) {
455
+ _mirrors[T_INT]. resolve () != NULL ) {
446
456
assert (HeapShared::is_heap_object_archiving_allowed (), " Sanity" );
447
- PRIMITIVE_MIRRORS_DO (ASSERT_MIRROR_NOT_NULL);
457
+
458
+ // check that all mirrors are mapped also
459
+ for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
460
+ if (!is_reference_type ((BasicType)i)) {
461
+ oop m = _mirrors[i].resolve ();
462
+ assert (m != NULL , " archived mirrors should not be NULL" );
463
+ }
464
+ }
448
465
} else
449
- // _int_mirror could be NULL if archived heap is not mapped.
466
+ // _mirror[T_INT} could be NULL if archived heap is not mapped.
450
467
#endif
451
468
{
452
- _int_mirror =
453
- java_lang_Class::create_basic_type_mirror (" int" , T_INT, CHECK);
454
- _float_mirror =
455
- java_lang_Class::create_basic_type_mirror (" float" , T_FLOAT, CHECK);
456
- _double_mirror =
457
- java_lang_Class::create_basic_type_mirror (" double" , T_DOUBLE, CHECK);
458
- _byte_mirror =
459
- java_lang_Class::create_basic_type_mirror (" byte" , T_BYTE, CHECK);
460
- _bool_mirror =
461
- java_lang_Class::create_basic_type_mirror (" boolean" ,T_BOOLEAN, CHECK);
462
- _char_mirror =
463
- java_lang_Class::create_basic_type_mirror (" char" , T_CHAR, CHECK);
464
- _long_mirror =
465
- java_lang_Class::create_basic_type_mirror (" long" , T_LONG, CHECK);
466
- _short_mirror =
467
- java_lang_Class::create_basic_type_mirror (" short" , T_SHORT, CHECK);
468
- _void_mirror =
469
- java_lang_Class::create_basic_type_mirror (" void" , T_VOID, CHECK);
469
+ for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
470
+ BasicType bt = (BasicType)i;
471
+ if (!is_reference_type (bt)) {
472
+ oop m = java_lang_Class::create_basic_type_mirror (type2name (bt), bt, CHECK);
473
+ _mirrors[i] = OopHandle (vm_global (), m);
474
+ }
475
+ }
470
476
}
471
-
472
- _mirrors[T_INT] = _int_mirror;
473
- _mirrors[T_FLOAT] = _float_mirror;
474
- _mirrors[T_DOUBLE] = _double_mirror;
475
- _mirrors[T_BYTE] = _byte_mirror;
476
- _mirrors[T_BOOLEAN] = _bool_mirror;
477
- _mirrors[T_CHAR] = _char_mirror;
478
- _mirrors[T_LONG] = _long_mirror;
479
- _mirrors[T_SHORT] = _short_mirror;
480
- _mirrors[T_VOID] = _void_mirror;
481
- // _mirrors[T_OBJECT] = _object_klass->java_mirror();
482
- // _mirrors[T_ARRAY] = _object_klass->java_mirror();
483
477
}
484
478
485
479
void Universe::fixup_mirrors (TRAPS) {
0 commit comments