src/hotspot/share/memory/filemap.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/hotspot/share/memory/filemap.cpp Mon Apr 9 15:33:05 2018
--- new/src/hotspot/share/memory/filemap.cpp Mon Apr 9 15:33:05 2018
*** 94,104 ****
--- 94,104 ----
void FileMapInfo::fail_continue(const char *msg, ...) {
va_list ap;
va_start(ap, msg);
MetaspaceShared::set_archive_loading_failed();
! if (PrintSharedArchiveAndExit && _validating_classpath_entry_table) {
! if (PrintSharedArchiveAndExit && _validating_shared_path_table) {
// If we are doing PrintSharedArchiveAndExit and some of the classpath entries
// do not validate, we can still continue "limping" to validate the remaining
// entries. No need to quit.
tty->print("[");
tty->vprint(msg, ap);
*** 186,198 ****
--- 186,198 ----
_narrow_oop_base = Universe::narrow_oop_base();
_narrow_oop_shift = Universe::narrow_oop_shift();
_max_heap_size = MaxHeapSize;
_narrow_klass_base = Universe::narrow_klass_base();
_narrow_klass_shift = Universe::narrow_klass_shift();
! _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
! _classpath_entry_table = mapinfo->_classpath_entry_table;
! _classpath_entry_size = mapinfo->_classpath_entry_size;
! _shared_path_table_size = mapinfo->_shared_path_table_size;
! _shared_path_table = mapinfo->_shared_path_table;
! _shared_path_entry_size = mapinfo->_shared_path_entry_size;
// The following fields are for sanity checks for whether this archive
// will function correctly with this JVM and the bootclasspath it's
// invoked with.
*** 229,244 ****
--- 229,248 ----
size_t len = strlen(name) + 1;
_name = MetadataFactory::new_array<char>(ClassLoaderData::the_null_class_loader_data(), (int)len, THREAD);
strcpy(_name->data(), name);
}
! bool SharedClassPathEntry::validate(bool is_class_path) {
struct stat st;
const char* name = this->name();
bool ok = true;
log_info(class, path)("checking shared classpath entry: %s", name);
! if (os::stat(name, &st) != 0 && is_class_path) {
+ // If the archived module path entry does not exist at runtime, it is not fatal
+ // (no need to invalid the shared archive) because the shared runtime visibility check
+ // filters out any archived module classes that do not have a matching runtime
+ // module path location.
FileMapInfo::fail_continue("Required classpath entry does not exist: %s", name);
ok = false;
} else if (is_dir()) {
if (!os::dir_is_empty(name)) {
FileMapInfo::fail_continue("directory is not empty: %s", name);
*** 264,274 ****
--- 268,278 ----
void SharedClassPathEntry::metaspace_pointers_do(MetaspaceClosure* it) {
it->push(&_name);
it->push(&_manifest);
}
! void FileMapInfo::allocate_classpath_entry_table() {
! void FileMapInfo::allocate_shared_path_table() {
assert(DumpSharedSpaces, "Sanity");
Thread* THREAD = Thread::current();
ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
ClassPathEntry* jrt = ClassLoader::get_jrt_entry();
*** 277,300 ****
--- 281,305 ----
"No modular java runtime image present when allocating the CDS classpath entry table");
size_t entry_size = SharedClassUtil::shared_class_path_entry_size(); // assert ( should be 8 byte aligned??)
int num_boot_classpath_entries = ClassLoader::num_boot_classpath_entries();
int num_app_classpath_entries = ClassLoader::num_app_classpath_entries();
! int num_entries = num_boot_classpath_entries + num_app_classpath_entries;
! int num_module_path_entries = ClassLoader::num_module_path_entries();
+ int num_entries = num_boot_classpath_entries + num_app_classpath_entries + num_module_path_entries;
size_t bytes = entry_size * num_entries;
! _classpath_entry_table = MetadataFactory::new_array<u8>(loader_data, (int)(bytes + 7 / 8), THREAD);
! _classpath_entry_table_size = num_entries;
! _classpath_entry_size = entry_size;
! _shared_path_table = MetadataFactory::new_array<u8>(loader_data, (int)(bytes + 7 / 8), THREAD);
! _shared_path_table_size = num_entries;
! _shared_path_entry_size = entry_size;
// 1. boot class path
int i = 0;
ClassPathEntry* cpe = jrt;
while (cpe != NULL) {
const char* type = ((cpe == jrt) ? "jrt" : (cpe->is_jar_file() ? "jar" : "dir"));
log_info(class, path)("add main shared path (%s) %s", type, cpe->name());
! SharedClassPathEntry* ent = shared_classpath(i);
! SharedClassPathEntry* ent = shared_path(i);
ent->init(cpe->name(), THREAD);
if (cpe != jrt) { // No need to do jimage.
EXCEPTION_MARK; // The following call should never throw, but would exit VM on error.
SharedClassUtil::update_shared_classpath(cpe, ent, THREAD);
}
*** 306,350 ****
--- 311,380 ----
// 2. app class path
ClassPathEntry *acpe = ClassLoader::app_classpath_entries();
while (acpe != NULL) {
log_info(class, path)("add app shared path %s", acpe->name());
! SharedClassPathEntry* ent = shared_classpath(i);
! SharedClassPathEntry* ent = shared_path(i);
ent->init(acpe->name(), THREAD);
EXCEPTION_MARK;
SharedClassUtil::update_shared_classpath(acpe, ent, THREAD);
acpe = acpe->next();
- i ++;
+ }
+
+ // 3. module path
+ ClassPathEntry *mpe = ClassLoader::module_path_entries();
+ while (mpe != NULL) {
+ log_info(class, path)("add module path %s",mpe->name());
+ SharedClassPathEntry* ent = shared_path(i);
+ ent->init(mpe->name(), THREAD);
+ EXCEPTION_MARK;
+ SharedClassUtil::update_shared_classpath(mpe, ent, THREAD);
+ mpe = mpe->next();
+ i++;
}
! assert(i == num_entries, "number of app class path entry mismatch");
! assert(i == num_entries, "number of shared path entry mismatch");
}
bool FileMapInfo::validate_classpath_entry_table() {
_validating_classpath_entry_table = true;
+ // This function should only be called during run time with UseSharedSpaces enabled.
+ bool FileMapInfo::validate_shared_path_table() {
+ _validating_shared_path_table = true;
! int count = _header->_classpath_entry_table_size;
! _shared_path_table = _header->_shared_path_table;
+ _shared_path_entry_size = _header->_shared_path_entry_size;
+ _shared_path_table_size = _header->_shared_path_table_size;
_classpath_entry_table = _header->_classpath_entry_table;
_classpath_entry_size = _header->_classpath_entry_size;
_classpath_entry_table_size = _header->_classpath_entry_table_size;
+ // Note: _app_module_paths_start_index may not have a valid value if the UseAppCDS flag
+ // wasn't enabled during dump time. Therefore, we need to use the smaller of
+ // _shared_path_table_size and _app_module_paths_start_index for the _app_module_paths_start_index.
+ FileMapHeaderExt* header = (FileMapHeaderExt*)FileMapInfo::current_info()->header();
+ int module_paths_start_index = (header->_app_module_paths_start_index >= _shared_path_table_size) ?
+ _shared_path_table_size : header->_app_module_paths_start_index;
+
+ int count = _shared_path_table_size;
for (int i=0; i<count; i++) {
! if (shared_classpath(i)->validate()) {
! if (i < module_paths_start_index) {
+ if (shared_path(i)->validate()) {
+ log_info(class, path)("ok");
+ }
+ } else if (i >= module_paths_start_index) {
+ if (shared_path(i)->validate(false /* not a class path entry */)) {
log_info(class, path)("ok");
+ }
} else if (!PrintSharedArchiveAndExit) {
! _validating_classpath_entry_table = false;
! _classpath_entry_table = NULL;
! _classpath_entry_table_size = 0;
! _validating_shared_path_table = false;
! _shared_path_table = NULL;
! _shared_path_table_size = 0;
return false;
}
}
! _validating_classpath_entry_table = false;
! _validating_shared_path_table = false;
return true;
}
// Read the FileMapInfo information from the file.
bool FileMapInfo::init_from_file(int fd) {
size_t sz = _header->data_size();
char* addr = _header->data();
*** 923,954 ****
--- 953,984 ----
fail_stop("Mark mismatch while restoring from shared file.");
}
}
void FileMapInfo::metaspace_pointers_do(MetaspaceClosure* it) {
! it->push(&_classpath_entry_table);
! for (int i=0; i<_classpath_entry_table_size; i++) {
! shared_classpath(i)->metaspace_pointers_do(it);
! it->push(&_shared_path_table);
! for (int i=0; i<_shared_path_table_size; i++) {
! shared_path(i)->metaspace_pointers_do(it);
}
}
FileMapInfo* FileMapInfo::_current_info = NULL;
! Array<u8>* FileMapInfo::_classpath_entry_table = NULL;
! int FileMapInfo::_classpath_entry_table_size = 0;
! size_t FileMapInfo::_classpath_entry_size = 0x1234baad;
! bool FileMapInfo::_validating_classpath_entry_table = false;
! Array<u8>* FileMapInfo::_shared_path_table = NULL;
! int FileMapInfo::_shared_path_table_size = 0;
! size_t FileMapInfo::_shared_path_entry_size = 0x1234baad;
! bool FileMapInfo::_validating_shared_path_table = false;
// Open the shared archive file, read and validate the header
// information (version, boot classpath, etc.). If initialization
// fails, shared spaces are disabled and the file is closed. [See
// fail_continue.]
//
// Validation of the archive is done in two steps:
//
// [1] validate_header() - done here. This checks the header, including _paths_misc_info.
! // [2] validate_classpath_entry_table - this is done later, because the table is in the RW
! // [2] validate_shared_path_table - this is done later, because the table is in the RW
// region of the archive, which is not mapped yet.
bool FileMapInfo::initialize() {
assert(UseSharedSpaces, "UseSharedSpaces expected.");
if (!open_for_read()) {
*** 978,987 ****
--- 1008,1018 ----
size_t sz = data_size() - (buf - header);
int crc = ClassLoader::crc32(0, buf, (jint)sz);
return crc;
}
+ // This function should only be called during run time with UseSharedSpaces enabled.
bool FileMapInfo::FileMapHeader::validate() {
if (VerifySharedSpaces && compute_crc() != _crc) {
fail_continue("Header checksum verification failed.");
return false;
}
src/hotspot/share/memory/filemap.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File