8204209: [Graal] Compilation fails during nmethod printing with "assert(bci == 0 || 0 <= bci && bci < code_size()) failed: illegal bci"

Tolerate JVMCI placeholder bcis

Reviewed-by: kvn, never, dlong
This commit is contained in:
Igor Veresov 2018-06-22 15:58:32 -07:00
parent b84c23399e
commit 90c4e07b60
7 changed files with 48 additions and 11 deletions

View File

@ -2599,6 +2599,16 @@ void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin,
st->move_to(column);
if (sd->bci() == SynchronizationEntryBCI) {
st->print(";*synchronization entry");
} else if (sd->bci() == AfterBci) {
st->print(";* method exit (unlocked if synchronized)");
} else if (sd->bci() == UnwindBci) {
st->print(";* unwind (locked if synchronized)");
} else if (sd->bci() == AfterExceptionBci) {
st->print(";* unwind (unlocked if synchronized)");
} else if (sd->bci() == UnknownBci) {
st->print(";* unknown");
} else if (sd->bci() == InvalidFrameStateBci) {
st->print(";* invalid frame state");
} else {
if (sd->method() == NULL) {
st->print("method is NULL");

View File

@ -41,7 +41,13 @@ inline const char* compilertype2name(CompilerType t) { return (uint)t < compiler
// Handy constants for deciding which compiler mode to use.
enum MethodCompilation {
InvocationEntryBci = -1 // i.e., not a on-stack replacement compilation
InvocationEntryBci = -1, // i.e., not a on-stack replacement compilation
BeforeBci = InvocationEntryBci,
AfterBci = -2,
UnwindBci = -3,
AfterExceptionBci = -4,
UnknownBci = -5,
InvalidFrameStateBci = -6
};
// Enumeration to distinguish tiers of compilation

View File

@ -1048,6 +1048,26 @@ void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode sc
record_scope(pc_offset, position, scope_mode, objectMapping, return_oop, CHECK);
}
int CodeInstaller::map_jvmci_bci(int bci) {
if (bci < 0) {
if (bci == BytecodeFrame::BEFORE_BCI()) {
return BeforeBci;
} else if (bci == BytecodeFrame::AFTER_BCI()) {
return AfterBci;
} else if (bci == BytecodeFrame::UNWIND_BCI()) {
return UnwindBci;
} else if (bci == BytecodeFrame::AFTER_EXCEPTION_BCI()) {
return AfterExceptionBci;
} else if (bci == BytecodeFrame::UNKNOWN_BCI()) {
return UnknownBci;
} else if (bci == BytecodeFrame::INVALID_FRAMESTATE_BCI()) {
return InvalidFrameStateBci;
}
ShouldNotReachHere();
}
return bci;
}
void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool return_oop, TRAPS) {
Handle frame;
if (scope_mode == CodeInstaller::FullFrame) {
@ -1063,16 +1083,13 @@ void CodeInstaller::record_scope(jint pc_offset, Handle position, ScopeMode scop
Handle hotspot_method (THREAD, BytecodePosition::method(position));
Method* method = getMethodFromHotSpotMethod(hotspot_method());
jint bci = BytecodePosition::bci(position);
if (bci == BytecodeFrame::BEFORE_BCI()) {
bci = SynchronizationEntryBCI;
}
jint bci = map_jvmci_bci(BytecodePosition::bci(position));
TRACE_jvmci_2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string());
bool reexecute = false;
if (frame.not_null()) {
if (bci == SynchronizationEntryBCI){
if (bci < 0) {
reexecute = false;
} else {
Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));

View File

@ -255,6 +255,7 @@ protected:
FullFrame
};
int map_jvmci_bci(int bci);
void record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS);
void record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, TRAPS) {
record_scope(pc_offset, debug_info, scope_mode, false /* return_oop */, THREAD);

View File

@ -210,7 +210,12 @@ class JVMCIJavaClasses : AllStatic {
int_field(BytecodeFrame, numLocks) \
boolean_field(BytecodeFrame, rethrowException) \
boolean_field(BytecodeFrame, duringCall) \
static_int_field(BytecodeFrame, UNKNOWN_BCI) \
static_int_field(BytecodeFrame, UNWIND_BCI) \
static_int_field(BytecodeFrame, BEFORE_BCI) \
static_int_field(BytecodeFrame, AFTER_BCI) \
static_int_field(BytecodeFrame, AFTER_EXCEPTION_BCI) \
static_int_field(BytecodeFrame, INVALID_FRAMESTATE_BCI) \
end_class \
start_class(BytecodePosition) \
oop_field(BytecodePosition, caller, "Ljdk/vm/ci/code/BytecodePosition;") \

View File

@ -690,12 +690,10 @@ objArrayHandle Method::resolved_checked_exceptions_impl(Method* method, TRAPS) {
int Method::line_number_from_bci(int bci) const {
if (bci == SynchronizationEntryBCI) bci = 0;
assert(bci == 0 || 0 <= bci && bci < code_size(), "illegal bci");
int best_bci = 0;
int best_line = -1;
if (has_linenumber_table()) {
if (bci == SynchronizationEntryBCI) bci = 0;
if (0 <= bci && bci < code_size() && has_linenumber_table()) {
// The line numbers are a short array of 2-tuples [start_pc, line_number].
// Not necessarily sorted and not necessarily one-to-one.
CompressedLineNumberReadStream stream(compressed_linenumber_table());

View File

@ -269,7 +269,7 @@ void JvmtiCodeBlobEvents::build_jvmti_addr_location_map(nmethod *nm,
ScopeDesc *sd = &sc0;
while( !sd->is_top() ) { sd = sd->sender(); }
int bci = sd->bci();
if (bci != InvocationEntryBci) {
if (bci >= 0) {
assert(map_length < pcds_in_method, "checking");
map[map_length].start_address = (const void*)pcd->real_pc(nm);
map[map_length].location = bci;