mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-19 10:34:38 +02:00
8297290: Use int indices to reference CDS archived primitive mirrors
Reviewed-by: ccheung
This commit is contained in:
parent
37f613bad3
commit
c7a679fbdd
6 changed files with 76 additions and 52 deletions
|
@ -833,7 +833,7 @@ void HeapShared::write_subgraph_info_table() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void HeapShared::serialize(SerializeClosure* soc) {
|
void HeapShared::serialize_root(SerializeClosure* soc) {
|
||||||
oop roots_oop = NULL;
|
oop roots_oop = NULL;
|
||||||
|
|
||||||
if (soc->reading()) {
|
if (soc->reading()) {
|
||||||
|
@ -849,6 +849,9 @@ void HeapShared::serialize(SerializeClosure* soc) {
|
||||||
roots_oop = roots();
|
roots_oop = roots();
|
||||||
soc->do_oop(&roots_oop); // write to archive
|
soc->do_oop(&roots_oop); // write to archive
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeapShared::serialize_tables(SerializeClosure* soc) {
|
||||||
|
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
soc->do_ptr((void**)&_archived_ArchiveHeapTestClass);
|
soc->do_ptr((void**)&_archived_ArchiveHeapTestClass);
|
||||||
|
|
|
@ -410,7 +410,8 @@ private:
|
||||||
|
|
||||||
static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
|
static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
|
||||||
static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN;
|
static void write_subgraph_info_table() NOT_CDS_JAVA_HEAP_RETURN;
|
||||||
static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
|
static void serialize_root(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
|
||||||
|
static void serialize_tables(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;
|
||||||
static bool initialize_enum_klass(InstanceKlass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
|
static bool initialize_enum_klass(InstanceKlass* k, TRAPS) NOT_CDS_JAVA_HEAP_RETURN_(false);
|
||||||
|
|
||||||
// Returns the address of a heap object when it's mapped at the
|
// Returns the address of a heap object when it's mapped at the
|
||||||
|
|
|
@ -375,6 +375,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) {
|
||||||
|
|
||||||
// Dump/restore miscellaneous metadata.
|
// Dump/restore miscellaneous metadata.
|
||||||
JavaClasses::serialize_offsets(soc);
|
JavaClasses::serialize_offsets(soc);
|
||||||
|
HeapShared::serialize_root(soc);
|
||||||
Universe::serialize(soc);
|
Universe::serialize(soc);
|
||||||
soc->do_tag(--tag);
|
soc->do_tag(--tag);
|
||||||
|
|
||||||
|
@ -385,7 +386,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) {
|
||||||
// Dump/restore the symbol/string/subgraph_info tables
|
// Dump/restore the symbol/string/subgraph_info tables
|
||||||
SymbolTable::serialize_shared_table_header(soc);
|
SymbolTable::serialize_shared_table_header(soc);
|
||||||
StringTable::serialize_shared_table_header(soc);
|
StringTable::serialize_shared_table_header(soc);
|
||||||
HeapShared::serialize(soc);
|
HeapShared::serialize_tables(soc);
|
||||||
SystemDictionaryShared::serialize_dictionary_headers(soc);
|
SystemDictionaryShared::serialize_dictionary_headers(soc);
|
||||||
|
|
||||||
InstanceMirrorKlass::serialize_offsets(soc);
|
InstanceMirrorKlass::serialize_offsets(soc);
|
||||||
|
@ -1499,6 +1500,8 @@ void MetaspaceShared::initialize_shared_spaces() {
|
||||||
static_mapinfo->patch_heap_embedded_pointers();
|
static_mapinfo->patch_heap_embedded_pointers();
|
||||||
ArchiveHeapLoader::finish_initialization();
|
ArchiveHeapLoader::finish_initialization();
|
||||||
|
|
||||||
|
CDS_JAVA_HEAP_ONLY(Universe::update_archived_basic_type_mirrors());
|
||||||
|
|
||||||
// Close the mapinfo file
|
// Close the mapinfo file
|
||||||
static_mapinfo->close();
|
static_mapinfo->close();
|
||||||
|
|
||||||
|
|
|
@ -1122,8 +1122,9 @@ void java_lang_Class::archive_basic_type_mirrors() {
|
||||||
|
|
||||||
for (int t = T_BOOLEAN; t < T_VOID+1; t++) {
|
for (int t = T_BOOLEAN; t < T_VOID+1; t++) {
|
||||||
BasicType bt = (BasicType)t;
|
BasicType bt = (BasicType)t;
|
||||||
oop m = Universe::_mirrors[t].resolve();
|
if (!is_reference_type(bt)) {
|
||||||
if (m != NULL) {
|
oop m = Universe::java_mirror(bt);
|
||||||
|
assert(m != NULL, "sanity");
|
||||||
// Update the field at _array_klass_offset to point to the relocated array klass.
|
// Update the field at _array_klass_offset to point to the relocated array klass.
|
||||||
oop archived_m = HeapShared::archive_object(m);
|
oop archived_m = HeapShared::archive_object(m);
|
||||||
assert(archived_m != NULL, "sanity");
|
assert(archived_m != NULL, "sanity");
|
||||||
|
@ -1138,7 +1139,7 @@ void java_lang_Class::archive_basic_type_mirrors() {
|
||||||
"Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
|
"Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
|
||||||
type2name(bt), p2i(m), p2i(archived_m));
|
type2name(bt), p2i(m), p2i(archived_m));
|
||||||
|
|
||||||
Universe::replace_mirror(bt, archived_m);
|
Universe::set_archived_basic_type_mirror_index(bt, HeapShared::append_root(archived_m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,10 @@
|
||||||
Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL /*, NULL...*/ };
|
Klass* Universe::_typeArrayKlassObjs[T_LONG+1] = { NULL /*, NULL...*/ };
|
||||||
Klass* Universe::_objectArrayKlassObj = NULL;
|
Klass* Universe::_objectArrayKlassObj = NULL;
|
||||||
Klass* Universe::_fillerArrayKlassObj = NULL;
|
Klass* Universe::_fillerArrayKlassObj = NULL;
|
||||||
OopHandle Universe::_mirrors[T_VOID+1];
|
OopHandle Universe::_basic_type_mirrors[T_VOID+1];
|
||||||
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
|
int Universe::_archived_basic_type_mirror_indices[T_VOID+1];
|
||||||
|
#endif
|
||||||
|
|
||||||
OopHandle Universe::_main_thread_group;
|
OopHandle Universe::_main_thread_group;
|
||||||
OopHandle Universe::_system_thread_group;
|
OopHandle Universe::_system_thread_group;
|
||||||
|
@ -180,24 +183,20 @@ oop Universe::virtual_machine_error_instance() { return _virtual_machine_erro
|
||||||
|
|
||||||
oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); }
|
oop Universe::the_null_sentinel() { return _the_null_sentinel.resolve(); }
|
||||||
|
|
||||||
oop Universe::int_mirror() { return check_mirror(_mirrors[T_INT].resolve()); }
|
oop Universe::int_mirror() { return check_mirror(_basic_type_mirrors[T_INT].resolve()); }
|
||||||
oop Universe::float_mirror() { return check_mirror(_mirrors[T_FLOAT].resolve()); }
|
oop Universe::float_mirror() { return check_mirror(_basic_type_mirrors[T_FLOAT].resolve()); }
|
||||||
oop Universe::double_mirror() { return check_mirror(_mirrors[T_DOUBLE].resolve()); }
|
oop Universe::double_mirror() { return check_mirror(_basic_type_mirrors[T_DOUBLE].resolve()); }
|
||||||
oop Universe::byte_mirror() { return check_mirror(_mirrors[T_BYTE].resolve()); }
|
oop Universe::byte_mirror() { return check_mirror(_basic_type_mirrors[T_BYTE].resolve()); }
|
||||||
oop Universe::bool_mirror() { return check_mirror(_mirrors[T_BOOLEAN].resolve()); }
|
oop Universe::bool_mirror() { return check_mirror(_basic_type_mirrors[T_BOOLEAN].resolve()); }
|
||||||
oop Universe::char_mirror() { return check_mirror(_mirrors[T_CHAR].resolve()); }
|
oop Universe::char_mirror() { return check_mirror(_basic_type_mirrors[T_CHAR].resolve()); }
|
||||||
oop Universe::long_mirror() { return check_mirror(_mirrors[T_LONG].resolve()); }
|
oop Universe::long_mirror() { return check_mirror(_basic_type_mirrors[T_LONG].resolve()); }
|
||||||
oop Universe::short_mirror() { return check_mirror(_mirrors[T_SHORT].resolve()); }
|
oop Universe::short_mirror() { return check_mirror(_basic_type_mirrors[T_SHORT].resolve()); }
|
||||||
oop Universe::void_mirror() { return check_mirror(_mirrors[T_VOID].resolve()); }
|
oop Universe::void_mirror() { return check_mirror(_basic_type_mirrors[T_VOID].resolve()); }
|
||||||
|
|
||||||
oop Universe::java_mirror(BasicType t) {
|
oop Universe::java_mirror(BasicType t) {
|
||||||
assert((uint)t < T_VOID+1, "range check");
|
assert((uint)t < T_VOID+1, "range check");
|
||||||
return check_mirror(_mirrors[t].resolve());
|
assert(!is_reference_type(t), "sanity");
|
||||||
}
|
return check_mirror(_basic_type_mirrors[t].resolve());
|
||||||
|
|
||||||
// Used by CDS dumping
|
|
||||||
void Universe::replace_mirror(BasicType t, oop new_mirror) {
|
|
||||||
Universe::_mirrors[t].replace(new_mirror);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Universe::basic_type_classes_do(KlassClosure *closure) {
|
void Universe::basic_type_classes_do(KlassClosure *closure) {
|
||||||
|
@ -236,29 +235,35 @@ void Universe::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||||
_do_stack_walk_cache->metaspace_pointers_do(it);
|
_do_stack_walk_cache->metaspace_pointers_do(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize metadata and pointers to primitive type mirrors in and out of CDS archive
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
|
void Universe::set_archived_basic_type_mirror_index(BasicType t, int index) {
|
||||||
|
assert(DumpSharedSpaces, "dump-time only");
|
||||||
|
assert(!is_reference_type(t), "sanity");
|
||||||
|
_archived_basic_type_mirror_indices[t] = index;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Universe::update_archived_basic_type_mirrors() {
|
||||||
|
if (ArchiveHeapLoader::are_archived_mirrors_available()) {
|
||||||
|
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||||
|
int index = _archived_basic_type_mirror_indices[i];
|
||||||
|
if (!is_reference_type((BasicType)i) && index >= 0) {
|
||||||
|
oop mirror_oop = HeapShared::get_root(index);
|
||||||
|
assert(mirror_oop != NULL, "must be");
|
||||||
|
_basic_type_mirrors[i] = OopHandle(vm_global(), mirror_oop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Universe::serialize(SerializeClosure* f) {
|
void Universe::serialize(SerializeClosure* f) {
|
||||||
|
|
||||||
#if INCLUDE_CDS_JAVA_HEAP
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
{
|
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||||
oop mirror_oop;
|
f->do_u4((u4*)&_archived_basic_type_mirror_indices[i]);
|
||||||
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
// if f->reading(): We can't call HeapShared::get_root() yet, as the heap
|
||||||
if (f->reading()) {
|
// contents may need to be relocated. _basic_type_mirrors[i] will be
|
||||||
f->do_oop(&mirror_oop); // read from archive
|
// updated later in Universe::update_archived_basic_type_mirrors().
|
||||||
assert(oopDesc::is_oop_or_null(mirror_oop), "is oop");
|
|
||||||
// Only create an OopHandle for non-null mirrors
|
|
||||||
if (mirror_oop != NULL) {
|
|
||||||
_mirrors[i] = OopHandle(vm_global(), mirror_oop);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (HeapShared::can_write()) {
|
|
||||||
mirror_oop = _mirrors[i].resolve();
|
|
||||||
} else {
|
|
||||||
mirror_oop = NULL;
|
|
||||||
}
|
|
||||||
f->do_oop(&mirror_oop); // write to archive
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -450,26 +455,27 @@ void Universe::initialize_basic_type_mirrors(TRAPS) {
|
||||||
#if INCLUDE_CDS_JAVA_HEAP
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
if (UseSharedSpaces &&
|
if (UseSharedSpaces &&
|
||||||
ArchiveHeapLoader::are_archived_mirrors_available() &&
|
ArchiveHeapLoader::are_archived_mirrors_available() &&
|
||||||
_mirrors[T_INT].resolve() != NULL) {
|
_basic_type_mirrors[T_INT].resolve() != NULL) {
|
||||||
assert(ArchiveHeapLoader::can_use(), "Sanity");
|
assert(ArchiveHeapLoader::can_use(), "Sanity");
|
||||||
|
|
||||||
// check that all mirrors are mapped also
|
// check that all basic type mirrors are mapped also
|
||||||
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||||
if (!is_reference_type((BasicType)i)) {
|
if (!is_reference_type((BasicType)i)) {
|
||||||
oop m = _mirrors[i].resolve();
|
oop m = _basic_type_mirrors[i].resolve();
|
||||||
assert(m != NULL, "archived mirrors should not be NULL");
|
assert(m != NULL, "archived mirrors should not be NULL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
// _mirror[T_INT} could be NULL if archived heap is not mapped.
|
// _basic_type_mirrors[T_INT], etc, are NULL if archived heap is not mapped.
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
|
||||||
BasicType bt = (BasicType)i;
|
BasicType bt = (BasicType)i;
|
||||||
if (!is_reference_type(bt)) {
|
if (!is_reference_type(bt)) {
|
||||||
oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK);
|
oop m = java_lang_Class::create_basic_type_mirror(type2name(bt), bt, CHECK);
|
||||||
_mirrors[i] = OopHandle(vm_global(), m);
|
_basic_type_mirrors[i] = OopHandle(vm_global(), m);
|
||||||
}
|
}
|
||||||
|
CDS_JAVA_HEAP_ONLY(_archived_basic_type_mirror_indices[i] = -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,16 @@ class Universe: AllStatic {
|
||||||
static uintptr_t _verify_oop_mask;
|
static uintptr_t _verify_oop_mask;
|
||||||
static uintptr_t _verify_oop_bits;
|
static uintptr_t _verify_oop_bits;
|
||||||
|
|
||||||
|
// Table of primitive type mirrors, excluding T_OBJECT and T_ARRAY
|
||||||
|
// but including T_VOID, hence the index including T_VOID
|
||||||
|
static OopHandle _basic_type_mirrors[T_VOID+1];
|
||||||
|
|
||||||
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
|
// Each slot i stores an index that can be used to restore _basic_type_mirrors[i]
|
||||||
|
// from the archive heap using HeapShared::get_root(int)
|
||||||
|
static int _archived_basic_type_mirror_indices[T_VOID+1];
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) PRODUCT_RETURN;
|
static void calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) PRODUCT_RETURN;
|
||||||
|
|
||||||
|
@ -231,12 +241,12 @@ class Universe: AllStatic {
|
||||||
static oop short_mirror();
|
static oop short_mirror();
|
||||||
static oop void_mirror();
|
static oop void_mirror();
|
||||||
|
|
||||||
// Table of primitive type mirrors, excluding T_OBJECT and T_ARRAY
|
|
||||||
// but including T_VOID, hence the index including T_VOID
|
|
||||||
static OopHandle _mirrors[T_VOID+1];
|
|
||||||
|
|
||||||
static oop java_mirror(BasicType t);
|
static oop java_mirror(BasicType t);
|
||||||
static void replace_mirror(BasicType t, oop obj);
|
|
||||||
|
#if INCLUDE_CDS_JAVA_HEAP
|
||||||
|
static void set_archived_basic_type_mirror_index(BasicType t, int index);
|
||||||
|
static void update_archived_basic_type_mirrors();
|
||||||
|
#endif
|
||||||
|
|
||||||
static oop main_thread_group();
|
static oop main_thread_group();
|
||||||
static void set_main_thread_group(oop group);
|
static void set_main_thread_group(oop group);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue