From c7faf60201a2401897e6159a5aaa03f22d4ae5d6 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Wed, 19 Apr 2023 02:53:02 +0000 Subject: [PATCH] 8305757: Call Method::compute_has_loops_flag() when creating CDS archive Reviewed-by: coleenp, ccheung --- src/hotspot/share/cds/metaspaceShared.cpp | 1 + src/hotspot/share/oops/instanceKlass.cpp | 10 ++++++++++ src/hotspot/share/oops/instanceKlass.hpp | 1 + 3 files changed, 12 insertions(+) diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 5d5ef2f4567..b62666a09f0 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -838,6 +838,7 @@ bool MetaspaceShared::try_link_class(JavaThread* current, InstanceKlass* ik) { SystemDictionaryShared::set_class_has_failed_verification(ik); _has_error_classes = true; } + ik->compute_has_loops_flag_for_methods(); BytecodeVerificationLocal = saved; return true; } else { diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 8bb3f10f868..a6f2245e3cd 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -2624,6 +2624,16 @@ void InstanceKlass::init_shared_package_entry() { #endif } +void InstanceKlass::compute_has_loops_flag_for_methods() { + Array* methods = this->methods(); + for (int index = 0; index < methods->length(); ++index) { + Method* m = methods->at(index); + if (!m->is_overpass()) { // work around JDK-8305771 + m->compute_has_loops_flag(); + } + } +} + void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS) { // InstanceKlass::add_to_hierarchy() sets the init_state to loaded diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index 681fa7d648b..80fc684de25 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -1141,6 +1141,7 @@ public: void init_shared_package_entry(); bool can_be_verified_at_dumptime() const; bool methods_contain_jsr_bytecode() const; + void compute_has_loops_flag_for_methods(); #endif jint compute_modifier_flags() const;