Skip to content

Commit 0c4803b

Browse files
committed
8278871: [JVMCI] assert((uint)reason < 2* _trap_hist_limit) failed: oob
Reviewed-by: mdoerr Backport-of: 6f0e8da6d3bef340299e48977d5e17d05eabe682
1 parent 3352b56 commit 0c4803b

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@
521521
declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \
522522
declare_constant(Deoptimization::Reason_unresolved) \
523523
declare_constant(Deoptimization::Reason_jsr_mismatch) \
524-
declare_constant(Deoptimization::Reason_LIMIT) \
524+
declare_constant(Deoptimization::Reason_TRAP_HISTORY_LENGTH) \
525525
\
526526
declare_constant(FieldInfo::access_flags_offset) \
527527
declare_constant(FieldInfo::name_index_offset) \

src/hotspot/share/oops/methodData.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "oops/method.hpp"
3232
#include "oops/oop.hpp"
3333
#include "runtime/atomic.hpp"
34+
#include "runtime/deoptimization.hpp"
3435
#include "utilities/align.hpp"
3536
#include "utilities/copy.hpp"
3637
#if INCLUDE_JVMCI
@@ -1983,7 +1984,7 @@ class MethodData : public Metadata {
19831984

19841985
// Whole-method sticky bits and flags
19851986
enum {
1986-
_trap_hist_limit = 24 JVMCI_ONLY(+5), // decoupled from Deoptimization::Reason_LIMIT
1987+
_trap_hist_limit = Deoptimization::Reason_TRAP_HISTORY_LENGTH,
19871988
_trap_hist_mask = max_jubyte,
19881989
_extra_data_count = 4 // extra DataLayout headers, for trap history
19891990
}; // Public flag values
@@ -1999,6 +2000,7 @@ class MethodData : public Metadata {
19992000
uint _nof_overflow_traps; // trap count, excluding _trap_hist
20002001
union {
20012002
intptr_t _align;
2003+
// JVMCI separates trap history for OSR compilations from normal compilations
20022004
u1 _array[JVMCI_ONLY(2 *) MethodData::_trap_hist_limit];
20032005
} _trap_hist;
20042006

@@ -2021,14 +2023,14 @@ class MethodData : public Metadata {
20212023

20222024
// Return (uint)-1 for overflow.
20232025
uint trap_count(int reason) const {
2024-
assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob");
2026+
assert((uint)reason < ARRAY_SIZE(_trap_hist._array), "oob");
20252027
return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1;
20262028
}
20272029

20282030
uint inc_trap_count(int reason) {
20292031
// Count another trap, anywhere in this method.
20302032
assert(reason >= 0, "must be single trap");
2031-
assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob");
2033+
assert((uint)reason < ARRAY_SIZE(_trap_hist._array), "oob");
20322034
uint cnt1 = 1 + _trap_hist._array[reason];
20332035
if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow...
20342036
_trap_hist._array[reason] = cnt1;

src/hotspot/share/runtime/deoptimization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,8 @@ Deoptimization::query_update_method_data(MethodData* trap_mdo,
19911991
uint idx = reason;
19921992
#if INCLUDE_JVMCI
19931993
if (is_osr) {
1994-
idx += Reason_LIMIT;
1994+
// Upper half of history array used for traps in OSR compilations
1995+
idx += Reason_TRAP_HISTORY_LENGTH;
19951996
}
19961997
#endif
19971998
uint prior_trap_count = trap_mdo->trap_count(idx);

src/hotspot/share/runtime/deoptimization.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Deoptimization : AllStatic {
3838

3939
public:
4040
// What condition caused the deoptimization?
41+
// Note: Keep this enum in sync. with Deoptimization::_trap_reason_name.
4142
enum DeoptReason {
4243
Reason_many = -1, // indicates presence of several reasons
4344
Reason_none = 0, // indicates absence of a relevant deopt.
@@ -88,28 +89,29 @@ class Deoptimization : AllStatic {
8889
Reason_jsr_mismatch,
8990
#endif
9091

92+
// Used to define MethodData::_trap_hist_limit where Reason_tenured isn't included
93+
Reason_TRAP_HISTORY_LENGTH,
94+
9195
// Reason_tenured is counted separately, add normal counted Reasons above.
92-
// Related to MethodData::_trap_hist_limit where Reason_tenured isn't included
93-
Reason_tenured, // age of the code has reached the limit
96+
Reason_tenured = Reason_TRAP_HISTORY_LENGTH, // age of the code has reached the limit
9497
Reason_LIMIT,
9598

96-
// Note: Keep this enum in sync. with _trap_reason_name.
97-
Reason_RECORDED_LIMIT = Reason_profile_predicate // some are not recorded per bc
9899
// Note: Reason_RECORDED_LIMIT should fit into 31 bits of
99100
// DataLayout::trap_bits. This dependency is enforced indirectly
100101
// via asserts, to avoid excessive direct header-to-header dependencies.
101102
// See Deoptimization::trap_state_reason and class DataLayout.
103+
Reason_RECORDED_LIMIT = Reason_profile_predicate, // some are not recorded per bc
102104
};
103105

104106
// What action must be taken by the runtime?
107+
// Note: Keep this enum in sync. with Deoptimization::_trap_action_name.
105108
enum DeoptAction {
106109
Action_none, // just interpret, do not invalidate nmethod
107110
Action_maybe_recompile, // recompile the nmethod; need not invalidate
108111
Action_reinterpret, // invalidate the nmethod, reset IC, maybe recompile
109112
Action_make_not_entrant, // invalidate the nmethod, recompile (probably)
110113
Action_make_not_compilable, // invalidate the nmethod and do not compile
111114
Action_LIMIT
112-
// Note: Keep this enum in sync. with _trap_action_name.
113115
};
114116

115117
enum {

src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ final int baseVtableLength() {
323323
final int deoptReasonLoopLimitCheck = getConstant("Deoptimization::Reason_loop_limit_check", Integer.class);
324324
final int deoptReasonAliasing = getConstant("Deoptimization::Reason_aliasing", Integer.class);
325325
final int deoptReasonTransferToInterpreter = getConstant("Deoptimization::Reason_transfer_to_interpreter", Integer.class);
326-
final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_LIMIT", Integer.class);
326+
final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_TRAP_HISTORY_LENGTH", Integer.class);
327327

328328
final int deoptActionNone = getConstant("Deoptimization::Action_none", Integer.class);
329329
final int deoptActionMaybeRecompile = getConstant("Deoptimization::Action_maybe_recompile", Integer.class);

0 commit comments

Comments
 (0)