Skip to content

Commit 6f0e8da

Browse files
author
Doug Simon
committed
8278871: [JVMCI] assert((uint)reason < 2* _trap_hist_limit) failed: oob
Reviewed-by: kvn, never, dlong
1 parent 3c10b5d commit 6f0e8da

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@
558558
declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \
559559
declare_constant(Deoptimization::Reason_unresolved) \
560560
declare_constant(Deoptimization::Reason_jsr_mismatch) \
561-
declare_constant(Deoptimization::Reason_LIMIT) \
562-
declare_constant(Deoptimization::_support_large_access_byte_array_virtualization) \
561+
declare_constant(Deoptimization::Reason_TRAP_HISTORY_LENGTH) \
562+
declare_constant(Deoptimization::_support_large_access_byte_array_virtualization) \
563563
\
564564
declare_constant(FieldInfo::access_flags_offset) \
565565
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
@@ -30,6 +30,7 @@
3030
#include "oops/method.hpp"
3131
#include "oops/oop.hpp"
3232
#include "runtime/atomic.hpp"
33+
#include "runtime/deoptimization.hpp"
3334
#include "runtime/mutex.hpp"
3435
#include "utilities/align.hpp"
3536
#include "utilities/copy.hpp"
@@ -1965,7 +1966,7 @@ class MethodData : public Metadata {
19651966

19661967
// Whole-method sticky bits and flags
19671968
enum {
1968-
_trap_hist_limit = 25 JVMCI_ONLY(+5), // decoupled from Deoptimization::Reason_LIMIT
1969+
_trap_hist_limit = Deoptimization::Reason_TRAP_HISTORY_LENGTH,
19691970
_trap_hist_mask = max_jubyte,
19701971
_extra_data_count = 4 // extra DataLayout headers, for trap history
19711972
}; // Public flag values
@@ -1980,6 +1981,7 @@ class MethodData : public Metadata {
19801981
uint _nof_overflow_traps; // trap count, excluding _trap_hist
19811982
union {
19821983
intptr_t _align;
1984+
// JVMCI separates trap history for OSR compilations from normal compilations
19831985
u1 _array[JVMCI_ONLY(2 *) MethodData::_trap_hist_limit];
19841986
} _trap_hist;
19851987

@@ -1996,14 +1998,14 @@ class MethodData : public Metadata {
19961998

19971999
// Return (uint)-1 for overflow.
19982000
uint trap_count(int reason) const {
1999-
assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob");
2001+
assert((uint)reason < ARRAY_SIZE(_trap_hist._array), "oob");
20002002
return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1;
20012003
}
20022004

20032005
uint inc_trap_count(int reason) {
20042006
// Count another trap, anywhere in this method.
20052007
assert(reason >= 0, "must be single trap");
2006-
assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob");
2008+
assert((uint)reason < ARRAY_SIZE(_trap_hist._array), "oob");
20072009
uint cnt1 = 1 + _trap_hist._array[reason];
20082010
if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow...
20092011
_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
@@ -2279,7 +2279,8 @@ Deoptimization::query_update_method_data(MethodData* trap_mdo,
22792279
uint idx = reason;
22802280
#if INCLUDE_JVMCI
22812281
if (is_osr) {
2282-
idx += Reason_LIMIT;
2282+
// Upper half of history array used for traps in OSR compilations
2283+
idx += Reason_TRAP_HISTORY_LENGTH;
22832284
}
22842285
#endif
22852286
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
@@ -46,6 +46,7 @@ class Deoptimization : AllStatic {
4646

4747
public:
4848
// What condition caused the deoptimization?
49+
// Note: Keep this enum in sync. with Deoptimization::_trap_reason_name.
4950
enum DeoptReason {
5051
Reason_many = -1, // indicates presence of several reasons
5152
Reason_none = 0, // indicates absence of a relevant deopt.
@@ -98,28 +99,29 @@ class Deoptimization : AllStatic {
9899
Reason_jsr_mismatch,
99100
#endif
100101

102+
// Used to define MethodData::_trap_hist_limit where Reason_tenured isn't included
103+
Reason_TRAP_HISTORY_LENGTH,
104+
101105
// Reason_tenured is counted separately, add normal counted Reasons above.
102-
// Related to MethodData::_trap_hist_limit where Reason_tenured isn't included
103-
Reason_tenured, // age of the code has reached the limit
106+
Reason_tenured = Reason_TRAP_HISTORY_LENGTH, // age of the code has reached the limit
104107
Reason_LIMIT,
105108

106-
// Note: Keep this enum in sync. with _trap_reason_name.
107-
Reason_RECORDED_LIMIT = Reason_profile_predicate // some are not recorded per bc
108109
// Note: Reason_RECORDED_LIMIT should fit into 31 bits of
109110
// DataLayout::trap_bits. This dependency is enforced indirectly
110111
// via asserts, to avoid excessive direct header-to-header dependencies.
111112
// See Deoptimization::trap_state_reason and class DataLayout.
113+
Reason_RECORDED_LIMIT = Reason_profile_predicate, // some are not recorded per bc
112114
};
113115

114116
// What action must be taken by the runtime?
117+
// Note: Keep this enum in sync. with Deoptimization::_trap_action_name.
115118
enum DeoptAction {
116119
Action_none, // just interpret, do not invalidate nmethod
117120
Action_maybe_recompile, // recompile the nmethod; need not invalidate
118121
Action_reinterpret, // invalidate the nmethod, reset IC, maybe recompile
119122
Action_make_not_entrant, // invalidate the nmethod, recompile (probably)
120123
Action_make_not_compilable, // invalidate the nmethod and do not compile
121124
Action_LIMIT
122-
// Note: Keep this enum in sync. with _trap_action_name.
123125
};
124126

125127
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
@@ -336,7 +336,7 @@ final int baseVtableLength() {
336336
final int deoptReasonLoopLimitCheck = getConstant("Deoptimization::Reason_loop_limit_check", Integer.class);
337337
final int deoptReasonAliasing = getConstant("Deoptimization::Reason_aliasing", Integer.class);
338338
final int deoptReasonTransferToInterpreter = getConstant("Deoptimization::Reason_transfer_to_interpreter", Integer.class);
339-
final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_LIMIT", Integer.class);
339+
final int deoptReasonOSROffset = getConstant("Deoptimization::Reason_TRAP_HISTORY_LENGTH", Integer.class);
340340

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

0 commit comments

Comments
 (0)