Skip to content

Commit

Permalink
8276095: ciReplay: replay failure due to incomplete ciMethodData info…
Browse files Browse the repository at this point in the history
…rmation

Reviewed-by: chagedorn, kvn
  • Loading branch information
dean-long committed Nov 15, 2021
1 parent 7a87041 commit 9326eb1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,7 @@ void ciEnv::dump_replay_data_helper(outputStream* out) {
NoSafepointVerifier no_safepoint;
ResourceMark rm;

out->print_cr("version %d", REPLAY_VERSION);
#if INCLUDE_JVMTI
out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables);
out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint);
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/share/ci/ciMethodData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ ciMethodData::ciMethodData(MethodData* md)
_saw_free_extra_data(false),
// Initialize the escape information (to "don't know.");
_eflags(0), _arg_local(0), _arg_stack(0), _arg_returned(0),
_creation_mileage(0),
_current_mileage(0),
_invocation_counter(0),
_backedge_counter(0),
_orig(),
_parameters(NULL) {}

Expand Down Expand Up @@ -250,10 +247,7 @@ bool ciMethodData::load_data() {
load_remaining_extra_data();

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

_eflags = mdo->eflags();
Expand Down Expand Up @@ -706,7 +700,7 @@ void ciMethodData::dump_replay_data(outputStream* out) {
Method* method = mdo->method();
out->print("ciMethodData ");
ciMethod::dump_name_as_ascii(out, method);
out->print(" %d %d", _state, current_mileage());
out->print(" %d %d", _state, _invocation_counter);

// dump the contents of the MDO header as raw data
unsigned char* orig = (unsigned char*)&_orig;
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/share/ci/ciMethodData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,10 @@ class ciMethodData : public ciMetadata {
intx _arg_stack; // bit set of stack-allocatable arguments
intx _arg_returned; // bit set of returned arguments

int _creation_mileage; // method mileage at MDO creation

// Maturity of the oop when the snapshot is taken.
int _current_mileage;

// These counters hold the age of MDO in tiered. In tiered we can have the same method
// running at different compilation levels concurrently. So, in order to precisely measure
// its maturity we need separate counters.
int _invocation_counter;
int _backedge_counter;

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

int creation_mileage() { return _creation_mileage; }
int current_mileage() { return _current_mileage; }

int invocation_count() { return _invocation_counter; }
int backedge_count() { return _backedge_counter; }

#if INCLUDE_RTM_OPT
// return cached value
Expand Down
40 changes: 26 additions & 14 deletions src/hotspot/share/ci/ciReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct _ciMethodDataRecord {
const char* _signature;

int _state;
int _current_mileage;
int _invocation_counter;

intptr_t* _data;
char* _orig_data;
Expand Down Expand Up @@ -115,6 +115,7 @@ class CompileReplay : public StackObj {
Handle _protection_domain;
bool _protection_domain_initialized;
Handle _loader;
int _version;

GrowableArray<ciMethodRecord*> _ci_method_records;
GrowableArray<ciMethodDataRecord*> _ci_method_data_records;
Expand Down Expand Up @@ -159,6 +160,7 @@ class CompileReplay : public StackObj {
_iklass = NULL;
_entry_bci = 0;
_comp_level = 0;
_version = 0;

test();
}
Expand Down Expand Up @@ -638,6 +640,11 @@ class CompileReplay : public StackObj {
tty->print_cr("# %s", _bufptr);
}
skip_remaining();
} else if (strcmp("version", cmd) == 0) {
_version = parse_int("version");
if (_version < 0 || _version > REPLAY_VERSION) {
tty->print_cr("# unrecognized version %d, expected 0 <= version <= %d", _version, REPLAY_VERSION);
}
} else if (strcmp("compile", cmd) == 0) {
process_compile(CHECK);
} else if (strcmp("ciMethod", cmd) == 0) {
Expand Down Expand Up @@ -802,7 +809,7 @@ class CompileReplay : public StackObj {
rec->_instructions_size = parse_int("instructions_size");
}

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

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

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

_protection_domain_initialized = true;
}

if (k == NULL) {
return;
Expand Down Expand Up @@ -1413,7 +1425,7 @@ void ciReplay::initialize(ciMethodData* m) {
tty->cr();
} else {
m->_state = rec->_state;
m->_current_mileage = rec->_current_mileage;
m->_invocation_counter = rec->_invocation_counter;
if (rec->_data_length != 0) {
assert(m->_data_size + m->_extra_data_size == rec->_data_length * (int)sizeof(rec->_data[0]) ||
m->_data_size == rec->_data_length * (int)sizeof(rec->_data[0]), "must agree");
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/ci/ciReplay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,10 @@ class ciReplay {

};

// Replay file format version history
// 0: legacy (no version number)
// 1: first instanceKlass sets protection domain (8275868)
// replace current_mileage with invocation_count (8276095)
#define REPLAY_VERSION 1 // current version, bump up for incompatible changes

#endif // SHARE_CI_CIREPLAY_HPP
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/vmStructs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@
nonstatic_field(ciMethodData, _arg_local, intx) \
nonstatic_field(ciMethodData, _arg_stack, intx) \
nonstatic_field(ciMethodData, _arg_returned, intx) \
nonstatic_field(ciMethodData, _current_mileage, int) \
nonstatic_field(ciMethodData, _orig, MethodData::CompilerCounters) \
\
nonstatic_field(ciField, _holder, ciInstanceKlass*) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ public void update(Observable o, Object data) {
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
Type type = db.lookupType("ciMethodData");
origField = type.getField("_orig");
currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
argReturnedField = new CIntField(type.getCIntegerField("_arg_returned"), 0);
argStackField = new CIntField(type.getCIntegerField("_arg_stack"), 0);
argLocalField = new CIntField(type.getCIntegerField("_arg_local"), 0);
eflagsField = new CIntField(type.getCIntegerField("_eflags"), 0);
hintDiField = new CIntField(type.getCIntegerField("_hint_di"), 0);
currentMileageField = new CIntField(type.getCIntegerField("_current_mileage"), 0);
dataField = type.getAddressField("_data");
extraDataSizeField = new CIntField(type.getCIntegerField("_extra_data_size"), 0);
dataSizeField = new CIntField(type.getCIntegerField("_data_size"), 0);
Expand All @@ -63,7 +61,6 @@ private static synchronized void initialize(TypeDataBase db) throws WrongTypeExc
}

private static Field origField;
private static CIntField currentMileageField;
private static CIntField argReturnedField;
private static CIntField argStackField;
private static CIntField argLocalField;
Expand Down Expand Up @@ -141,7 +138,7 @@ int state() {
}

int currentMileage() {
return (int)currentMileageField.getValue(getAddress());
return 0;
}

boolean outOfBounds(int dataIndex) {
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/compiler/ciReplay/TestLambdas.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @test
* @bug 8275670
* @library / /test/lib
* @summary testing of ciReplay with inlining
* @summary testing of ciReplay with nested BoundMethodHandles
* @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.compiler2.enabled
* @modules java.base/jdk.internal.misc
* @build sun.hotspot.WhiteBox
Expand Down

1 comment on commit 9326eb1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.