8292891: ifdef-out some CDS-only functions
Reviewed-by: coleenp, ccheung, dholmes
This commit is contained in:
parent
adb3d4f14a
commit
40b0ed5657
@ -111,7 +111,7 @@ void Rewriter::make_constant_pool_cache(TRAPS) {
|
||||
_pool->initialize_resolved_references(loader_data, _resolved_references_map,
|
||||
_resolved_reference_limit,
|
||||
THREAD);
|
||||
|
||||
#if INCLUDE_CDS
|
||||
if (!HAS_PENDING_EXCEPTION && Arguments::is_dumping_archive()) {
|
||||
if (_pool->pool_holder()->is_shared()) {
|
||||
assert(DynamicDumpSharedSpaces, "must be");
|
||||
@ -122,6 +122,7 @@ void Rewriter::make_constant_pool_cache(TRAPS) {
|
||||
cache->save_for_archive(THREAD);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Clean up constant pool cache if initialize_resolved_references() failed.
|
||||
if (HAS_PENDING_EXCEPTION) {
|
||||
|
@ -199,6 +199,7 @@ traceid JfrTraceId::load_raw(jclass jc) {
|
||||
return load(jc, true);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// used by CDS / APPCDS as part of "remove_unshareable_info"
|
||||
void JfrTraceId::remove(const Klass* k) {
|
||||
assert(k != NULL, "invariant");
|
||||
@ -230,6 +231,7 @@ void JfrTraceId::restore(const Klass* k) {
|
||||
next_class_id();
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
bool JfrTraceId::in_visible_set(const jclass jc) {
|
||||
assert(jc != NULL, "invariant");
|
||||
|
@ -102,9 +102,11 @@ class JfrTraceId : public AllStatic {
|
||||
static traceid load_raw(const PackageEntry* package);
|
||||
static traceid load_raw(const ClassLoaderData* cld);
|
||||
|
||||
#if INCLUDE_CDS
|
||||
static void remove(const Klass* klass);
|
||||
static void remove(const Method* method);
|
||||
static void restore(const Klass* klass);
|
||||
#endif
|
||||
|
||||
// set of event classes made visible to java
|
||||
static bool in_visible_set(const Klass* k);
|
||||
|
@ -270,6 +270,7 @@ class MetaspaceObj {
|
||||
// non-shared or shared metaspace.
|
||||
static bool is_valid(const MetaspaceObj* p);
|
||||
|
||||
#if INCLUDE_CDS
|
||||
static bool is_shared(const MetaspaceObj* p) {
|
||||
// If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will
|
||||
// both be NULL and all values of p will be rejected quickly.
|
||||
@ -277,6 +278,10 @@ class MetaspaceObj {
|
||||
((void*)p) >= _shared_metaspace_base);
|
||||
}
|
||||
bool is_shared() const { return MetaspaceObj::is_shared(this); }
|
||||
#else
|
||||
static bool is_shared(const MetaspaceObj* p) { return false; }
|
||||
bool is_shared() const { return false; }
|
||||
#endif
|
||||
|
||||
void print_address_on(outputStream* st) const; // nonvirtual address printing
|
||||
|
||||
|
@ -156,6 +156,7 @@ void ArrayKlass::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
it->push((Klass**)&_lower_dimension);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void ArrayKlass::remove_unshareable_info() {
|
||||
Klass::remove_unshareable_info();
|
||||
if (_higher_dimension != NULL) {
|
||||
@ -182,6 +183,7 @@ void ArrayKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle p
|
||||
ak->restore_unshareable_info(loader_data, protection_domain, CHECK);
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
// Printing
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, 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
|
||||
@ -114,10 +114,12 @@ class ArrayKlass: public Klass {
|
||||
// JVMTI support
|
||||
jint jvmti_class_status() const;
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// CDS support - remove and restore oops from metadata. Oops are not shared.
|
||||
virtual void remove_unshareable_info();
|
||||
virtual void remove_java_mirror();
|
||||
void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
|
||||
#endif
|
||||
|
||||
// Printing
|
||||
void print_on(outputStream* st) const;
|
||||
|
@ -329,6 +329,7 @@ void ConstantPool::add_dumped_interned_strings() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// CDS support. Create a new resolved_references array.
|
||||
void ConstantPool::restore_unshareable_info(TRAPS) {
|
||||
if (!_pool_holder->is_linked() && !_pool_holder->is_rewritten()) {
|
||||
@ -342,9 +343,6 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
|
||||
// Only create the new resolved references array if it hasn't been attempted before
|
||||
if (resolved_references() != NULL) return;
|
||||
|
||||
// restore the C++ vtable from the shared archive
|
||||
restore_vtable();
|
||||
|
||||
if (vmClasses::Object_klass_loaded()) {
|
||||
ClassLoaderData* loader_data = pool_holder()->class_loader_data();
|
||||
#if INCLUDE_CDS_JAVA_HEAP
|
||||
@ -427,6 +425,7 @@ void ConstantPool::remove_unshareable_info() {
|
||||
cache()->remove_unshareable_info();
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
int ConstantPool::cp_to_object_index(int cp_index) {
|
||||
// this is harder don't do this so much.
|
||||
|
@ -691,17 +691,14 @@ class ConstantPool : public Metadata {
|
||||
resolve_string_constants_impl(h_this, CHECK);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// CDS support
|
||||
void archive_resolved_references() NOT_CDS_JAVA_HEAP_RETURN;
|
||||
void add_dumped_interned_strings() NOT_CDS_JAVA_HEAP_RETURN;
|
||||
void resolve_class_constants(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
|
||||
void remove_unshareable_info();
|
||||
void restore_unshareable_info(TRAPS);
|
||||
// The ConstantPool vtable is restored by this call when the ConstantPool is
|
||||
// in the shared archive. See patch_klass_vtables() in metaspaceShared.cpp for
|
||||
// all the gory details. SA, dtrace and pstack helpers distinguish metadata
|
||||
// by their vtable.
|
||||
void restore_vtable() { guarantee(is_constantPool(), "vtable restored by this call"); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum { _no_index_sentinel = -1, _possible_index_sentinel = -2 };
|
||||
|
@ -684,18 +684,16 @@ void ConstantPoolCache::record_gc_epoch() {
|
||||
_gc_epoch = CodeCache::gc_epoch();
|
||||
}
|
||||
|
||||
void ConstantPoolCache::save_for_archive(TRAPS) {
|
||||
#if INCLUDE_CDS
|
||||
void ConstantPoolCache::save_for_archive(TRAPS) {
|
||||
ClassLoaderData* loader_data = constant_pool()->pool_holder()->class_loader_data();
|
||||
_initial_entries = MetadataFactory::new_array<ConstantPoolCacheEntry>(loader_data, length(), CHECK);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
_initial_entries->at_put(i, *entry_at(i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ConstantPoolCache::remove_unshareable_info() {
|
||||
#if INCLUDE_CDS
|
||||
Arguments::assert_is_dumping_archive();
|
||||
// <this> is the copy to be written into the archive. It's in the ArchiveBuilder's "buffer space".
|
||||
// However, this->_initial_entries was not copied/relocated by the ArchiveBuilder, so it's
|
||||
@ -708,8 +706,8 @@ void ConstantPoolCache::remove_unshareable_info() {
|
||||
*entry_at(i) = _initial_entries->at(i);
|
||||
}
|
||||
_initial_entries = NULL;
|
||||
#endif
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) {
|
||||
assert(!is_shared(), "shared caches are not deallocated");
|
||||
|
@ -455,9 +455,11 @@ class ConstantPoolCache: public MetaspaceObj {
|
||||
// Assembly code support
|
||||
static int resolved_references_offset_in_bytes() { return offset_of(ConstantPoolCache, _resolved_references); }
|
||||
|
||||
// CDS support
|
||||
#if INCLUDE_CDS
|
||||
void remove_unshareable_info();
|
||||
void save_for_archive(TRAPS);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void walk_entries_for_initialization(bool check_only);
|
||||
void set_length(int length) { _length = length; }
|
||||
|
@ -2451,6 +2451,7 @@ void InstanceKlass::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
it->push(&_record_components);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void InstanceKlass::remove_unshareable_info() {
|
||||
|
||||
if (is_linked()) {
|
||||
@ -2651,6 +2652,7 @@ void InstanceKlass::assign_class_loader_type() {
|
||||
set_shared_class_loader_type(ClassLoader::APP_LOADER);
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
#if INCLUDE_JVMTI
|
||||
static void clear_all_breakpoints(Method* m) {
|
||||
|
@ -1211,12 +1211,15 @@ private:
|
||||
// log class name to classlist
|
||||
void log_to_classlist() const;
|
||||
public:
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// CDS support - remove and restore oops from metadata. Oops are not shared.
|
||||
virtual void remove_unshareable_info();
|
||||
virtual void remove_java_mirror();
|
||||
void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
|
||||
void init_shared_package_entry();
|
||||
bool can_be_verified_at_dumptime() const;
|
||||
#endif
|
||||
|
||||
jint compute_modifier_flags() const;
|
||||
|
||||
|
@ -537,6 +537,7 @@ void Klass::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
}
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void Klass::remove_unshareable_info() {
|
||||
assert (Arguments::is_dumping_archive(),
|
||||
"only called during CDS dump time");
|
||||
@ -627,6 +628,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
|
||||
java_lang_Class::create_mirror(this, loader, module_handle, protection_domain, Handle(), CHECK);
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
#if INCLUDE_CDS_JAVA_HEAP
|
||||
oop Klass::archived_java_mirror() {
|
||||
|
@ -545,7 +545,9 @@ protected:
|
||||
void set_vtable_length(int len) { _vtable_len= len; }
|
||||
|
||||
vtableEntry* start_of_vtable() const;
|
||||
#if INCLUDE_CDS
|
||||
void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
|
||||
#endif
|
||||
public:
|
||||
Method* method_at_vtable(int index);
|
||||
|
||||
@ -554,6 +556,7 @@ protected:
|
||||
return byte_offset_of(Klass, _vtable_len);
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// CDS support - remove and restore oops from metadata. Oops are not shared.
|
||||
virtual void remove_unshareable_info();
|
||||
virtual void remove_java_mirror();
|
||||
@ -569,6 +572,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif // INCLUDE_CDS
|
||||
|
||||
public:
|
||||
// ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP
|
||||
|
@ -401,6 +401,7 @@ void Method::metaspace_pointers_do(MetaspaceClosure* it) {
|
||||
NOT_PRODUCT(it->push(&_name);)
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
// Attempt to return method to original state. Clear any pointers
|
||||
// (to objects outside the shared spaces). We won't be able to predict
|
||||
// where they should point in a new JVM. Further initialize some
|
||||
@ -411,6 +412,11 @@ void Method::remove_unshareable_info() {
|
||||
JFR_ONLY(REMOVE_METHOD_ID(this);)
|
||||
}
|
||||
|
||||
void Method::restore_unshareable_info(TRAPS) {
|
||||
assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
|
||||
}
|
||||
#endif
|
||||
|
||||
void Method::set_vtable_index(int index) {
|
||||
if (is_shared() && !MetaspaceShared::remapped_readwrite() && method_holder()->verified_at_dump_time()) {
|
||||
// At runtime initialize_vtable is rerun as part of link_class_impl()
|
||||
@ -1259,10 +1265,6 @@ address Method::make_adapters(const methodHandle& mh, TRAPS) {
|
||||
return adapter->get_c2i_entry();
|
||||
}
|
||||
|
||||
void Method::restore_unshareable_info(TRAPS) {
|
||||
assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored");
|
||||
}
|
||||
|
||||
address Method::from_compiled_entry_no_trampoline() const {
|
||||
CompiledMethod *code = Atomic::load_acquire(&_code);
|
||||
if (code) {
|
||||
|
@ -134,7 +134,10 @@ class Method : public Metadata {
|
||||
|
||||
virtual bool is_method() const { return true; }
|
||||
|
||||
#if INCLUDE_CDS
|
||||
void remove_unshareable_info();
|
||||
void restore_unshareable_info(TRAPS);
|
||||
#endif
|
||||
|
||||
// accessors for instance variables
|
||||
|
||||
@ -424,10 +427,6 @@ class Method : public Metadata {
|
||||
int64_t compiled_invocation_count() const { return 0; }
|
||||
#endif // not PRODUCT
|
||||
|
||||
// Clear (non-shared space) pointers which could not be relevant
|
||||
// if this (shared) method were mapped into another JVM.
|
||||
void remove_unshareable_info();
|
||||
|
||||
// nmethod/verified compiler entry
|
||||
address verified_code_entry();
|
||||
bool check_code() const; // Not inline to avoid circular ref
|
||||
|
Loading…
x
Reference in New Issue
Block a user