8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces
Summary: 1)Populate MetaspaceShared::_core_spaces_size early at mapping time; 2)Fix FileMapInfo::validate_shared_path_table to report failure properly; 3)Remove dead code in FileMapInfo::validate_shared_path_table.
Reviewed-by: iklam, ccheung
--- a/src/hotspot/share/memory/filemap.cpp Wed Nov 14 12:25:15 2018 -0800
+++ b/src/hotspot/share/memory/filemap.cpp Wed Nov 14 18:49:02 2018 -0500
@@ -287,6 +287,12 @@
" the shared archive file: %s", name);
}
}
+
+ if (PrintSharedArchiveAndExit && !ok) {
+ // If PrintSharedArchiveAndExit is enabled, don't report failure to the
+ // caller. Please see above comments for more details.
+ ok = true;
+ }
return ok;
}
@@ -479,16 +485,17 @@
if (i < module_paths_start_index) {
if (shared_path(i)->validate()) {
log_info(class, path)("ok");
+ } else {
+ assert(!UseSharedSpaces, "UseSharedSpaces should be disabled");
+ return false;
}
} else if (i >= module_paths_start_index) {
if (shared_path(i)->validate(false /* not a class path entry */)) {
log_info(class, path)("ok");
+ } else {
+ assert(!UseSharedSpaces, "UseSharedSpaces should be disabled");
+ return false;
}
- } else if (!PrintSharedArchiveAndExit) {
- _validating_shared_path_table = false;
- _shared_path_table = NULL;
- _shared_path_table_size = 0;
- return false;
}
}
--- a/src/hotspot/share/memory/metaspaceShared.cpp Wed Nov 14 12:25:15 2018 -0800
+++ b/src/hotspot/share/memory/metaspaceShared.cpp Wed Nov 14 18:49:02 2018 -0500
@@ -1919,6 +1919,7 @@
assert(ro_top == md_base, "must be");
assert(md_top == od_base, "must be");
+ _core_spaces_size = mapinfo->core_spaces_size();
MetaspaceObj::set_shared_metaspace_range((void*)mc_base, (void*)od_top);
return true;
} else {
@@ -1951,7 +1952,8 @@
FileMapInfo *mapinfo = FileMapInfo::current_info();
_cds_i2i_entry_code_buffers = mapinfo->cds_i2i_entry_code_buffers();
_cds_i2i_entry_code_buffers_size = mapinfo->cds_i2i_entry_code_buffers_size();
- _core_spaces_size = mapinfo->core_spaces_size();
+ // _core_spaces_size is loaded from the shared archive immediatelly after mapping
+ assert(_core_spaces_size == mapinfo->core_spaces_size(), "sanity");
char* buffer = mapinfo->misc_data_patching_start();
clone_cpp_vtables((intptr_t*)buffer);
--- a/src/hotspot/share/memory/metaspaceShared.hpp Wed Nov 14 12:25:15 2018 -0800
+++ b/src/hotspot/share/memory/metaspaceShared.hpp Wed Nov 14 18:49:02 2018 -0500
@@ -100,6 +100,8 @@
}
static void commit_shared_space_to(char* newtop) NOT_CDS_RETURN;
static size_t core_spaces_size() {
+ assert(DumpSharedSpaces || UseSharedSpaces, "sanity");
+ assert(_core_spaces_size != 0, "sanity");
return _core_spaces_size;
}
static void initialize_dumptime_shared_and_meta_spaces() NOT_CDS_RETURN;