< prev index next >
src/hotspot/share/classfile/javaClasses.cpp
Print this page
*** 1049,1059 ****
oop archived_m = HeapShared::archive_heap_object(m, THREAD);
assert(archived_m != NULL, "sanity");
Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
assert(ak != NULL || t == T_VOID, "should not be NULL");
if (ak != NULL) {
! Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak);
archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
}
// Clear the fields. Just to be safe
Klass *k = m->klass();
--- 1049,1059 ----
oop archived_m = HeapShared::archive_heap_object(m, THREAD);
assert(archived_m != NULL, "sanity");
Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
assert(ak != NULL || t == T_VOID, "should not be NULL");
if (ak != NULL) {
! Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak, true);
archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
}
// Clear the fields. Just to be safe
Klass *k = m->klass();
*** 1194,1222 ****
set_module(archived_mirror, NULL);
// The archived mirror's field at _klass_offset is still pointing to the original
// klass. Updated the field in the archived mirror to point to the relocated
// klass in the archive.
! Klass *reloc_k = MetaspaceShared::get_relocated_klass(as_Klass(mirror));
log_debug(cds, heap, mirror)(
"Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
p2i(as_Klass(mirror)), p2i(reloc_k));
archived_mirror->metadata_field_put(_klass_offset, reloc_k);
// The field at _array_klass_offset is pointing to the original one dimension
// higher array klass if exists. Relocate the pointer.
Klass *arr = array_klass_acquire(mirror);
if (arr != NULL) {
! Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr);
log_debug(cds, heap, mirror)(
"Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
p2i(arr), p2i(reloc_arr));
archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
}
return archived_mirror;
}
// Returns true if the mirror is updated, false if no archived mirror
// data is present. After the archived mirror object is restored, the
// shared klass' _has_raw_archived_mirror flag is cleared.
bool java_lang_Class::restore_archived_mirror(Klass *k,
Handle class_loader, Handle module,
--- 1194,1235 ----
set_module(archived_mirror, NULL);
// The archived mirror's field at _klass_offset is still pointing to the original
// klass. Updated the field in the archived mirror to point to the relocated
// klass in the archive.
! Klass *reloc_k = MetaspaceShared::get_relocated_klass(as_Klass(mirror), true);
log_debug(cds, heap, mirror)(
"Relocate mirror metadata field at _klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
p2i(as_Klass(mirror)), p2i(reloc_k));
archived_mirror->metadata_field_put(_klass_offset, reloc_k);
// The field at _array_klass_offset is pointing to the original one dimension
// higher array klass if exists. Relocate the pointer.
Klass *arr = array_klass_acquire(mirror);
if (arr != NULL) {
! Klass *reloc_arr = MetaspaceShared::get_relocated_klass(arr, true);
log_debug(cds, heap, mirror)(
"Relocate mirror metadata field at _array_klass_offset from " PTR_FORMAT " ==> " PTR_FORMAT,
p2i(arr), p2i(reloc_arr));
archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr);
}
return archived_mirror;
}
+ void java_lang_Class::update_archived_mirror_native_pointers(oop archived_mirror) {
+ Klass* k = ((Klass*)archived_mirror->metadata_field(_klass_offset));
+ if (k != NULL) { // k is NULL for the primitive classes such as java.lang.Byte::TYPE
+ archived_mirror->metadata_field_put(_klass_offset, (Klass*)(address(k) + MetaspaceShared::mapping_delta()));
+ }
+
+ Klass* ak = ((Klass*)archived_mirror->metadata_field(_array_klass_offset));
+ if (ak != NULL) {
+ archived_mirror->metadata_field_put(_array_klass_offset, (Klass*)(address(ak) + MetaspaceShared::mapping_delta()));
+ }
+ }
+
+
// Returns true if the mirror is updated, false if no archived mirror
// data is present. After the archived mirror object is restored, the
// shared klass' _has_raw_archived_mirror flag is cleared.
bool java_lang_Class::restore_archived_mirror(Klass *k,
Handle class_loader, Handle module,
*** 1234,1243 ****
--- 1247,1257 ----
if (m == NULL) {
return false;
}
log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m));
+ update_archived_mirror_native_pointers(m);
// mirror is archived, restore
assert(HeapShared::is_archived_object(m), "must be archived mirror object");
Handle mirror(THREAD, m);
< prev index next >