|
88 | 88 | Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL /*, NULL...*/ }; |
89 | 89 | Klass* Universe::_objectArrayKlassObj = NULL; |
90 | 90 | Klass* Universe::_fillerArrayKlassObj = NULL; |
91 | | -OopHandle Universe::_mirrors[T_VOID+1]; |
| 91 | +OopHandle Universe::_basic_type_mirrors[T_VOID+1]; |
| 92 | +#if INCLUDE_CDS_JAVA_HEAP |
| 93 | +int Universe::_archived_basic_type_mirror_indices[T_VOID+1]; |
| 94 | +#endif |
92 | 95 |
|
93 | 96 | OopHandle Universe::_main_thread_group; |
94 | 97 | OopHandle Universe::_system_thread_group; |
@@ -180,24 +183,20 @@ oop Universe::virtual_machine_error_instance() { return _virtual_machine_erro |
180 | 183 |
|
181 | 184 | oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); } |
182 | 185 |
|
183 | | -oop Universe::int_mirror() { return check_mirror(_mirrors[T_INT].resolve()); } |
184 | | -oop Universe::float_mirror() { return check_mirror(_mirrors[T_FLOAT].resolve()); } |
185 | | -oop Universe::double_mirror() { return check_mirror(_mirrors[T_DOUBLE].resolve()); } |
186 | | -oop Universe::byte_mirror() { return check_mirror(_mirrors[T_BYTE].resolve()); } |
187 | | -oop Universe::bool_mirror() { return check_mirror(_mirrors[T_BOOLEAN].resolve()); } |
188 | | -oop Universe::char_mirror() { return check_mirror(_mirrors[T_CHAR].resolve()); } |
189 | | -oop Universe::long_mirror() { return check_mirror(_mirrors[T_LONG].resolve()); } |
190 | | -oop Universe::short_mirror() { return check_mirror(_mirrors[T_SHORT].resolve()); } |
191 | | -oop Universe::void_mirror() { return check_mirror(_mirrors[T_VOID].resolve()); } |
| 186 | +oop Universe::int_mirror() { return check_mirror(_basic_type_mirrors[T_INT].resolve()); } |
| 187 | +oop Universe::float_mirror() { return check_mirror(_basic_type_mirrors[T_FLOAT].resolve()); } |
| 188 | +oop Universe::double_mirror() { return check_mirror(_basic_type_mirrors[T_DOUBLE].resolve()); } |
| 189 | +oop Universe::byte_mirror() { return check_mirror(_basic_type_mirrors[T_BYTE].resolve()); } |
| 190 | +oop Universe::bool_mirror() { return check_mirror(_basic_type_mirrors[T_BOOLEAN].resolve()); } |
| 191 | +oop Universe::char_mirror() { return check_mirror(_basic_type_mirrors[T_CHAR].resolve()); } |
| 192 | +oop Universe::long_mirror() { return check_mirror(_basic_type_mirrors[T_LONG].resolve()); } |
| 193 | +oop Universe::short_mirror() { return check_mirror(_basic_type_mirrors[T_SHORT].resolve()); } |
| 194 | +oop Universe::void_mirror() { return check_mirror(_basic_type_mirrors[T_VOID].resolve()); } |
192 | 195 |
|
193 | 196 | oop Universe::java_mirror(BasicType t) { |
194 | 197 | assert((uint)t < T_VOID+1, "range check"); |
195 | | - return check_mirror(_mirrors[t].resolve()); |
196 | | -} |
197 | | - |
198 | | -// Used by CDS dumping |
199 | | -void Universe::replace_mirror(BasicType t, oop new_mirror) { |
200 | | - Universe::_mirrors[t].replace(new_mirror); |
| 198 | + assert(!is_reference_type(t), "sanity"); |
| 199 | + return check_mirror(_basic_type_mirrors[t].resolve()); |
201 | 200 | } |
202 | 201 |
|
203 | 202 | void Universe::basic_type_classes_do(KlassClosure *closure) { |
@@ -236,30 +235,36 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) { |
236 | 235 | _do_stack_walk_cache->metaspace_pointers_do(it); |
237 | 236 | } |
238 | 237 |
|
239 | | -// Serialize metadata and pointers to primitive type mirrors in and out of CDS archive |
240 | | -void Universe::serialize(SerializeClosure* f) { |
241 | | - |
242 | 238 | #if INCLUDE_CDS_JAVA_HEAP |
243 | | - { |
244 | | - oop mirror_oop; |
| 239 | +void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) { |
| 240 | + assert(DumpSharedSpaces, "dump-time only"); |
| 241 | + assert(!is_reference_type(t), "sanity"); |
| 242 | + _archived_basic_type_mirror_indices[t] = index; |
| 243 | +} |
| 244 | + |
| 245 | +void Universe::update_archived_basic_type_mirrors() { |
| 246 | + if (ArchiveHeapLoader::are_archived_mirrors_available()) { |
245 | 247 | for (int i = T_BOOLEAN; i < T_VOID+1; i++) { |
246 | | - if (f->reading()) { |
247 | | - f->do_oop(&mirror_oop); // read from archive |
248 | | - assert(oopDesc::is_oop_or_null(mirror_oop), "is oop"); |
249 | | - // Only create an OopHandle for non-null mirrors |
250 | | - if (mirror_oop != NULL) { |
251 | | - _mirrors[i] = OopHandle(vm_global(), mirror_oop); |
252 | | - } |
253 | | - } else { |
254 | | - if (HeapShared::can_write()) { |
255 | | - mirror_oop = _mirrors[i].resolve(); |
256 | | - } else { |
257 | | - mirror_oop = NULL; |
258 | | - } |
259 | | - f->do_oop(&mirror_oop); // write to archive |
| 248 | + int index = _archived_basic_type_mirror_indices[i]; |
| 249 | + if (!is_reference_type((BasicType)i) && index >= 0) { |
| 250 | + oop mirror_oop = HeapShared::get_root(index); |
| 251 | + assert(mirror_oop != NULL, "must be"); |
| 252 | + _basic_type_mirrors[i] = OopHandle(vm_global(), mirror_oop); |
260 | 253 | } |
261 | 254 | } |
262 | 255 | } |
| 256 | +} |
| 257 | +#endif |
| 258 | + |
| 259 | +void Universe::serialize(SerializeClosure* f) { |
| 260 | + |
| 261 | +#if INCLUDE_CDS_JAVA_HEAP |
| 262 | + for (int i = T_BOOLEAN; i < T_VOID+1; i++) { |
| 263 | + f->do_u4((u4*)&_archived_basic_type_mirror_indices[i]); |
| 264 | + // if f->reading(): We can't call HeapShared::get_root() yet, as the heap |
| 265 | + // contents may need to be relocated. _basic_type_mirrors[i] will be |
| 266 | + // updated later in Universe::update_archived_basic_type_mirrors(). |
| 267 | + } |
263 | 268 | #endif |
264 | 269 |
|
265 | 270 | f->do_ptr((void**)&_fillerArrayKlassObj); |
@@ -450,26 +455,27 @@ void Universe::initialize_basic_type_mirrors(TRAPS) { |
450 | 455 | #if INCLUDE_CDS_JAVA_HEAP |
451 | 456 | if (UseSharedSpaces && |
452 | 457 | ArchiveHeapLoader::are_archived_mirrors_available() && |
453 | | - _mirrors[T_INT].resolve() != NULL) { |
| 458 | + _basic_type_mirrors[T_INT].resolve() != NULL) { |
454 | 459 | assert(ArchiveHeapLoader::can_use(), "Sanity"); |
455 | 460 |
|
456 | | - // check that all mirrors are mapped also |
| 461 | + // check that all basic type mirrors are mapped also |
457 | 462 | for (int i = T_BOOLEAN; i < T_VOID+1; i++) { |
458 | 463 | if (!is_reference_type((BasicType)i)) { |
459 | | - oop m = _mirrors[i].resolve(); |
| 464 | + oop m = _basic_type_mirrors[i].resolve(); |
460 | 465 | assert(m != NULL, "archived mirrors should not be NULL"); |
461 | 466 | } |
462 | 467 | } |
463 | 468 | } else |
464 | | - // _mirror[T_INT} could be NULL if archived heap is not mapped. |
| 469 | + // _basic_type_mirrors[T_INT], etc, are NULL if archived heap is not mapped. |
465 | 470 | #endif |
466 | 471 | { |
467 | 472 | for (int i = T_BOOLEAN; i < T_VOID+1; i++) { |
468 | 473 | BasicType bt = (BasicType)i; |
469 | 474 | if (!is_reference_type(bt)) { |
470 | 475 | oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK); |
471 | | - _mirrors[i] = OopHandle(vm_global(), m); |
| 476 | + _basic_type_mirrors[i] = OopHandle(vm_global(), m); |
472 | 477 | } |
| 478 | + CDS_JAVA_HEAP_ONLY(_archived_basic_type_mirror_indices[i] = -1); |
473 | 479 | } |
474 | 480 | } |
475 | 481 | } |
|
0 commit comments