Skip to content

Commit 21759a9

Browse files
author
Michael Haas
committed
Rely on the reexecute bit to decide if the JVMCI logic should be used.
1 parent e5de029 commit 21759a9

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/hotspot/share/runtime/sharedRuntime.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include "runtime/synchronizer.inline.hpp"
7575
#include "runtime/timerTrace.hpp"
7676
#include "runtime/vframe.inline.hpp"
77+
#include "runtime/vframe_hp.hpp"
7778
#include "runtime/vframeArray.hpp"
7879
#include "runtime/vm_version.hpp"
7980
#include "utilities/copy.hpp"
@@ -1201,29 +1202,40 @@ Handle SharedRuntime::find_callee_info_helper(vframeStream& vfst, Bytecodes::Cod
12011202
bool caller_is_jvmci = vfst.nm()->is_compiled_by_jvmci();
12021203

12031204
if (!trust_bytecode && attached_method.not_null() && caller_is_jvmci) {
1204-
// invoke does not correspond to bytecode
12051205
RegisterMap reg_map2(current,
12061206
RegisterMap::UpdateMap::include,
12071207
RegisterMap::ProcessFrames::include,
12081208
RegisterMap::WalkContinuation::skip);
12091209
frame stubFrame = current->last_frame();
12101210
frame callerFrame = stubFrame.sender(&reg_map2);
1211-
1212-
Method* callee = attached_method();
1213-
1214-
if (attached_method->is_static()) {
1215-
bc = Bytecodes::_invokestatic;
1216-
} else {
1217-
receiver = Handle(current, callerFrame.retrieve_receiver(&reg_map2));
1218-
if (attached_method->method_holder()->is_interface()) {
1219-
bc = Bytecodes::_invokeinterface;
1211+
javaVFrame* jVFrame = vfst.asJavaVFrame();
1212+
assert(jVFrame->is_compiled_frame(), "should be compiled frame");
1213+
compiledVFrame* cVFrame = (compiledVFrame*) jVFrame;
1214+
bool should_reexecute = cVFrame->should_reexecute();
1215+
Bytecodes::Code code = caller->java_code_at(bci);
1216+
// TODO for Valhalla: If the bytecode is if_acmpeq or if_acmpne and the attached method performs a substitutability check, skip this logic.
1217+
// Valhalla adds handling for substitutability checks in this method.
1218+
bool is_substitutability_check = (code == Bytecodes::_if_acmpeq || code == Bytecodes::_if_acmpne) && false;
1219+
if (cVFrame->should_reexecute() && !is_substitutability_check) {
1220+
// For invoke bytecodes, the reexecute bit is not set (see Interpreter::bytecode_should_reexecute).
1221+
// Since the reexecute bit is set for this call, no corresponding invoke bytecode exists.
1222+
Method* callee = attached_method();
1223+
if (attached_method->is_static()) {
1224+
bc = Bytecodes::_invokestatic;
12201225
} else {
1221-
bc = Bytecodes::_invokevirtual;
1226+
receiver = Handle(current, callerFrame.retrieve_receiver(&reg_map2));
1227+
if (attached_method->method_holder()->is_interface()) {
1228+
bc = Bytecodes::_invokeinterface;
1229+
} else {
1230+
bc = Bytecodes::_invokevirtual;
1231+
}
12221232
}
1233+
1234+
LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
1235+
return receiver;
12231236
}
12241237

1225-
LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
1226-
return receiver;
1238+
12271239
}
12281240
#else
12291241
methodHandle attached_method(THREAD, extract_attached_method(vfst));

test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestMethodBinding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
120120

121121
asm.recordMark(markId);
122122
int[] pos = new int[2];
123-
BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, 0, false, true, new JavaValue[0], new JavaKind[0], 0, 0, 0);
123+
BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, 0, false, false, new JavaValue[0], new JavaKind[0], 0, 0, 0);
124124
DebugInfo info = new DebugInfo(frame, new VirtualObject[0]);
125125
if (resolvedMethod.isStatic()) {
126126
info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));

0 commit comments

Comments
 (0)