8268821: Split systemDictionaryShared.cpp
Reviewed-by: erikj, ccheung, iklam
This commit is contained in:
parent
03d54e6ef1
commit
ee1e202bc3
@ -116,8 +116,12 @@ endif
|
||||
ifneq ($(call check-jvm-feature, cds), true)
|
||||
JVM_CFLAGS_FEATURES += -DINCLUDE_CDS=0
|
||||
JVM_EXCLUDE_FILES += \
|
||||
cdsProtectionDomain.cpp \
|
||||
classLoaderDataShared.cpp \
|
||||
classLoaderExt.cpp \
|
||||
dumpTimeSharedClassInfo.cpp \
|
||||
lambdaProxyClassDictionary.cpp \
|
||||
runTimeSharedClassInfo.cpp \
|
||||
systemDictionaryShared.cpp
|
||||
JVM_EXCLUDE_PATTERNS += cds/
|
||||
endif
|
||||
|
@ -228,7 +228,7 @@ bool ArchiveBuilder::gather_klass_and_symbol(MetaspaceClosure::Ref* ref, bool re
|
||||
_num_type_array_klasses ++;
|
||||
}
|
||||
}
|
||||
// See RunTimeSharedClassInfo::get_for()
|
||||
// See RunTimeClassInfo::get_for()
|
||||
_estimated_metaspaceobj_bytes += align_up(BytesPerWord, SharedSpaceObjectAlignment);
|
||||
} else if (ref->msotype() == MetaspaceObj::SymbolType) {
|
||||
// Make sure the symbol won't be GC'ed while we are dumping the archive.
|
||||
@ -319,7 +319,7 @@ void ArchiveBuilder::sort_klasses() {
|
||||
}
|
||||
|
||||
size_t ArchiveBuilder::estimate_archive_size() {
|
||||
// size of the symbol table and two dictionaries, plus the RunTimeSharedClassInfo's
|
||||
// size of the symbol table and two dictionaries, plus the RunTimeClassInfo's
|
||||
size_t symbol_table_est = SymbolTable::estimate_size_for_archive();
|
||||
size_t dictionary_est = SystemDictionaryShared::estimate_size_for_archive();
|
||||
_estimated_hashtable_bytes = symbol_table_est + dictionary_est;
|
||||
@ -632,8 +632,8 @@ void ArchiveBuilder::make_shallow_copy(DumpRegion *dump_region, SourceObjInfo* s
|
||||
oldtop = dump_region->top();
|
||||
if (ref->msotype() == MetaspaceObj::ClassType) {
|
||||
// Save a pointer immediate in front of an InstanceKlass, so
|
||||
// we can do a quick lookup from InstanceKlass* -> RunTimeSharedClassInfo*
|
||||
// without building another hashtable. See RunTimeSharedClassInfo::get_for()
|
||||
// we can do a quick lookup from InstanceKlass* -> RunTimeClassInfo*
|
||||
// without building another hashtable. See RunTimeClassInfo::get_for()
|
||||
// in systemDictionaryShared.cpp.
|
||||
Klass* klass = (Klass*)src;
|
||||
if (klass->is_instance_klass()) {
|
||||
|
338
src/hotspot/share/cds/cdsProtectionDomain.cpp
Normal file
338
src/hotspot/share/cds/cdsProtectionDomain.cpp
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "cds/cdsProtectionDomain.hpp"
|
||||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/classLoaderExt.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/moduleEntry.hpp"
|
||||
#include "classfile/symbolTable.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "classfile/vmClasses.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "memory/oopFactory.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "oops/symbol.hpp"
|
||||
#include "runtime/javaCalls.hpp"
|
||||
|
||||
OopHandle CDSProtectionDomain::_shared_protection_domains;
|
||||
OopHandle CDSProtectionDomain::_shared_jar_urls;
|
||||
OopHandle CDSProtectionDomain::_shared_jar_manifests;
|
||||
|
||||
// Initializes the java.lang.Package and java.security.ProtectionDomain objects associated with
|
||||
// the given InstanceKlass.
|
||||
// Returns the ProtectionDomain for the InstanceKlass.
|
||||
Handle CDSProtectionDomain::init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS) {
|
||||
Handle pd;
|
||||
|
||||
if (ik != NULL) {
|
||||
int index = ik->shared_classpath_index();
|
||||
assert(index >= 0, "Sanity");
|
||||
SharedClassPathEntry* ent = FileMapInfo::shared_path(index);
|
||||
Symbol* class_name = ik->name();
|
||||
|
||||
if (ent->is_modules_image()) {
|
||||
// For shared app/platform classes originated from the run-time image:
|
||||
// The ProtectionDomains are cached in the corresponding ModuleEntries
|
||||
// for fast access by the VM.
|
||||
// all packages from module image are already created during VM bootstrap in
|
||||
// Modules::define_module().
|
||||
assert(pkg_entry != NULL, "archived class in module image cannot be from unnamed package");
|
||||
ModuleEntry* mod_entry = pkg_entry->module();
|
||||
pd = get_shared_protection_domain(class_loader, mod_entry, CHECK_(pd));
|
||||
} else {
|
||||
// For shared app/platform classes originated from JAR files on the class path:
|
||||
// Each of the 3 SystemDictionaryShared::_shared_xxx arrays has the same length
|
||||
// as the shared classpath table in the shared archive (see
|
||||
// FileMap::_shared_path_table in filemap.hpp for details).
|
||||
//
|
||||
// If a shared InstanceKlass k is loaded from the class path, let
|
||||
//
|
||||
// index = k->shared_classpath_index():
|
||||
//
|
||||
// FileMap::_shared_path_table[index] identifies the JAR file that contains k.
|
||||
//
|
||||
// k's protection domain is:
|
||||
//
|
||||
// ProtectionDomain pd = _shared_protection_domains[index];
|
||||
//
|
||||
// and k's Package is initialized using
|
||||
//
|
||||
// manifest = _shared_jar_manifests[index];
|
||||
// url = _shared_jar_urls[index];
|
||||
// define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd));
|
||||
//
|
||||
// Note that if an element of these 3 _shared_xxx arrays is NULL, it will be initialized by
|
||||
// the corresponding SystemDictionaryShared::get_shared_xxx() function.
|
||||
Handle manifest = get_shared_jar_manifest(index, CHECK_(pd));
|
||||
Handle url = get_shared_jar_url(index, CHECK_(pd));
|
||||
int index_offset = index - ClassLoaderExt::app_class_paths_start_index();
|
||||
if (index_offset < PackageEntry::max_index_for_defined_in_class_path()) {
|
||||
if (pkg_entry == NULL || !pkg_entry->is_defined_by_cds_in_class_path(index_offset)) {
|
||||
// define_shared_package only needs to be called once for each package in a jar specified
|
||||
// in the shared class path.
|
||||
define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd));
|
||||
if (pkg_entry != NULL) {
|
||||
pkg_entry->set_defined_by_cds_in_class_path(index_offset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd));
|
||||
}
|
||||
pd = get_shared_protection_domain(class_loader, index, url, CHECK_(pd));
|
||||
}
|
||||
}
|
||||
return pd;
|
||||
}
|
||||
|
||||
Handle CDSProtectionDomain::get_package_name(Symbol* class_name, TRAPS) {
|
||||
ResourceMark rm(THREAD);
|
||||
Handle pkgname_string;
|
||||
TempNewSymbol pkg = ClassLoader::package_from_class_name(class_name);
|
||||
if (pkg != NULL) { // Package prefix found
|
||||
const char* pkgname = pkg->as_klass_external_name();
|
||||
pkgname_string = java_lang_String::create_from_str(pkgname,
|
||||
CHECK_(pkgname_string));
|
||||
}
|
||||
return pkgname_string;
|
||||
}
|
||||
|
||||
PackageEntry* CDSProtectionDomain::get_package_entry_from_class(InstanceKlass* ik, Handle class_loader) {
|
||||
PackageEntry* pkg_entry = ik->package();
|
||||
if (MetaspaceShared::use_full_module_graph() && ik->is_shared() && pkg_entry != NULL) {
|
||||
assert(MetaspaceShared::is_in_shared_metaspace(pkg_entry), "must be");
|
||||
assert(!ik->is_shared_unregistered_class(), "unexpected archived package entry for an unregistered class");
|
||||
assert(ik->module()->is_named(), "unexpected archived package entry for a class in an unnamed module");
|
||||
return pkg_entry;
|
||||
}
|
||||
TempNewSymbol pkg_name = ClassLoader::package_from_class_name(ik->name());
|
||||
if (pkg_name != NULL) {
|
||||
pkg_entry = SystemDictionaryShared::class_loader_data(class_loader)->packages()->lookup_only(pkg_name);
|
||||
} else {
|
||||
pkg_entry = NULL;
|
||||
}
|
||||
return pkg_entry;
|
||||
}
|
||||
|
||||
// Define Package for shared app classes from JAR file and also checks for
|
||||
// package sealing (all done in Java code)
|
||||
// See http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html
|
||||
void CDSProtectionDomain::define_shared_package(Symbol* class_name,
|
||||
Handle class_loader,
|
||||
Handle manifest,
|
||||
Handle url,
|
||||
TRAPS) {
|
||||
assert(SystemDictionary::is_system_class_loader(class_loader()), "unexpected class loader");
|
||||
// get_package_name() returns a NULL handle if the class is in unnamed package
|
||||
Handle pkgname_string = get_package_name(class_name, CHECK);
|
||||
if (pkgname_string.not_null()) {
|
||||
Klass* app_classLoader_klass = vmClasses::jdk_internal_loader_ClassLoaders_AppClassLoader_klass();
|
||||
JavaValue result(T_OBJECT);
|
||||
JavaCallArguments args(3);
|
||||
args.set_receiver(class_loader);
|
||||
args.push_oop(pkgname_string);
|
||||
args.push_oop(manifest);
|
||||
args.push_oop(url);
|
||||
JavaCalls::call_virtual(&result, app_classLoader_klass,
|
||||
vmSymbols::defineOrCheckPackage_name(),
|
||||
vmSymbols::defineOrCheckPackage_signature(),
|
||||
&args,
|
||||
CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
Handle CDSProtectionDomain::create_jar_manifest(const char* manifest_chars, size_t size, TRAPS) {
|
||||
typeArrayOop buf = oopFactory::new_byteArray((int)size, CHECK_NH);
|
||||
typeArrayHandle bufhandle(THREAD, buf);
|
||||
ArrayAccess<>::arraycopy_from_native(reinterpret_cast<const jbyte*>(manifest_chars),
|
||||
buf, typeArrayOopDesc::element_offset<jbyte>(0), size);
|
||||
Handle bais = JavaCalls::construct_new_instance(vmClasses::ByteArrayInputStream_klass(),
|
||||
vmSymbols::byte_array_void_signature(),
|
||||
bufhandle, CHECK_NH);
|
||||
// manifest = new Manifest(ByteArrayInputStream)
|
||||
Handle manifest = JavaCalls::construct_new_instance(vmClasses::Jar_Manifest_klass(),
|
||||
vmSymbols::input_stream_void_signature(),
|
||||
bais, CHECK_NH);
|
||||
return manifest;
|
||||
}
|
||||
|
||||
Handle CDSProtectionDomain::get_shared_jar_manifest(int shared_path_index, TRAPS) {
|
||||
Handle manifest;
|
||||
if (shared_jar_manifest(shared_path_index) == NULL) {
|
||||
SharedClassPathEntry* ent = FileMapInfo::shared_path(shared_path_index);
|
||||
size_t size = (size_t)ent->manifest_size();
|
||||
if (size == 0) {
|
||||
return Handle();
|
||||
}
|
||||
|
||||
// ByteArrayInputStream bais = new ByteArrayInputStream(buf);
|
||||
const char* src = ent->manifest();
|
||||
assert(src != NULL, "No Manifest data");
|
||||
manifest = create_jar_manifest(src, size, CHECK_NH);
|
||||
atomic_set_shared_jar_manifest(shared_path_index, manifest());
|
||||
}
|
||||
manifest = Handle(THREAD, shared_jar_manifest(shared_path_index));
|
||||
assert(manifest.not_null(), "sanity");
|
||||
return manifest;
|
||||
}
|
||||
|
||||
Handle CDSProtectionDomain::get_shared_jar_url(int shared_path_index, TRAPS) {
|
||||
Handle url_h;
|
||||
if (shared_jar_url(shared_path_index) == NULL) {
|
||||
JavaValue result(T_OBJECT);
|
||||
const char* path = FileMapInfo::shared_path_name(shared_path_index);
|
||||
Handle path_string = java_lang_String::create_from_str(path, CHECK_(url_h));
|
||||
Klass* classLoaders_klass =
|
||||
vmClasses::jdk_internal_loader_ClassLoaders_klass();
|
||||
JavaCalls::call_static(&result, classLoaders_klass,
|
||||
vmSymbols::toFileURL_name(),
|
||||
vmSymbols::toFileURL_signature(),
|
||||
path_string, CHECK_(url_h));
|
||||
|
||||
atomic_set_shared_jar_url(shared_path_index, result.get_oop());
|
||||
}
|
||||
|
||||
url_h = Handle(THREAD, shared_jar_url(shared_path_index));
|
||||
assert(url_h.not_null(), "sanity");
|
||||
return url_h;
|
||||
}
|
||||
|
||||
// Get the ProtectionDomain associated with the CodeSource from the classloader.
|
||||
Handle CDSProtectionDomain::get_protection_domain_from_classloader(Handle class_loader,
|
||||
Handle url, TRAPS) {
|
||||
// CodeSource cs = new CodeSource(url, null);
|
||||
Handle cs = JavaCalls::construct_new_instance(vmClasses::CodeSource_klass(),
|
||||
vmSymbols::url_code_signer_array_void_signature(),
|
||||
url, Handle(), CHECK_NH);
|
||||
|
||||
// protection_domain = SecureClassLoader.getProtectionDomain(cs);
|
||||
Klass* secureClassLoader_klass = vmClasses::SecureClassLoader_klass();
|
||||
JavaValue obj_result(T_OBJECT);
|
||||
JavaCalls::call_virtual(&obj_result, class_loader, secureClassLoader_klass,
|
||||
vmSymbols::getProtectionDomain_name(),
|
||||
vmSymbols::getProtectionDomain_signature(),
|
||||
cs, CHECK_NH);
|
||||
return Handle(THREAD, obj_result.get_oop());
|
||||
}
|
||||
|
||||
// Returns the ProtectionDomain associated with the JAR file identified by the url.
|
||||
Handle CDSProtectionDomain::get_shared_protection_domain(Handle class_loader,
|
||||
int shared_path_index,
|
||||
Handle url,
|
||||
TRAPS) {
|
||||
Handle protection_domain;
|
||||
if (shared_protection_domain(shared_path_index) == NULL) {
|
||||
Handle pd = get_protection_domain_from_classloader(class_loader, url, THREAD);
|
||||
atomic_set_shared_protection_domain(shared_path_index, pd());
|
||||
}
|
||||
|
||||
// Acquire from the cache because if another thread beats the current one to
|
||||
// set the shared protection_domain and the atomic_set fails, the current thread
|
||||
// needs to get the updated protection_domain from the cache.
|
||||
protection_domain = Handle(THREAD, shared_protection_domain(shared_path_index));
|
||||
assert(protection_domain.not_null(), "sanity");
|
||||
return protection_domain;
|
||||
}
|
||||
|
||||
// Returns the ProtectionDomain associated with the moduleEntry.
|
||||
Handle CDSProtectionDomain::get_shared_protection_domain(Handle class_loader,
|
||||
ModuleEntry* mod, TRAPS) {
|
||||
ClassLoaderData *loader_data = mod->loader_data();
|
||||
if (mod->shared_protection_domain() == NULL) {
|
||||
Symbol* location = mod->location();
|
||||
if (location != NULL) {
|
||||
Handle location_string = java_lang_String::create_from_symbol(
|
||||
location, CHECK_NH);
|
||||
Handle url;
|
||||
JavaValue result(T_OBJECT);
|
||||
if (location->starts_with("jrt:/")) {
|
||||
url = JavaCalls::construct_new_instance(vmClasses::URL_klass(),
|
||||
vmSymbols::string_void_signature(),
|
||||
location_string, CHECK_NH);
|
||||
} else {
|
||||
Klass* classLoaders_klass =
|
||||
vmClasses::jdk_internal_loader_ClassLoaders_klass();
|
||||
JavaCalls::call_static(&result, classLoaders_klass, vmSymbols::toFileURL_name(),
|
||||
vmSymbols::toFileURL_signature(),
|
||||
location_string, CHECK_NH);
|
||||
url = Handle(THREAD, result.get_oop());
|
||||
}
|
||||
|
||||
Handle pd = get_protection_domain_from_classloader(class_loader, url,
|
||||
CHECK_NH);
|
||||
mod->set_shared_protection_domain(loader_data, pd);
|
||||
}
|
||||
}
|
||||
|
||||
Handle protection_domain(THREAD, mod->shared_protection_domain());
|
||||
assert(protection_domain.not_null(), "sanity");
|
||||
return protection_domain;
|
||||
}
|
||||
|
||||
void CDSProtectionDomain::atomic_set_array_index(OopHandle array, int index, oop o) {
|
||||
// Benign race condition: array.obj_at(index) may already be filled in.
|
||||
// The important thing here is that all threads pick up the same result.
|
||||
// It doesn't matter which racing thread wins, as long as only one
|
||||
// result is used by all threads, and all future queries.
|
||||
((objArrayOop)array.resolve())->atomic_compare_exchange_oop(index, o, NULL);
|
||||
}
|
||||
|
||||
oop CDSProtectionDomain::shared_protection_domain(int index) {
|
||||
return ((objArrayOop)_shared_protection_domains.resolve())->obj_at(index);
|
||||
}
|
||||
|
||||
void CDSProtectionDomain::allocate_shared_protection_domain_array(int size, TRAPS) {
|
||||
if (_shared_protection_domains.resolve() == NULL) {
|
||||
oop spd = oopFactory::new_objArray(
|
||||
vmClasses::ProtectionDomain_klass(), size, CHECK);
|
||||
_shared_protection_domains = OopHandle(Universe::vm_global(), spd);
|
||||
}
|
||||
}
|
||||
|
||||
oop CDSProtectionDomain::shared_jar_url(int index) {
|
||||
return ((objArrayOop)_shared_jar_urls.resolve())->obj_at(index);
|
||||
}
|
||||
|
||||
void CDSProtectionDomain::allocate_shared_jar_url_array(int size, TRAPS) {
|
||||
if (_shared_jar_urls.resolve() == NULL) {
|
||||
oop sju = oopFactory::new_objArray(
|
||||
vmClasses::URL_klass(), size, CHECK);
|
||||
_shared_jar_urls = OopHandle(Universe::vm_global(), sju);
|
||||
}
|
||||
}
|
||||
|
||||
oop CDSProtectionDomain::shared_jar_manifest(int index) {
|
||||
return ((objArrayOop)_shared_jar_manifests.resolve())->obj_at(index);
|
||||
}
|
||||
|
||||
void CDSProtectionDomain::allocate_shared_jar_manifest_array(int size, TRAPS) {
|
||||
if (_shared_jar_manifests.resolve() == NULL) {
|
||||
oop sjm = oopFactory::new_objArray(
|
||||
vmClasses::Jar_Manifest_klass(), size, CHECK);
|
||||
_shared_jar_manifests = OopHandle(Universe::vm_global(), sjm);
|
||||
}
|
||||
}
|
115
src/hotspot/share/cds/cdsProtectionDomain.hpp
Normal file
115
src/hotspot/share/cds/cdsProtectionDomain.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARED_CDS_CDSPROTECTIONDOMAIN_HPP
|
||||
#define SHARED_CDS_CDSPROTECTIONDOMAIN_HPP
|
||||
#include "oops/oopHandle.inline.hpp"
|
||||
#include "runtime/handles.inline.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
#include "classfile/moduleEntry.hpp"
|
||||
|
||||
class InstanceKlass;
|
||||
class Symbol;
|
||||
class PackageEntry;
|
||||
class ModuleEntry;
|
||||
|
||||
// CDS security
|
||||
class CDSProtectionDomain : AllStatic {
|
||||
// See init_security_info for more info.
|
||||
static OopHandle _shared_protection_domains;
|
||||
static OopHandle _shared_jar_urls;
|
||||
static OopHandle _shared_jar_manifests;
|
||||
|
||||
public:
|
||||
// Package handling:
|
||||
//
|
||||
// 1. For named modules in the runtime image
|
||||
// BOOT classes: Reuses the existing JVM_GetSystemPackage(s) interfaces
|
||||
// to get packages in named modules for shared classes.
|
||||
// Package for non-shared classes in named module is also
|
||||
// handled using JVM_GetSystemPackage(s).
|
||||
//
|
||||
// APP classes: VM calls ClassLoaders.AppClassLoader::definePackage(String, Module)
|
||||
// to define package for shared app classes from named
|
||||
// modules.
|
||||
//
|
||||
// PLATFORM classes: VM calls ClassLoaders.PlatformClassLoader::definePackage(String, Module)
|
||||
// to define package for shared platform classes from named
|
||||
// modules.
|
||||
//
|
||||
// 2. For unnamed modules
|
||||
// BOOT classes: Reuses the existing JVM_GetSystemPackage(s) interfaces to
|
||||
// get packages for shared boot classes in unnamed modules.
|
||||
//
|
||||
// APP classes: VM calls ClassLoaders.AppClassLoader::defineOrCheckPackage()
|
||||
// with with the manifest and url from archived data.
|
||||
//
|
||||
// PLATFORM classes: No package is defined.
|
||||
//
|
||||
// The following two define_shared_package() functions are used to define
|
||||
// package for shared APP and PLATFORM classes.
|
||||
static Handle get_package_name(Symbol* class_name, TRAPS);
|
||||
static PackageEntry* get_package_entry_from_class(InstanceKlass* ik, Handle class_loader);
|
||||
static void define_shared_package(Symbol* class_name,
|
||||
Handle class_loader,
|
||||
Handle manifest,
|
||||
Handle url,
|
||||
TRAPS);
|
||||
static Handle create_jar_manifest(const char* man, size_t size, TRAPS);
|
||||
static Handle get_shared_jar_manifest(int shared_path_index, TRAPS);
|
||||
static Handle get_shared_jar_url(int shared_path_index, TRAPS);
|
||||
static Handle get_protection_domain_from_classloader(Handle class_loader,
|
||||
Handle url, TRAPS);
|
||||
static Handle get_shared_protection_domain(Handle class_loader,
|
||||
int shared_path_index,
|
||||
Handle url,
|
||||
TRAPS);
|
||||
static Handle get_shared_protection_domain(Handle class_loader,
|
||||
ModuleEntry* mod, TRAPS);
|
||||
static void atomic_set_array_index(OopHandle array, int index, oop o);
|
||||
static oop shared_protection_domain(int index);
|
||||
static void allocate_shared_protection_domain_array(int size, TRAPS);
|
||||
static oop shared_jar_url(int index);
|
||||
static void allocate_shared_jar_url_array(int size, TRAPS);
|
||||
static oop shared_jar_manifest(int index);
|
||||
static void allocate_shared_jar_manifest_array(int size, TRAPS);
|
||||
static Handle init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS);
|
||||
|
||||
static void allocate_shared_data_arrays(int size, TRAPS) {
|
||||
allocate_shared_protection_domain_array(size, CHECK);
|
||||
allocate_shared_jar_url_array(size, CHECK);
|
||||
allocate_shared_jar_manifest_array(size, CHECK);
|
||||
}
|
||||
static void atomic_set_shared_protection_domain(int index, oop pd) {
|
||||
atomic_set_array_index(_shared_protection_domains, index, pd);
|
||||
}
|
||||
static void atomic_set_shared_jar_url(int index, oop url) {
|
||||
atomic_set_array_index(_shared_jar_urls, index, url);
|
||||
}
|
||||
static void atomic_set_shared_jar_manifest(int index, oop man) {
|
||||
atomic_set_array_index(_shared_jar_manifests, index, man);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARED_CDS_CDSPROTECTIONDOMAIN_HPP
|
158
src/hotspot/share/cds/dumpTimeClassInfo.cpp
Normal file
158
src/hotspot/share/cds/dumpTimeClassInfo.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/dumpTimeClassInfo.hpp"
|
||||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
|
||||
void DumpTimeClassInfo::add_verification_constraint(InstanceKlass* k, Symbol* name,
|
||||
Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
|
||||
if (_verifier_constraints == NULL) {
|
||||
_verifier_constraints = new(ResourceObj::C_HEAP, mtClass) GrowableArray<DTVerifierConstraint>(4, mtClass);
|
||||
}
|
||||
if (_verifier_constraint_flags == NULL) {
|
||||
_verifier_constraint_flags = new(ResourceObj::C_HEAP, mtClass) GrowableArray<char>(4, mtClass);
|
||||
}
|
||||
GrowableArray<DTVerifierConstraint>* vc_array = _verifier_constraints;
|
||||
for (int i = 0; i < vc_array->length(); i++) {
|
||||
DTVerifierConstraint* p = vc_array->adr_at(i);
|
||||
if (name == p->_name && from_name == p->_from_name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
DTVerifierConstraint cons(name, from_name);
|
||||
vc_array->append(cons);
|
||||
|
||||
GrowableArray<char>* vcflags_array = _verifier_constraint_flags;
|
||||
char c = 0;
|
||||
c |= from_field_is_protected ? SystemDictionaryShared::FROM_FIELD_IS_PROTECTED : 0;
|
||||
c |= from_is_array ? SystemDictionaryShared::FROM_IS_ARRAY : 0;
|
||||
c |= from_is_object ? SystemDictionaryShared::FROM_IS_OBJECT : 0;
|
||||
vcflags_array->append(c);
|
||||
|
||||
if (log_is_enabled(Trace, cds, verification)) {
|
||||
ResourceMark rm;
|
||||
log_trace(cds, verification)("add_verification_constraint: %s: %s must be subclass of %s [0x%x] array len %d flags len %d",
|
||||
k->external_name(), from_name->as_klass_external_name(),
|
||||
name->as_klass_external_name(), c, vc_array->length(), vcflags_array->length());
|
||||
}
|
||||
}
|
||||
|
||||
static char get_loader_type_by(oop loader) {
|
||||
assert(SystemDictionary::is_builtin_class_loader(loader), "Must be built-in loader");
|
||||
if (SystemDictionary::is_boot_class_loader(loader)) {
|
||||
return (char)ClassLoader::BOOT_LOADER;
|
||||
} else if (SystemDictionary::is_platform_class_loader(loader)) {
|
||||
return (char)ClassLoader::PLATFORM_LOADER;
|
||||
} else {
|
||||
assert(SystemDictionary::is_system_class_loader(loader), "Class loader mismatch");
|
||||
return (char)ClassLoader::APP_LOADER;
|
||||
}
|
||||
}
|
||||
|
||||
void DumpTimeClassInfo::record_linking_constraint(Symbol* name, Handle loader1, Handle loader2) {
|
||||
assert(loader1 != loader2, "sanity");
|
||||
LogTarget(Info, class, loader, constraints) log;
|
||||
if (_loader_constraints == NULL) {
|
||||
_loader_constraints = new (ResourceObj::C_HEAP, mtClass) GrowableArray<DTLoaderConstraint>(4, mtClass);
|
||||
}
|
||||
char lt1 = get_loader_type_by(loader1());
|
||||
char lt2 = get_loader_type_by(loader2());
|
||||
DTLoaderConstraint lc(name, lt1, lt2);
|
||||
for (int i = 0; i < _loader_constraints->length(); i++) {
|
||||
DTLoaderConstraint dt = _loader_constraints->at(i);
|
||||
if (lc.equals(dt)) {
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
// Use loader[0]/loader[1] to be consistent with the logs in loaderConstraints.cpp
|
||||
log.print("[CDS record loader constraint for class: %s constraint_name: %s loader[0]: %s loader[1]: %s already added]",
|
||||
_klass->external_name(), name->as_C_string(),
|
||||
ClassLoaderData::class_loader_data(loader1())->loader_name_and_id(),
|
||||
ClassLoaderData::class_loader_data(loader2())->loader_name_and_id());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
_loader_constraints->append(lc);
|
||||
if (log.is_enabled()) {
|
||||
ResourceMark rm;
|
||||
// Use loader[0]/loader[1] to be consistent with the logs in loaderConstraints.cpp
|
||||
log.print("[CDS record loader constraint for class: %s constraint_name: %s loader[0]: %s loader[1]: %s total %d]",
|
||||
_klass->external_name(), name->as_C_string(),
|
||||
ClassLoaderData::class_loader_data(loader1())->loader_name_and_id(),
|
||||
ClassLoaderData::class_loader_data(loader2())->loader_name_and_id(),
|
||||
_loader_constraints->length());
|
||||
}
|
||||
}
|
||||
|
||||
bool DumpTimeClassInfo::is_builtin() {
|
||||
return SystemDictionaryShared::is_builtin(_klass);
|
||||
}
|
||||
|
||||
DumpTimeClassInfo* DumpTimeSharedClassTable::find_or_allocate_info_for(InstanceKlass* k, bool dump_in_progress) {
|
||||
bool created = false;
|
||||
DumpTimeClassInfo* p;
|
||||
if (!dump_in_progress) {
|
||||
p = put_if_absent(k, &created);
|
||||
} else {
|
||||
p = get(k);
|
||||
}
|
||||
if (created) {
|
||||
assert(!SystemDictionaryShared::no_class_loading_should_happen(),
|
||||
"no new classes can be loaded while dumping archive");
|
||||
p->_klass = k;
|
||||
} else {
|
||||
if (!dump_in_progress) {
|
||||
assert(p->_klass == k, "Sanity");
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
class CountClassByCategory : StackObj {
|
||||
DumpTimeSharedClassTable* _table;
|
||||
public:
|
||||
CountClassByCategory(DumpTimeSharedClassTable* table) : _table(table) {}
|
||||
bool do_entry(InstanceKlass* k, DumpTimeClassInfo& info) {
|
||||
if (!info.is_excluded()) {
|
||||
if (info.is_builtin()) {
|
||||
_table->inc_builtin_count();
|
||||
} else {
|
||||
_table->inc_unregistered_count();
|
||||
}
|
||||
}
|
||||
return true; // keep on iterating
|
||||
}
|
||||
};
|
||||
|
||||
void DumpTimeSharedClassTable::update_counts() {
|
||||
_builtin_count = 0;
|
||||
_unregistered_count = 0;
|
||||
CountClassByCategory counter(this);
|
||||
iterate(&counter);
|
||||
}
|
194
src/hotspot/share/cds/dumpTimeClassInfo.hpp
Normal file
194
src/hotspot/share/cds/dumpTimeClassInfo.hpp
Normal file
@ -0,0 +1,194 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARED_CDS_DUMPTIMESHAREDCLASSINFO_HPP
|
||||
#define SHARED_CDS_DUMPTIMESHAREDCLASSINFO_HPP
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/archiveUtils.hpp"
|
||||
#include "cds/metaspaceShared.hpp"
|
||||
#include "classfile/compactHashtable.hpp"
|
||||
#include "memory/metaspaceClosure.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
class Method;
|
||||
class Symbol;
|
||||
|
||||
class DumpTimeClassInfo: public CHeapObj<mtClass> {
|
||||
bool _excluded;
|
||||
bool _is_early_klass;
|
||||
bool _has_checked_exclusion;
|
||||
public:
|
||||
struct DTLoaderConstraint {
|
||||
Symbol* _name;
|
||||
char _loader_type1;
|
||||
char _loader_type2;
|
||||
DTLoaderConstraint(Symbol* name, char l1, char l2) : _name(name), _loader_type1(l1), _loader_type2(l2) {
|
||||
_name->increment_refcount();
|
||||
}
|
||||
DTLoaderConstraint() : _name(NULL), _loader_type1('0'), _loader_type2('0') {}
|
||||
bool equals(const DTLoaderConstraint& t) {
|
||||
return t._name == _name &&
|
||||
((t._loader_type1 == _loader_type1 && t._loader_type2 == _loader_type2) ||
|
||||
(t._loader_type2 == _loader_type1 && t._loader_type1 == _loader_type2));
|
||||
}
|
||||
};
|
||||
|
||||
struct DTVerifierConstraint {
|
||||
Symbol* _name;
|
||||
Symbol* _from_name;
|
||||
DTVerifierConstraint() : _name(NULL), _from_name(NULL) {}
|
||||
DTVerifierConstraint(Symbol* n, Symbol* fn) : _name(n), _from_name(fn) {
|
||||
_name->increment_refcount();
|
||||
_from_name->increment_refcount();
|
||||
}
|
||||
};
|
||||
|
||||
InstanceKlass* _klass;
|
||||
InstanceKlass* _nest_host;
|
||||
bool _failed_verification;
|
||||
bool _is_archived_lambda_proxy;
|
||||
int _id;
|
||||
int _clsfile_size;
|
||||
int _clsfile_crc32;
|
||||
GrowableArray<DTVerifierConstraint>* _verifier_constraints;
|
||||
GrowableArray<char>* _verifier_constraint_flags;
|
||||
GrowableArray<DTLoaderConstraint>* _loader_constraints;
|
||||
|
||||
DumpTimeClassInfo() {
|
||||
_klass = NULL;
|
||||
_nest_host = NULL;
|
||||
_failed_verification = false;
|
||||
_is_archived_lambda_proxy = false;
|
||||
_has_checked_exclusion = false;
|
||||
_id = -1;
|
||||
_clsfile_size = -1;
|
||||
_clsfile_crc32 = -1;
|
||||
_excluded = false;
|
||||
_is_early_klass = JvmtiExport::is_early_phase();
|
||||
_verifier_constraints = NULL;
|
||||
_verifier_constraint_flags = NULL;
|
||||
_loader_constraints = NULL;
|
||||
}
|
||||
|
||||
void add_verification_constraint(InstanceKlass* k, Symbol* name,
|
||||
Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object);
|
||||
void record_linking_constraint(Symbol* name, Handle loader1, Handle loader2);
|
||||
|
||||
bool is_builtin();
|
||||
|
||||
int num_verifier_constraints() {
|
||||
if (_verifier_constraint_flags != NULL) {
|
||||
return _verifier_constraint_flags->length();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int num_loader_constraints() {
|
||||
if (_loader_constraints != NULL) {
|
||||
return _loader_constraints->length();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
it->push(&_klass);
|
||||
it->push(&_nest_host);
|
||||
if (_verifier_constraints != NULL) {
|
||||
for (int i = 0; i < _verifier_constraints->length(); i++) {
|
||||
DTVerifierConstraint* cons = _verifier_constraints->adr_at(i);
|
||||
it->push(&cons->_name);
|
||||
it->push(&cons->_from_name);
|
||||
}
|
||||
}
|
||||
if (_loader_constraints != NULL) {
|
||||
for (int i = 0; i < _loader_constraints->length(); i++) {
|
||||
DTLoaderConstraint* lc = _loader_constraints->adr_at(i);
|
||||
it->push(&lc->_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_excluded() {
|
||||
// _klass may become NULL due to DynamicArchiveBuilder::set_to_null
|
||||
return _excluded || _failed_verification || _klass == NULL;
|
||||
}
|
||||
|
||||
// Was this class loaded while JvmtiExport::is_early_phase()==true
|
||||
bool is_early_klass() {
|
||||
return _is_early_klass;
|
||||
}
|
||||
|
||||
// simple accessors
|
||||
void set_excluded() { _excluded = true; }
|
||||
bool has_checked_exclusion() const { return _has_checked_exclusion; }
|
||||
void set_has_checked_exclusion() { _has_checked_exclusion = true; }
|
||||
bool failed_verification() const { return _failed_verification; }
|
||||
void set_failed_verification() { _failed_verification = true; }
|
||||
InstanceKlass* nest_host() const { return _nest_host; }
|
||||
void set_nest_host(InstanceKlass* nest_host) { _nest_host = nest_host; }
|
||||
};
|
||||
|
||||
|
||||
inline unsigned DumpTimeSharedClassTable_hash(InstanceKlass* const& k) {
|
||||
if (DumpSharedSpaces) {
|
||||
// Deterministic archive contents
|
||||
uintx delta = k->name() - MetaspaceShared::symbol_rs_base();
|
||||
return primitive_hash<uintx>(delta);
|
||||
} else {
|
||||
// Deterministic archive is not possible because classes can be loaded
|
||||
// in multiple threads.
|
||||
return primitive_hash<InstanceKlass*>(k);
|
||||
}
|
||||
}
|
||||
|
||||
class DumpTimeSharedClassTable: public ResourceHashtable<
|
||||
InstanceKlass*,
|
||||
DumpTimeClassInfo,
|
||||
&DumpTimeSharedClassTable_hash,
|
||||
primitive_equals<InstanceKlass*>,
|
||||
15889, // prime number
|
||||
ResourceObj::C_HEAP>
|
||||
{
|
||||
int _builtin_count;
|
||||
int _unregistered_count;
|
||||
public:
|
||||
DumpTimeClassInfo* find_or_allocate_info_for(InstanceKlass* k, bool dump_in_progress);
|
||||
void inc_builtin_count() { _builtin_count++; }
|
||||
void inc_unregistered_count() { _unregistered_count++; }
|
||||
void update_counts();
|
||||
int count_of(bool is_builtin) const {
|
||||
if (is_builtin) {
|
||||
return _builtin_count;
|
||||
} else {
|
||||
return _unregistered_count;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARED_CDS_DUMPTIMESHAREDCLASSINFO_HPP
|
@ -319,7 +319,7 @@ public:
|
||||
VMOp_Type type() const { return VMOp_PopulateDumpSharedSpace; }
|
||||
void doit() {
|
||||
ResourceMark rm;
|
||||
if (SystemDictionaryShared::empty_dumptime_table()) {
|
||||
if (SystemDictionaryShared::is_dumptime_table_empty()) {
|
||||
log_warning(cds, dynamic)("There is no class to be included in the dynamic archive.");
|
||||
return;
|
||||
}
|
||||
|
45
src/hotspot/share/cds/lambdaProxyClassDictionary.cpp
Normal file
45
src/hotspot/share/cds/lambdaProxyClassDictionary.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/lambdaProxyClassDictionary.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
|
||||
void LambdaProxyClassKey::mark_pointers() {
|
||||
ArchivePtrMarker::mark_pointer(&_caller_ik);
|
||||
ArchivePtrMarker::mark_pointer(&_instantiated_method_type);
|
||||
ArchivePtrMarker::mark_pointer(&_invoked_name);
|
||||
ArchivePtrMarker::mark_pointer(&_invoked_type);
|
||||
ArchivePtrMarker::mark_pointer(&_member_method);
|
||||
ArchivePtrMarker::mark_pointer(&_method_type);
|
||||
}
|
||||
|
||||
unsigned int LambdaProxyClassKey::hash() const {
|
||||
return SystemDictionaryShared::hash_for_shared_dictionary((address)_caller_ik) +
|
||||
SystemDictionaryShared::hash_for_shared_dictionary((address)_invoked_name) +
|
||||
SystemDictionaryShared::hash_for_shared_dictionary((address)_invoked_type) +
|
||||
SystemDictionaryShared::hash_for_shared_dictionary((address)_method_type) +
|
||||
SystemDictionaryShared::hash_for_shared_dictionary((address)_instantiated_method_type);
|
||||
}
|
171
src/hotspot/share/cds/lambdaProxyClassDictionary.hpp
Normal file
171
src/hotspot/share/cds/lambdaProxyClassDictionary.hpp
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARED_CDS_LAMBDAPROXYCLASSINFO_HPP
|
||||
#define SHARED_CDS_LAMBDAPROXYCLASSINFO_HPP
|
||||
#include "cds/metaspaceShared.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/resourceHash.hpp"
|
||||
|
||||
class InstanceKlass;
|
||||
class Method;
|
||||
class Symbol;
|
||||
|
||||
class LambdaProxyClassKey {
|
||||
InstanceKlass* _caller_ik;
|
||||
Symbol* _invoked_name;
|
||||
Symbol* _invoked_type;
|
||||
Symbol* _method_type;
|
||||
Method* _member_method;
|
||||
Symbol* _instantiated_method_type;
|
||||
|
||||
public:
|
||||
LambdaProxyClassKey(InstanceKlass* caller_ik,
|
||||
Symbol* invoked_name,
|
||||
Symbol* invoked_type,
|
||||
Symbol* method_type,
|
||||
Method* member_method,
|
||||
Symbol* instantiated_method_type) :
|
||||
_caller_ik(caller_ik),
|
||||
_invoked_name(invoked_name),
|
||||
_invoked_type(invoked_type),
|
||||
_method_type(method_type),
|
||||
_member_method(member_method),
|
||||
_instantiated_method_type(instantiated_method_type) {}
|
||||
|
||||
void metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
it->push(&_caller_ik);
|
||||
it->push(&_invoked_name);
|
||||
it->push(&_invoked_type);
|
||||
it->push(&_method_type);
|
||||
it->push(&_member_method);
|
||||
it->push(&_instantiated_method_type);
|
||||
}
|
||||
|
||||
bool equals(LambdaProxyClassKey const& other) const {
|
||||
return _caller_ik == other._caller_ik &&
|
||||
_invoked_name == other._invoked_name &&
|
||||
_invoked_type == other._invoked_type &&
|
||||
_method_type == other._method_type &&
|
||||
_member_method == other._member_method &&
|
||||
_instantiated_method_type == other._instantiated_method_type;
|
||||
}
|
||||
|
||||
void mark_pointers();
|
||||
unsigned int hash() const;
|
||||
|
||||
static unsigned int dumptime_hash(Symbol* sym) {
|
||||
if (sym == NULL) {
|
||||
// _invoked_name maybe NULL
|
||||
return 0;
|
||||
}
|
||||
return java_lang_String::hash_code((const jbyte*)sym->bytes(), sym->utf8_length());
|
||||
}
|
||||
|
||||
unsigned int dumptime_hash() const {
|
||||
return dumptime_hash(_caller_ik->name()) +
|
||||
dumptime_hash(_invoked_name) +
|
||||
dumptime_hash(_invoked_type) +
|
||||
dumptime_hash(_method_type) +
|
||||
dumptime_hash(_instantiated_method_type);
|
||||
}
|
||||
|
||||
static inline unsigned int DUMPTIME_HASH(LambdaProxyClassKey const& key) {
|
||||
return (key.dumptime_hash());
|
||||
}
|
||||
|
||||
static inline bool DUMPTIME_EQUALS(
|
||||
LambdaProxyClassKey const& k1, LambdaProxyClassKey const& k2) {
|
||||
return (k1.equals(k2));
|
||||
}
|
||||
|
||||
InstanceKlass* caller_ik() const { return _caller_ik; }
|
||||
};
|
||||
|
||||
class DumpTimeLambdaProxyClassInfo {
|
||||
public:
|
||||
GrowableArray<InstanceKlass*>* _proxy_klasses;
|
||||
DumpTimeLambdaProxyClassInfo() : _proxy_klasses(NULL) {}
|
||||
void add_proxy_klass(InstanceKlass* proxy_klass) {
|
||||
if (_proxy_klasses == NULL) {
|
||||
_proxy_klasses = new (ResourceObj::C_HEAP, mtClassShared)GrowableArray<InstanceKlass*>(5, mtClassShared);
|
||||
}
|
||||
assert(_proxy_klasses != NULL, "sanity");
|
||||
_proxy_klasses->append(proxy_klass);
|
||||
}
|
||||
|
||||
void metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
for (int i=0; i<_proxy_klasses->length(); i++) {
|
||||
it->push(_proxy_klasses->adr_at(i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class RunTimeLambdaProxyClassInfo {
|
||||
LambdaProxyClassKey _key;
|
||||
InstanceKlass* _proxy_klass_head;
|
||||
public:
|
||||
RunTimeLambdaProxyClassInfo(LambdaProxyClassKey key, InstanceKlass* proxy_klass_head) :
|
||||
_key(key), _proxy_klass_head(proxy_klass_head) {}
|
||||
|
||||
InstanceKlass* proxy_klass_head() const { return _proxy_klass_head; }
|
||||
|
||||
// Used by LambdaProxyClassDictionary to implement OffsetCompactHashtable::EQUALS
|
||||
static inline bool EQUALS(
|
||||
const RunTimeLambdaProxyClassInfo* value, LambdaProxyClassKey* key, int len_unused) {
|
||||
return (value->_key.equals(*key));
|
||||
}
|
||||
void init(LambdaProxyClassKey& key, DumpTimeLambdaProxyClassInfo& info) {
|
||||
_key = key;
|
||||
_key.mark_pointers();
|
||||
_proxy_klass_head = info._proxy_klasses->at(0);
|
||||
ArchivePtrMarker::mark_pointer(&_proxy_klass_head);
|
||||
}
|
||||
|
||||
unsigned int hash() const {
|
||||
return _key.hash();
|
||||
}
|
||||
LambdaProxyClassKey key() const {
|
||||
return _key;
|
||||
}
|
||||
};
|
||||
|
||||
class DumpTimeLambdaProxyClassDictionary
|
||||
: public ResourceHashtable<LambdaProxyClassKey,
|
||||
DumpTimeLambdaProxyClassInfo,
|
||||
LambdaProxyClassKey::DUMPTIME_HASH,
|
||||
LambdaProxyClassKey::DUMPTIME_EQUALS,
|
||||
137, // prime number
|
||||
ResourceObj::C_HEAP> {
|
||||
public:
|
||||
int _count;
|
||||
};
|
||||
|
||||
class LambdaProxyClassDictionary : public OffsetCompactHashtable<
|
||||
LambdaProxyClassKey*,
|
||||
const RunTimeLambdaProxyClassInfo*,
|
||||
RunTimeLambdaProxyClassInfo::EQUALS> {};
|
||||
|
||||
#endif // SHARED_CDS_LAMBDAPROXYCLASSINFO_HPP
|
@ -25,6 +25,7 @@
|
||||
#include "precompiled.hpp"
|
||||
#include "jvm_io.h"
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/cdsProtectionDomain.hpp"
|
||||
#include "cds/classListParser.hpp"
|
||||
#include "cds/cppVtables.hpp"
|
||||
#include "cds/dumpAllocStats.hpp"
|
||||
@ -246,7 +247,7 @@ void MetaspaceShared::post_initialize(TRAPS) {
|
||||
if (UseSharedSpaces) {
|
||||
int size = FileMapInfo::get_number_of_shared_paths();
|
||||
if (size > 0) {
|
||||
SystemDictionaryShared::allocate_shared_data_arrays(size, CHECK);
|
||||
CDSProtectionDomain::allocate_shared_data_arrays(size, CHECK);
|
||||
if (!DynamicDumpSharedSpaces) {
|
||||
FileMapInfo* info;
|
||||
if (FileMapInfo::dynamic_info() == NULL) {
|
||||
@ -700,7 +701,7 @@ void MetaspaceShared::preload_classes(TRAPS) {
|
||||
// Exercise the manifest processing code to ensure classes used by CDS at runtime
|
||||
// are always archived
|
||||
const char* dummy = "Manifest-Version: 1.0\n";
|
||||
SystemDictionaryShared::create_jar_manifest(dummy, strlen(dummy), CHECK);
|
||||
CDSProtectionDomain::create_jar_manifest(dummy, strlen(dummy), CHECK);
|
||||
|
||||
log_info(cds)("Loading classes to share: done.");
|
||||
log_info(cds)("Shared spaces: preloaded %d classes", class_count);
|
||||
|
76
src/hotspot/share/cds/runTimeClassInfo.cpp
Normal file
76
src/hotspot/share/cds/runTimeClassInfo.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/runTimeClassInfo.hpp"
|
||||
|
||||
void RunTimeClassInfo::init(DumpTimeClassInfo& info) {
|
||||
ArchiveBuilder* builder = ArchiveBuilder::current();
|
||||
assert(builder->is_in_buffer_space(info._klass), "must be");
|
||||
_klass = info._klass;
|
||||
if (!SystemDictionaryShared::is_builtin(_klass)) {
|
||||
CrcInfo* c = crc();
|
||||
c->_clsfile_size = info._clsfile_size;
|
||||
c->_clsfile_crc32 = info._clsfile_crc32;
|
||||
}
|
||||
_num_verifier_constraints = info.num_verifier_constraints();
|
||||
_num_loader_constraints = info.num_loader_constraints();
|
||||
int i;
|
||||
if (_num_verifier_constraints > 0) {
|
||||
RTVerifierConstraint* vf_constraints = verifier_constraints();
|
||||
char* flags = verifier_constraint_flags();
|
||||
for (i = 0; i < _num_verifier_constraints; i++) {
|
||||
vf_constraints[i]._name = builder->any_to_offset_u4(info._verifier_constraints->at(i)._name);
|
||||
vf_constraints[i]._from_name = builder->any_to_offset_u4(info._verifier_constraints->at(i)._from_name);
|
||||
}
|
||||
for (i = 0; i < _num_verifier_constraints; i++) {
|
||||
flags[i] = info._verifier_constraint_flags->at(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (_num_loader_constraints > 0) {
|
||||
RTLoaderConstraint* ld_constraints = loader_constraints();
|
||||
for (i = 0; i < _num_loader_constraints; i++) {
|
||||
ld_constraints[i]._name = builder->any_to_offset_u4(info._loader_constraints->at(i)._name);
|
||||
ld_constraints[i]._loader_type1 = info._loader_constraints->at(i)._loader_type1;
|
||||
ld_constraints[i]._loader_type2 = info._loader_constraints->at(i)._loader_type2;
|
||||
}
|
||||
}
|
||||
|
||||
if (_klass->is_hidden()) {
|
||||
InstanceKlass* n_h = info.nest_host();
|
||||
set_nest_host(n_h);
|
||||
}
|
||||
ArchivePtrMarker::mark_pointer(&_klass);
|
||||
}
|
||||
|
||||
size_t RunTimeClassInfo::crc_size(InstanceKlass* klass) {
|
||||
if (!SystemDictionaryShared::is_builtin(klass)) {
|
||||
return sizeof(CrcInfo);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
226
src/hotspot/share/cds/runTimeClassInfo.hpp
Normal file
226
src/hotspot/share/cds/runTimeClassInfo.hpp
Normal file
@ -0,0 +1,226 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARED_CDS_SHAREDCLASSINFO_HPP
|
||||
#define SHARED_CDS_SHAREDCLASSINFO_HPP
|
||||
#include "classfile/compactHashtable.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/systemDictionaryShared.hpp"
|
||||
#include "cds/archiveBuilder.hpp"
|
||||
#include "cds/archiveUtils.hpp"
|
||||
#include "cds/metaspaceShared.hpp"
|
||||
#include "memory/metaspaceClosure.hpp"
|
||||
#include "oops/instanceKlass.hpp"
|
||||
#include "prims/jvmtiExport.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/resourceHash.hpp"
|
||||
|
||||
class Method;
|
||||
class Symbol;
|
||||
|
||||
class RunTimeClassInfo {
|
||||
public:
|
||||
struct CrcInfo {
|
||||
int _clsfile_size;
|
||||
int _clsfile_crc32;
|
||||
};
|
||||
|
||||
// This is different than DumpTimeClassInfo::DTVerifierConstraint. We use
|
||||
// u4 instead of Symbol* to save space on 64-bit CPU.
|
||||
struct RTVerifierConstraint {
|
||||
u4 _name;
|
||||
u4 _from_name;
|
||||
Symbol* name() { return (Symbol*)(SharedBaseAddress + _name);}
|
||||
Symbol* from_name() { return (Symbol*)(SharedBaseAddress + _from_name); }
|
||||
};
|
||||
|
||||
struct RTLoaderConstraint {
|
||||
u4 _name;
|
||||
char _loader_type1;
|
||||
char _loader_type2;
|
||||
Symbol* constraint_name() {
|
||||
return (Symbol*)(SharedBaseAddress + _name);
|
||||
}
|
||||
};
|
||||
|
||||
InstanceKlass* _klass;
|
||||
int _num_verifier_constraints;
|
||||
int _num_loader_constraints;
|
||||
|
||||
// optional CrcInfo _crc; (only for UNREGISTERED classes)
|
||||
// optional InstanceKlass* _nest_host
|
||||
// optional RTLoaderConstraint _loader_constraint_types[_num_loader_constraints]
|
||||
// optional RTVerifierConstraint _verifier_constraints[_num_verifier_constraints]
|
||||
// optional char _verifier_constraint_flags[_num_verifier_constraints]
|
||||
|
||||
private:
|
||||
static size_t header_size_size() {
|
||||
return sizeof(RunTimeClassInfo);
|
||||
}
|
||||
static size_t verifier_constraints_size(int num_verifier_constraints) {
|
||||
return sizeof(RTVerifierConstraint) * num_verifier_constraints;
|
||||
}
|
||||
static size_t verifier_constraint_flags_size(int num_verifier_constraints) {
|
||||
return sizeof(char) * num_verifier_constraints;
|
||||
}
|
||||
static size_t loader_constraints_size(int num_loader_constraints) {
|
||||
return sizeof(RTLoaderConstraint) * num_loader_constraints;
|
||||
}
|
||||
static size_t nest_host_size(InstanceKlass* klass) {
|
||||
if (klass->is_hidden()) {
|
||||
return sizeof(InstanceKlass*);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t crc_size(InstanceKlass* klass);
|
||||
public:
|
||||
static size_t byte_size(InstanceKlass* klass, int num_verifier_constraints, int num_loader_constraints) {
|
||||
return header_size_size() +
|
||||
crc_size(klass) +
|
||||
nest_host_size(klass) +
|
||||
loader_constraints_size(num_loader_constraints) +
|
||||
verifier_constraints_size(num_verifier_constraints) +
|
||||
verifier_constraint_flags_size(num_verifier_constraints);
|
||||
}
|
||||
|
||||
private:
|
||||
size_t crc_offset() const {
|
||||
return header_size_size();
|
||||
}
|
||||
|
||||
size_t nest_host_offset() const {
|
||||
return crc_offset() + crc_size(_klass);
|
||||
}
|
||||
|
||||
size_t loader_constraints_offset() const {
|
||||
return nest_host_offset() + nest_host_size(_klass);
|
||||
}
|
||||
size_t verifier_constraints_offset() const {
|
||||
return loader_constraints_offset() + loader_constraints_size(_num_loader_constraints);
|
||||
}
|
||||
size_t verifier_constraint_flags_offset() const {
|
||||
return verifier_constraints_offset() + verifier_constraints_size(_num_verifier_constraints);
|
||||
}
|
||||
|
||||
void check_verifier_constraint_offset(int i) const {
|
||||
assert(0 <= i && i < _num_verifier_constraints, "sanity");
|
||||
}
|
||||
|
||||
void check_loader_constraint_offset(int i) const {
|
||||
assert(0 <= i && i < _num_loader_constraints, "sanity");
|
||||
}
|
||||
|
||||
public:
|
||||
CrcInfo* crc() const {
|
||||
assert(crc_size(_klass) > 0, "must be");
|
||||
return (CrcInfo*)(address(this) + crc_offset());
|
||||
}
|
||||
RTVerifierConstraint* verifier_constraints() {
|
||||
assert(_num_verifier_constraints > 0, "sanity");
|
||||
return (RTVerifierConstraint*)(address(this) + verifier_constraints_offset());
|
||||
}
|
||||
RTVerifierConstraint* verifier_constraint_at(int i) {
|
||||
check_verifier_constraint_offset(i);
|
||||
return verifier_constraints() + i;
|
||||
}
|
||||
|
||||
char* verifier_constraint_flags() {
|
||||
assert(_num_verifier_constraints > 0, "sanity");
|
||||
return (char*)(address(this) + verifier_constraint_flags_offset());
|
||||
}
|
||||
|
||||
InstanceKlass** nest_host_addr() {
|
||||
assert(_klass->is_hidden(), "sanity");
|
||||
return (InstanceKlass**)(address(this) + nest_host_offset());
|
||||
}
|
||||
InstanceKlass* nest_host() {
|
||||
return *nest_host_addr();
|
||||
}
|
||||
void set_nest_host(InstanceKlass* k) {
|
||||
*nest_host_addr() = k;
|
||||
ArchivePtrMarker::mark_pointer((address*)nest_host_addr());
|
||||
}
|
||||
|
||||
RTLoaderConstraint* loader_constraints() {
|
||||
assert(_num_loader_constraints > 0, "sanity");
|
||||
return (RTLoaderConstraint*)(address(this) + loader_constraints_offset());
|
||||
}
|
||||
|
||||
RTLoaderConstraint* loader_constraint_at(int i) {
|
||||
check_loader_constraint_offset(i);
|
||||
return loader_constraints() + i;
|
||||
}
|
||||
|
||||
void init(DumpTimeClassInfo& info);
|
||||
|
||||
bool matches(int clsfile_size, int clsfile_crc32) const {
|
||||
return crc()->_clsfile_size == clsfile_size &&
|
||||
crc()->_clsfile_crc32 == clsfile_crc32;
|
||||
}
|
||||
|
||||
char verifier_constraint_flag(int i) {
|
||||
check_verifier_constraint_offset(i);
|
||||
return verifier_constraint_flags()[i];
|
||||
}
|
||||
|
||||
private:
|
||||
// ArchiveBuilder::make_shallow_copy() has reserved a pointer immediately
|
||||
// before archived InstanceKlasses. We can use this slot to do a quick
|
||||
// lookup of InstanceKlass* -> RunTimeClassInfo* without
|
||||
// building a new hashtable.
|
||||
//
|
||||
// info_pointer_addr(klass) --> 0x0100 RunTimeClassInfo*
|
||||
// InstanceKlass* klass --> 0x0108 <C++ vtbl>
|
||||
// 0x0110 fields from Klass ...
|
||||
static RunTimeClassInfo** info_pointer_addr(InstanceKlass* klass) {
|
||||
return &((RunTimeClassInfo**)klass)[-1];
|
||||
}
|
||||
|
||||
public:
|
||||
static RunTimeClassInfo* get_for(InstanceKlass* klass) {
|
||||
assert(klass->is_shared(), "don't call for non-shared class");
|
||||
return *info_pointer_addr(klass);
|
||||
}
|
||||
static void set_for(InstanceKlass* klass, RunTimeClassInfo* record) {
|
||||
assert(ArchiveBuilder::current()->is_in_buffer_space(klass), "must be");
|
||||
assert(ArchiveBuilder::current()->is_in_buffer_space(record), "must be");
|
||||
*info_pointer_addr(klass) = record;
|
||||
ArchivePtrMarker::mark_pointer(info_pointer_addr(klass));
|
||||
}
|
||||
|
||||
// Used by RunTimeSharedDictionary to implement OffsetCompactHashtable::EQUALS
|
||||
static inline bool EQUALS(
|
||||
const RunTimeClassInfo* value, Symbol* key, int len_unused) {
|
||||
return (value->_klass->name() == key);
|
||||
}
|
||||
};
|
||||
|
||||
class RunTimeSharedDictionary : public OffsetCompactHashtable<
|
||||
Symbol*,
|
||||
const RunTimeClassInfo*,
|
||||
RunTimeClassInfo::EQUALS> {};
|
||||
#endif // SHARED_CDS_SHAREDCLASSINFO_HPP
|
@ -202,15 +202,14 @@ class SystemDictionary : AllStatic {
|
||||
// Initialization
|
||||
static void initialize(TRAPS);
|
||||
|
||||
protected:
|
||||
// Returns the class loader data to be used when looking up/updating the
|
||||
// system dictionary.
|
||||
static ClassLoaderData *class_loader_data(Handle class_loader);
|
||||
|
||||
public:
|
||||
// Returns java system loader
|
||||
static oop java_system_loader();
|
||||
|
||||
// Returns the class loader data to be used when looking up/updating the
|
||||
// system dictionary.
|
||||
static ClassLoaderData *class_loader_data(Handle class_loader);
|
||||
|
||||
// Returns java platform loader
|
||||
static oop java_platform_loader();
|
||||
|
||||
@ -220,7 +219,6 @@ public:
|
||||
// Register a new class loader
|
||||
static ClassLoaderData* register_loader(Handle class_loader, bool create_mirror_cld = false);
|
||||
|
||||
public:
|
||||
static Symbol* check_signature_loaders(Symbol* signature, Klass* klass_being_linked,
|
||||
Handle loader1, Handle loader2, bool is_method);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,6 +26,9 @@
|
||||
#define SHARE_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP
|
||||
|
||||
#include "cds/filemap.hpp"
|
||||
#include "cds/dumpTimeClassInfo.hpp"
|
||||
#include "cds/lambdaProxyClassDictionary.hpp"
|
||||
#include "cds/runTimeClassInfo.hpp"
|
||||
#include "classfile/classLoaderData.hpp"
|
||||
#include "classfile/packageEntry.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
@ -106,11 +109,13 @@
|
||||
class BootstrapInfo;
|
||||
class ClassFileStream;
|
||||
class Dictionary;
|
||||
class DumpTimeSharedClassInfo;
|
||||
class DumpTimeClassInfo;
|
||||
class DumpTimeSharedClassTable;
|
||||
class LambdaProxyClassDictionary;
|
||||
class RunTimeSharedClassInfo;
|
||||
class RunTimeClassInfo;
|
||||
class RunTimeSharedDictionary;
|
||||
class DumpTimeLambdaProxyClassDictionary;
|
||||
class LambdaProxyClassKey;
|
||||
|
||||
class SharedClassLoadingMark {
|
||||
private:
|
||||
@ -139,92 +144,30 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
// These _shared_xxxs arrays are used to initialize the java.lang.Package and
|
||||
// java.security.ProtectionDomain objects associated with each shared class.
|
||||
//
|
||||
// See SystemDictionaryShared::init_security_info for more info.
|
||||
static OopHandle _shared_protection_domains;
|
||||
static OopHandle _shared_jar_urls;
|
||||
static OopHandle _shared_jar_manifests;
|
||||
|
||||
static DumpTimeSharedClassTable* _dumptime_table;
|
||||
static DumpTimeLambdaProxyClassDictionary* _dumptime_lambda_proxy_class_dictionary;
|
||||
// SystemDictionaries in the base layer static archive
|
||||
static RunTimeSharedDictionary _builtin_dictionary;
|
||||
static RunTimeSharedDictionary _unregistered_dictionary;
|
||||
static LambdaProxyClassDictionary _lambda_proxy_class_dictionary;
|
||||
// SystemDictionaries in the top layer dynamic archive
|
||||
static RunTimeSharedDictionary _dynamic_builtin_dictionary;
|
||||
static RunTimeSharedDictionary _dynamic_unregistered_dictionary;
|
||||
static LambdaProxyClassDictionary _dynamic_lambda_proxy_class_dictionary;
|
||||
|
||||
static InstanceKlass* load_shared_class_for_builtin_loader(
|
||||
Symbol* class_name,
|
||||
Handle class_loader,
|
||||
TRAPS);
|
||||
static Handle get_package_name(Symbol* class_name, TRAPS);
|
||||
|
||||
static PackageEntry* get_package_entry_from_class(InstanceKlass* ik, Handle class_loader);
|
||||
|
||||
|
||||
// Package handling:
|
||||
//
|
||||
// 1. For named modules in the runtime image
|
||||
// BOOT classes: Reuses the existing JVM_GetSystemPackage(s) interfaces
|
||||
// to get packages in named modules for shared classes.
|
||||
// Package for non-shared classes in named module is also
|
||||
// handled using JVM_GetSystemPackage(s).
|
||||
//
|
||||
// APP classes: VM calls ClassLoaders.AppClassLoader::definePackage(String, Module)
|
||||
// to define package for shared app classes from named
|
||||
// modules.
|
||||
//
|
||||
// PLATFORM classes: VM calls ClassLoaders.PlatformClassLoader::definePackage(String, Module)
|
||||
// to define package for shared platform classes from named
|
||||
// modules.
|
||||
//
|
||||
// 2. For unnamed modules
|
||||
// BOOT classes: Reuses the existing JVM_GetSystemPackage(s) interfaces to
|
||||
// get packages for shared boot classes in unnamed modules.
|
||||
//
|
||||
// APP classes: VM calls ClassLoaders.AppClassLoader::defineOrCheckPackage()
|
||||
// with with the manifest and url from archived data.
|
||||
//
|
||||
// PLATFORM classes: No package is defined.
|
||||
//
|
||||
// The following two define_shared_package() functions are used to define
|
||||
// package for shared APP and PLATFORM classes.
|
||||
static void define_shared_package(Symbol* class_name,
|
||||
Handle class_loader,
|
||||
Handle manifest,
|
||||
Handle url,
|
||||
TRAPS);
|
||||
|
||||
static Handle get_shared_jar_manifest(int shared_path_index, TRAPS);
|
||||
static Handle get_shared_jar_url(int shared_path_index, TRAPS);
|
||||
static Handle get_protection_domain_from_classloader(Handle class_loader,
|
||||
Handle url, TRAPS);
|
||||
static Handle get_shared_protection_domain(Handle class_loader,
|
||||
int shared_path_index,
|
||||
Handle url,
|
||||
TRAPS);
|
||||
static Handle get_shared_protection_domain(Handle class_loader,
|
||||
ModuleEntry* mod, TRAPS);
|
||||
|
||||
static void atomic_set_array_index(OopHandle array, int index, oop o);
|
||||
|
||||
static oop shared_protection_domain(int index);
|
||||
static void atomic_set_shared_protection_domain(int index, oop pd) {
|
||||
atomic_set_array_index(_shared_protection_domains, index, pd);
|
||||
}
|
||||
static void allocate_shared_protection_domain_array(int size, TRAPS);
|
||||
static oop shared_jar_url(int index);
|
||||
static void atomic_set_shared_jar_url(int index, oop url) {
|
||||
atomic_set_array_index(_shared_jar_urls, index, url);
|
||||
}
|
||||
static void allocate_shared_jar_url_array(int size, TRAPS);
|
||||
static oop shared_jar_manifest(int index);
|
||||
static void atomic_set_shared_jar_manifest(int index, oop man) {
|
||||
atomic_set_array_index(_shared_jar_manifests, index, man);
|
||||
}
|
||||
static void allocate_shared_jar_manifest_array(int size, TRAPS);
|
||||
static InstanceKlass* acquire_class_for_current_thread(
|
||||
InstanceKlass *ik,
|
||||
Handle class_loader,
|
||||
Handle protection_domain,
|
||||
const ClassFileStream* cfs,
|
||||
TRAPS);
|
||||
static DumpTimeSharedClassInfo* find_or_allocate_info_for(InstanceKlass* k);
|
||||
static DumpTimeSharedClassInfo* find_or_allocate_info_for_locked(InstanceKlass* k);
|
||||
static DumpTimeClassInfo* find_or_allocate_info_for(InstanceKlass* k);
|
||||
static DumpTimeClassInfo* find_or_allocate_info_for_locked(InstanceKlass* k);
|
||||
static void write_dictionary(RunTimeSharedDictionary* dictionary,
|
||||
bool is_builtin);
|
||||
static void write_lambda_proxy_class_dictionary(LambdaProxyClassDictionary* dictionary);
|
||||
@ -245,10 +188,9 @@ private:
|
||||
public:
|
||||
static bool is_hidden_lambda_proxy(InstanceKlass* ik);
|
||||
static bool is_early_klass(InstanceKlass* k); // Was k loaded while JvmtiExport::is_early_phase()==true
|
||||
static Handle init_security_info(Handle class_loader, InstanceKlass* ik, PackageEntry* pkg_entry, TRAPS);
|
||||
static InstanceKlass* find_builtin_class(Symbol* class_name);
|
||||
|
||||
static const RunTimeSharedClassInfo* find_record(RunTimeSharedDictionary* static_dict,
|
||||
static const RunTimeClassInfo* find_record(RunTimeSharedDictionary* static_dict,
|
||||
RunTimeSharedDictionary* dynamic_dict,
|
||||
Symbol* name);
|
||||
|
||||
@ -307,6 +249,8 @@ public:
|
||||
Symbol* method_type,
|
||||
Method* member_method,
|
||||
Symbol* instantiated_method_type, TRAPS) NOT_CDS_RETURN;
|
||||
static void add_to_dump_time_lambda_proxy_class_dictionary(LambdaProxyClassKey& key,
|
||||
InstanceKlass* proxy_klass) NOT_CDS_RETURN;
|
||||
static InstanceKlass* get_shared_lambda_proxy_class(InstanceKlass* caller_ik,
|
||||
Symbol* invoked_name,
|
||||
Symbol* invoked_type,
|
||||
@ -324,7 +268,7 @@ public:
|
||||
}
|
||||
static bool add_unregistered_class(Thread* current, InstanceKlass* k);
|
||||
static void check_excluded_classes();
|
||||
static bool check_for_exclusion(InstanceKlass* k, DumpTimeSharedClassInfo* info);
|
||||
static bool check_for_exclusion(InstanceKlass* k, DumpTimeClassInfo* info);
|
||||
static void validate_before_archiving(InstanceKlass* k);
|
||||
static bool is_excluded_class(InstanceKlass* k);
|
||||
static void set_excluded(InstanceKlass* k);
|
||||
@ -341,11 +285,9 @@ public:
|
||||
static void print_on(outputStream* st) NOT_CDS_RETURN;
|
||||
static void print_shared_archive(outputStream* st, bool is_static = true) NOT_CDS_RETURN;
|
||||
static void print_table_statistics(outputStream* st) NOT_CDS_RETURN;
|
||||
static bool empty_dumptime_table() NOT_CDS_RETURN_(true);
|
||||
static bool is_dumptime_table_empty() NOT_CDS_RETURN_(true);
|
||||
static void start_dumping() NOT_CDS_RETURN;
|
||||
static Handle create_jar_manifest(const char* man, size_t size, TRAPS) NOT_CDS_RETURN_(Handle());
|
||||
static bool is_supported_invokedynamic(BootstrapInfo* bsi) NOT_CDS_RETURN_(false);
|
||||
|
||||
DEBUG_ONLY(static bool no_class_loading_should_happen() {return _no_class_loading_should_happen;})
|
||||
|
||||
#ifdef ASSERT
|
||||
|
Loading…
x
Reference in New Issue
Block a user