Skip to content

Commit 9326eb1

Browse files
committedNov 15, 2021
8276095: ciReplay: replay failure due to incomplete ciMethodData information
Reviewed-by: chagedorn, kvn
1 parent 7a87041 commit 9326eb1

File tree

8 files changed

+36
-37
lines changed

8 files changed

+36
-37
lines changed
 

‎src/hotspot/share/ci/ciEnv.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,7 @@ void ciEnv::dump_replay_data_helper(outputStream* out) {
16431643
NoSafepointVerifier no_safepoint;
16441644
ResourceMark rm;
16451645

1646+
out->print_cr("version %d", REPLAY_VERSION);
16461647
#if INCLUDE_JVMTI
16471648
out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables);
16481649
out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint);

‎src/hotspot/share/ci/ciMethodData.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ ciMethodData::ciMethodData(MethodData* md)
4949
_saw_free_extra_data(false),
5050
// Initialize the escape information (to "don't know.");
5151
_eflags(0), _arg_local(0), _arg_stack(0), _arg_returned(0),
52-
_creation_mileage(0),
53-
_current_mileage(0),
5452
_invocation_counter(0),
55-
_backedge_counter(0),
5653
_orig(),
5754
_parameters(NULL) {}
5855

@@ -250,10 +247,7 @@ bool ciMethodData::load_data() {
250247
load_remaining_extra_data();
251248

252249
// Note: Extra data are all BitData, and do not need translation.
253-
_creation_mileage = mdo->creation_mileage();
254-
_current_mileage = MethodData::mileage_of(mdo->method());
255250
_invocation_counter = mdo->invocation_count();
256-
_backedge_counter = mdo->backedge_count();
257251
_state = mdo->is_mature()? mature_state: immature_state;
258252

259253
_eflags = mdo->eflags();
@@ -706,7 +700,7 @@ void ciMethodData::dump_replay_data(outputStream* out) {
706700
Method* method = mdo->method();
707701
out->print("ciMethodData ");
708702
ciMethod::dump_name_as_ascii(out, method);
709-
out->print(" %d %d", _state, current_mileage());
703+
out->print(" %d %d", _state, _invocation_counter);
710704

711705
// dump the contents of the MDO header as raw data
712706
unsigned char* orig = (unsigned char*)&_orig;

‎src/hotspot/share/ci/ciMethodData.hpp

-10
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,10 @@ class ciMethodData : public ciMetadata {
395395
intx _arg_stack; // bit set of stack-allocatable arguments
396396
intx _arg_returned; // bit set of returned arguments
397397

398-
int _creation_mileage; // method mileage at MDO creation
399-
400-
// Maturity of the oop when the snapshot is taken.
401-
int _current_mileage;
402-
403398
// These counters hold the age of MDO in tiered. In tiered we can have the same method
404399
// running at different compilation levels concurrently. So, in order to precisely measure
405400
// its maturity we need separate counters.
406401
int _invocation_counter;
407-
int _backedge_counter;
408402

409403
// Coherent snapshot of original header.
410404
MethodData::CompilerCounters _orig;
@@ -477,11 +471,7 @@ class ciMethodData : public ciMetadata {
477471
bool is_empty() { return _state == empty_state; }
478472
bool is_mature() { return _state == mature_state; }
479473

480-
int creation_mileage() { return _creation_mileage; }
481-
int current_mileage() { return _current_mileage; }
482-
483474
int invocation_count() { return _invocation_counter; }
484-
int backedge_count() { return _backedge_counter; }
485475

486476
#if INCLUDE_RTM_OPT
487477
// return cached value

‎src/hotspot/share/ci/ciReplay.cpp

+26-14
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef struct _ciMethodDataRecord {
6565
const char* _signature;
6666

6767
int _state;
68-
int _current_mileage;
68+
int _invocation_counter;
6969

7070
intptr_t* _data;
7171
char* _orig_data;
@@ -115,6 +115,7 @@ class CompileReplay : public StackObj {
115115
Handle _protection_domain;
116116
bool _protection_domain_initialized;
117117
Handle _loader;
118+
int _version;
118119

119120
GrowableArray<ciMethodRecord*> _ci_method_records;
120121
GrowableArray<ciMethodDataRecord*> _ci_method_data_records;
@@ -159,6 +160,7 @@ class CompileReplay : public StackObj {
159160
_iklass = NULL;
160161
_entry_bci = 0;
161162
_comp_level = 0;
163+
_version = 0;
162164

163165
test();
164166
}
@@ -638,6 +640,11 @@ class CompileReplay : public StackObj {
638640
tty->print_cr("# %s", _bufptr);
639641
}
640642
skip_remaining();
643+
} else if (strcmp("version", cmd) == 0) {
644+
_version = parse_int("version");
645+
if (_version < 0 || _version > REPLAY_VERSION) {
646+
tty->print_cr("# unrecognized version %d, expected 0 <= version <= %d", _version, REPLAY_VERSION);
647+
}
641648
} else if (strcmp("compile", cmd) == 0) {
642649
process_compile(CHECK);
643650
} else if (strcmp("ciMethod", cmd) == 0) {
@@ -802,7 +809,7 @@ class CompileReplay : public StackObj {
802809
rec->_instructions_size = parse_int("instructions_size");
803810
}
804811

805-
// ciMethodData <klass> <name> <signature> <state> <current_mileage> orig <length> <byte>* data <length> <ptr>* oops <length> (<offset> <klass>)* methods <length> (<offset> <klass> <name> <signature>)*
812+
// ciMethodData <klass> <name> <signature> <state> <invocation_counter> orig <length> <byte>* data <length> <ptr>* oops <length> (<offset> <klass>)* methods <length> (<offset> <klass> <name> <signature>)*
806813
void process_ciMethodData(TRAPS) {
807814
Method* method = parse_method(CHECK);
808815
if (had_error()) return;
@@ -827,7 +834,11 @@ class CompileReplay : public StackObj {
827834
// collect and record all the needed information for later
828835
ciMethodDataRecord* rec = new_ciMethodData(method);
829836
rec->_state = parse_int("state");
830-
rec->_current_mileage = parse_int("current_mileage");
837+
if (_version < 1) {
838+
parse_int("current_mileage");
839+
} else {
840+
rec->_invocation_counter = parse_int("invocation_counter");
841+
}
831842

832843
rec->_orig_data = parse_data("orig", rec->_orig_data_length);
833844
if (rec->_orig_data == NULL) {
@@ -876,17 +887,18 @@ class CompileReplay : public StackObj {
876887
void process_instanceKlass(TRAPS) {
877888
// just load the referenced class
878889
Klass* k = parse_klass(CHECK);
879-
if (!_protection_domain_initialized && k != NULL) {
880-
assert(_protection_domain() == NULL, "must be uninitialized");
881-
// The first entry is the holder class of the method for which a replay compilation is requested.
882-
// Use the same protection domain to load all subsequent classes in order to resolve all classes
883-
// in signatures of inlinees. This ensures that inlining can be done as stated in the replay file.
884-
_protection_domain = Handle(_thread, k->protection_domain());
885-
}
886890

887-
// Only initialize the protection domain handle with the protection domain of the very first entry.
888-
// This also ensures that older replay files work.
889-
_protection_domain_initialized = true;
891+
if (_version >= 1) {
892+
if (!_protection_domain_initialized && k != NULL) {
893+
assert(_protection_domain() == NULL, "must be uninitialized");
894+
// The first entry is the holder class of the method for which a replay compilation is requested.
895+
// Use the same protection domain to load all subsequent classes in order to resolve all classes
896+
// in signatures of inlinees. This ensures that inlining can be done as stated in the replay file.
897+
_protection_domain = Handle(_thread, k->protection_domain());
898+
}
899+
900+
_protection_domain_initialized = true;
901+
}
890902

891903
if (k == NULL) {
892904
return;
@@ -1413,7 +1425,7 @@ void ciReplay::initialize(ciMethodData* m) {
14131425
tty->cr();
14141426
} else {
14151427
m->_state = rec->_state;
1416-
m->_current_mileage = rec->_current_mileage;
1428+
m->_invocation_counter = rec->_invocation_counter;
14171429
if (rec->_data_length != 0) {
14181430
assert(m->_data_size + m->_extra_data_size == rec->_data_length * (int)sizeof(rec->_data[0]) ||
14191431
m->_data_size == rec->_data_length * (int)sizeof(rec->_data[0]), "must agree");

‎src/hotspot/share/ci/ciReplay.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,10 @@ class ciReplay {
131131

132132
};
133133

134+
// Replay file format version history
135+
// 0: legacy (no version number)
136+
// 1: first instanceKlass sets protection domain (8275868)
137+
// replace current_mileage with invocation_count (8276095)
138+
#define REPLAY_VERSION 1 // current version, bump up for incompatible changes
139+
134140
#endif // SHARE_CI_CIREPLAY_HPP

‎src/hotspot/share/runtime/vmStructs.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@
824824
nonstatic_field(ciMethodData, _arg_local, intx) \
825825
nonstatic_field(ciMethodData, _arg_stack, intx) \
826826
nonstatic_field(ciMethodData, _arg_returned, intx) \
827-
nonstatic_field(ciMethodData, _current_mileage, int) \
828827
nonstatic_field(ciMethodData, _orig, MethodData::CompilerCounters) \
829828
\
830829
nonstatic_field(ciField, _holder, ciInstanceKlass*) \

‎src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ci/ciMethodData.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ public void update(Observable o, Object data) {
4646
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
4747
Type type = db.lookupType("ciMethodData");
4848
origField = type.getField("_orig");
49-
currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
5049
argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0);
5150
argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0);
5251
argLocalField = new CIntField(type.getCIntegerField("_arg_local"), 0);
5352
eflagsField = new CIntField(type.getCIntegerField("_eflags"), 0);
5453
hintDiField = new CIntField(type.getCIntegerField("_hint_di"), 0);
55-
currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
5654
dataField = type.getAddressField("_data");
5755
extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0);
5856
dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0);
@@ -63,7 +61,6 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
6361
}
6462

6563
private static Field origField;
66-
private static CIntField currentMileageField;
6764
private static CIntField argReturnedField;
6865
private static CIntField argStackField;
6966
private static CIntField argLocalField;
@@ -141,7 +138,7 @@ int state() {
141138
}
142139

143140
int currentMileage() {
144-
return (int)currentMileageField.getValue(getAddress());
141+
return 0;
145142
}
146143

147144
boolean outOfBounds(int dataIndex) {

‎test/hotspot/jtreg/compiler/ciReplay/TestLambdas.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @test
2626
* @bug 8275670
2727
* @library / /test/lib
28-
* @summary testing of ciReplay with inlining
28+
* @summary testing of ciReplay with nested BoundMethodHandles
2929
* @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.compiler2.enabled
3030
* @modules java.base/jdk.internal.misc
3131
* @build sun.hotspot.WhiteBox

0 commit comments

Comments
 (0)
Please sign in to comment.