mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8207812: Implement Dynamic CDS Archive
Improve the usability of AppCDS Co-authored-by: Ioi Lam <ioi.lam@oracle.com> Co-authored-by: Jiangli Zhou <jianglizhou@google.com> Reviewed-by: acorn, jiangli, mseledtsov
This commit is contained in:
parent
e6c52060dc
commit
72dc5721e0
120 changed files with 6325 additions and 862 deletions
|
@ -36,6 +36,7 @@
|
|||
#include "classfile/klassFactory.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "compiler/compileBroker.hpp"
|
||||
#include "interpreter/bytecodeStream.hpp"
|
||||
|
@ -468,7 +469,7 @@ bool ClassPathImageEntry::is_modules_image() const {
|
|||
|
||||
#if INCLUDE_CDS
|
||||
void ClassLoader::exit_with_path_failure(const char* error, const char* message) {
|
||||
assert(DumpSharedSpaces, "only called at dump time");
|
||||
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "only called at dump time");
|
||||
tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure");
|
||||
vm_exit_during_initialization(error, message);
|
||||
}
|
||||
|
@ -534,7 +535,7 @@ void ClassLoader::setup_bootstrap_search_path() {
|
|||
trace_class_path("bootstrap loader class path=", sys_class_path);
|
||||
}
|
||||
#if INCLUDE_CDS
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
_shared_paths_misc_info->add_boot_classpath(sys_class_path);
|
||||
}
|
||||
#endif
|
||||
|
@ -550,16 +551,16 @@ void* ClassLoader::get_shared_paths_misc_info() {
|
|||
return _shared_paths_misc_info->buffer();
|
||||
}
|
||||
|
||||
bool ClassLoader::check_shared_paths_misc_info(void *buf, int size) {
|
||||
bool ClassLoader::check_shared_paths_misc_info(void *buf, int size, bool is_static) {
|
||||
SharedPathsMiscInfo* checker = new SharedPathsMiscInfo((char*)buf, size);
|
||||
bool result = checker->check();
|
||||
bool result = checker->check(is_static);
|
||||
delete checker;
|
||||
return result;
|
||||
}
|
||||
|
||||
void ClassLoader::setup_app_search_path(const char *class_path) {
|
||||
|
||||
assert(DumpSharedSpaces, "Sanity");
|
||||
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "Sanity");
|
||||
|
||||
Thread* THREAD = Thread::current();
|
||||
int len = (int)strlen(class_path);
|
||||
|
@ -587,7 +588,7 @@ void ClassLoader::setup_app_search_path(const char *class_path) {
|
|||
void ClassLoader::add_to_module_path_entries(const char* path,
|
||||
ClassPathEntry* entry) {
|
||||
assert(entry != NULL, "ClassPathEntry should not be NULL");
|
||||
assert(DumpSharedSpaces, "dump time only");
|
||||
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only");
|
||||
|
||||
// The entry does not exist, add to the list
|
||||
if (_module_path_entries == NULL) {
|
||||
|
@ -601,7 +602,7 @@ void ClassLoader::add_to_module_path_entries(const char* path,
|
|||
|
||||
// Add a module path to the _module_path_entries list.
|
||||
void ClassLoader::update_module_path_entry_list(const char *path, TRAPS) {
|
||||
assert(DumpSharedSpaces, "dump time only");
|
||||
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "dump time only");
|
||||
struct stat st;
|
||||
if (os::stat(path, &st) != 0) {
|
||||
tty->print_cr("os::stat error %d (%s). CDS dump aborted (path was \"%s\").",
|
||||
|
@ -709,7 +710,7 @@ void ClassLoader::setup_boot_search_path(const char *class_path) {
|
|||
bool set_base_piece = true;
|
||||
|
||||
#if INCLUDE_CDS
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
if (!Arguments::has_jimage()) {
|
||||
vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL);
|
||||
}
|
||||
|
@ -976,7 +977,7 @@ bool ClassLoader::update_class_path_entry_list(const char *path,
|
|||
return true;
|
||||
} else {
|
||||
#if INCLUDE_CDS
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
_shared_paths_misc_info->add_nonexist_path(path);
|
||||
}
|
||||
#endif
|
||||
|
@ -1334,6 +1335,10 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
|
|||
// appear in the _patch_mod_entries. The runtime shared class visibility
|
||||
// check will determine if a shared class is visible based on the runtime
|
||||
// environemnt, including the runtime --patch-module setting.
|
||||
//
|
||||
// DynamicDumpSharedSpaces requires UseSharedSpaces to be enabled. Since --patch-module
|
||||
// is not supported with UseSharedSpaces, it is not supported with DynamicDumpSharedSpaces.
|
||||
assert(!DynamicDumpSharedSpaces, "sanity");
|
||||
if (!DumpSharedSpaces) {
|
||||
stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
|
||||
}
|
||||
|
@ -1423,7 +1428,7 @@ char* ClassLoader::skip_uri_protocol(char* source) {
|
|||
// Record the shared classpath index and loader type for classes loaded
|
||||
// by the builtin loaders at dump time.
|
||||
void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream, TRAPS) {
|
||||
assert(DumpSharedSpaces, "sanity");
|
||||
assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "sanity");
|
||||
assert(stream != NULL, "sanity");
|
||||
|
||||
if (ik->is_unsafe_anonymous()) {
|
||||
|
@ -1513,6 +1518,8 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
|
|||
// user defined classloader.
|
||||
if (classpath_index < 0) {
|
||||
assert(ik->shared_classpath_index() < 0, "Sanity");
|
||||
ik->set_shared_classpath_index(UNREGISTERED_INDEX);
|
||||
SystemDictionaryShared::set_shared_class_misc_info(ik, (ClassFileStream*)stream);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -1595,7 +1602,7 @@ void ClassLoader::initialize() {
|
|||
load_jimage_library();
|
||||
#if INCLUDE_CDS
|
||||
// initialize search path
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
_shared_paths_misc_info = new SharedPathsMiscInfo();
|
||||
}
|
||||
#endif
|
||||
|
@ -1604,14 +1611,14 @@ void ClassLoader::initialize() {
|
|||
|
||||
#if INCLUDE_CDS
|
||||
void ClassLoader::initialize_shared_path() {
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
ClassLoaderExt::setup_search_paths();
|
||||
_shared_paths_misc_info->write_jint(0); // see comments in SharedPathsMiscInfo::check()
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoader::initialize_module_path(TRAPS) {
|
||||
if (DumpSharedSpaces) {
|
||||
if (DumpSharedSpaces || DynamicDumpSharedSpaces) {
|
||||
ClassLoaderExt::setup_module_paths(THREAD);
|
||||
FileMapInfo::allocate_shared_path_table();
|
||||
}
|
||||
|
@ -1677,6 +1684,7 @@ void ClassLoader::classLoader_init2(TRAPS) {
|
|||
// entries will be added to the exploded build array.
|
||||
if (!has_jrt_entry()) {
|
||||
assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with exploded module builds");
|
||||
assert(!DynamicDumpSharedSpaces, "DynamicDumpSharedSpaces not supported with exploded module builds");
|
||||
assert(!UseSharedSpaces, "UsedSharedSpaces not supported with exploded module builds");
|
||||
// Set up the boot loader's _exploded_entries list. Note that this gets
|
||||
// done before loading any classes, by the same thread that will
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue