From 3bfc2b844d30f76af2b9a0391fae3f30e5382d74 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Mon, 3 Aug 2026 05:43:00 +0000 Subject: [PATCH] 8389235: [lworld] Wrong reason for too_many_traps_or_recompiles check in Parse::speculate_non_flat_array Reviewed-by: mchevalier, chagedorn --- src/hotspot/share/opto/compile.cpp | 3 +++ src/hotspot/share/opto/graphKit.hpp | 2 +- src/hotspot/share/opto/parse2.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index c5c22c25bd4..dee6e7fc397 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -4926,6 +4926,7 @@ bool Compile::final_graph_reshaping() { bool Compile::too_many_traps(ciMethod* method, int bci, Deoptimization::DeoptReason reason) { + assert(reason > Deoptimization::Reason_none && reason <= Deoptimization::Reason_LIMIT, "invalid reason"); ciMethodData* md = method->method_data(); if (md->is_empty()) { // Assume the trap has not occurred, or that it occurred only @@ -4951,6 +4952,7 @@ bool Compile::too_many_traps(ciMethod* method, // Less-accurate variant which does not require a method and bci. bool Compile::too_many_traps(Deoptimization::DeoptReason reason, ciMethodData* logmd) { + assert(reason > Deoptimization::Reason_none && reason <= Deoptimization::Reason_LIMIT, "invalid reason"); if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) { // Too many traps globally. // Note that we use cumulative trap_count, not just md->trap_count. @@ -4975,6 +4977,7 @@ bool Compile::too_many_traps(Deoptimization::DeoptReason reason, bool Compile::too_many_recompiles(ciMethod* method, int bci, Deoptimization::DeoptReason reason) { + assert(reason > Deoptimization::Reason_none && reason <= Deoptimization::Reason_LIMIT, "invalid reason"); ciMethodData* md = method->method_data(); if (md->is_empty()) { // Assume the trap has not occurred, or that it occurred only diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index d0de320ab84..bc4d6aeb371 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -772,7 +772,7 @@ class GraphKit : public Phase { } bool too_many_traps_or_recompiles(Deoptimization::DeoptReason reason) { - return C->too_many_traps_or_recompiles(method(), bci(), reason); + return C->too_many_traps_or_recompiles(method(), bci(), reason); } // Returns the object (if any) which was created the moment before. diff --git a/src/hotspot/share/opto/parse2.cpp b/src/hotspot/share/opto/parse2.cpp index 5c5cee39224..397c6421c6d 100644 --- a/src/hotspot/share/opto/parse2.cpp +++ b/src/hotspot/share/opto/parse2.cpp @@ -581,7 +581,7 @@ Node* Parse::speculate_non_flat_array(Node* const array, const TypeAryPtr* const !too_many_traps_or_recompiles(Deoptimization::Reason_speculate_class_check)) { flat_array = false; reason = Deoptimization::Reason_speculate_class_check; - } else if (UseArrayLoadStoreProfile && !too_many_traps_or_recompiles(reason)) { + } else if (UseArrayLoadStoreProfile && !too_many_traps_or_recompiles(Deoptimization::Reason_class_check)) { ciKlass* profiled_array_type = nullptr; ciKlass* profiled_element_type = nullptr; ProfilePtrKind element_ptr = ProfileMaybeNull;