From d3e5065284441647564a9eede79d69e7b0ac80be Mon Sep 17 00:00:00 2001 From: Ashutosh Mehra Date: Tue, 16 May 2023 22:36:44 +0000 Subject: [PATCH] 8306460: Clear JVM_ACC_QUEUED flag on methods when dumping dynamic CDS archive Reviewed-by: coleenp, iklam --- src/hotspot/share/oops/instanceKlass.cpp | 12 ++++++++++++ src/hotspot/share/oops/instanceKlass.hpp | 2 ++ src/hotspot/share/oops/method.cpp | 16 ++++++++++++++++ src/hotspot/share/oops/method.hpp | 1 + 4 files changed, 31 insertions(+) diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index c6efafe1526..075547705dc 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -2592,6 +2592,18 @@ void InstanceKlass::remove_unshareable_info() { init_shared_package_entry(); _dep_context_last_cleaned = 0; _init_monitor = nullptr; + + remove_unshareable_flags(); +} + +void InstanceKlass::remove_unshareable_flags() { + // clear all the flags/stats that shouldn't be in the archived version + assert(!is_scratch_class(), "must be"); + assert(!has_been_redefined(), "must be"); +#if INCLUDE_JVMTI + set_is_being_redefined(false); +#endif + set_has_resolved_methods(false); } void InstanceKlass::remove_java_mirror() { diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index 4997a122140..abf9ebdd044 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -706,6 +706,7 @@ public: bool has_resolved_methods() const { return _misc_flags.has_resolved_methods(); } void set_has_resolved_methods() { _misc_flags.set_has_resolved_methods(true); } + void set_has_resolved_methods(bool value) { _misc_flags.set_has_resolved_methods(value); } public: #if INCLUDE_JVMTI @@ -1126,6 +1127,7 @@ public: #if INCLUDE_CDS // CDS support - remove and restore oops from metadata. Oops are not shared. virtual void remove_unshareable_info(); + void remove_unshareable_flags(); virtual void remove_java_mirror(); void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS); void init_shared_package_entry(); diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index 20bf400f55c..5a25d9569fa 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -408,6 +408,7 @@ void Method::remove_unshareable_info() { void Method::restore_unshareable_info(TRAPS) { assert(is_method() && is_valid_method(this), "ensure C++ vtable is restored"); + assert(!queued_for_compilation(), "method's queued_for_compilation flag should not be set"); } #endif @@ -1193,6 +1194,21 @@ void Method::unlink_method() { set_method_data(nullptr); clear_method_counters(); + remove_unshareable_flags(); +} + +void Method::remove_unshareable_flags() { + // clear all the flags that shouldn't be in the archived version + assert(!is_old(), "must be"); + assert(!is_obsolete(), "must be"); + assert(!is_deleted(), "must be"); + + set_is_prefixed_native(false); + set_queued_for_compilation(false); + set_is_not_c2_compilable(false); + set_is_not_c1_compilable(false); + set_is_not_c2_osr_compilable(false); + set_on_stack_flag(false); } #endif diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index ab8c309afd8..564fa83e380 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -447,6 +447,7 @@ public: void link_method(const methodHandle& method, TRAPS); // clear entry points. Used by sharing code during dump time void unlink_method() NOT_CDS_RETURN; + void remove_unshareable_flags() NOT_CDS_RETURN; // the number of argument reg slots that the compiled method uses on the stack. int num_stack_arg_slots() const { return constMethod()->num_stack_arg_slots(); }