8213713: Minor issues during MetaspaceShared::initialize_runtime_shared_and_meta_spaces

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
This commit is contained in:
Jiangli Zhou 2018-11-14 18:49:02 -05:00
parent d7d4bc9fdd
commit f049167354
3 changed files with 17 additions and 6 deletions

View file

@ -287,6 +287,12 @@ bool SharedClassPathEntry::validate(bool is_class_path) {
" the shared archive file: %s", name); " 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; return ok;
} }
@ -479,16 +485,17 @@ bool FileMapInfo::validate_shared_path_table() {
if (i < module_paths_start_index) { if (i < module_paths_start_index) {
if (shared_path(i)->validate()) { if (shared_path(i)->validate()) {
log_info(class, path)("ok"); log_info(class, path)("ok");
} else {
assert(!UseSharedSpaces, "UseSharedSpaces should be disabled");
return false;
} }
} else if (i >= module_paths_start_index) { } else if (i >= module_paths_start_index) {
if (shared_path(i)->validate(false /* not a class path entry */)) { if (shared_path(i)->validate(false /* not a class path entry */)) {
log_info(class, path)("ok"); 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;
} }
} }

View file

@ -1919,6 +1919,7 @@ bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) {
assert(ro_top == md_base, "must be"); assert(ro_top == md_base, "must be");
assert(md_top == od_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); MetaspaceObj::set_shared_metaspace_range((void*)mc_base, (void*)od_top);
return true; return true;
} else { } else {
@ -1951,7 +1952,8 @@ void MetaspaceShared::initialize_shared_spaces() {
FileMapInfo *mapinfo = FileMapInfo::current_info(); FileMapInfo *mapinfo = FileMapInfo::current_info();
_cds_i2i_entry_code_buffers = mapinfo->cds_i2i_entry_code_buffers(); _cds_i2i_entry_code_buffers = mapinfo->cds_i2i_entry_code_buffers();
_cds_i2i_entry_code_buffers_size = mapinfo->cds_i2i_entry_code_buffers_size(); _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(); char* buffer = mapinfo->misc_data_patching_start();
clone_cpp_vtables((intptr_t*)buffer); clone_cpp_vtables((intptr_t*)buffer);

View file

@ -100,6 +100,8 @@ class MetaspaceShared : AllStatic {
} }
static void commit_shared_space_to(char* newtop) NOT_CDS_RETURN; static void commit_shared_space_to(char* newtop) NOT_CDS_RETURN;
static size_t core_spaces_size() { static size_t core_spaces_size() {
assert(DumpSharedSpaces || UseSharedSpaces, "sanity");
assert(_core_spaces_size != 0, "sanity");
return _core_spaces_size; return _core_spaces_size;
} }
static void initialize_dumptime_shared_and_meta_spaces() NOT_CDS_RETURN; static void initialize_dumptime_shared_and_meta_spaces() NOT_CDS_RETURN;