Skip to content

Commit e99b026

Browse files
author
Michael Haas
committed
Restrict new bind logic to static calls only.
1 parent be1292e commit e99b026

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

src/hotspot/share/runtime/sharedRuntime.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,17 +1219,8 @@ Handle SharedRuntime::find_callee_info_helper(vframeStream& vfst, Bytecodes::Cod
12191219
// For invoke bytecodes, the reexecute bit is not set (see Interpreter::bytecode_should_reexecute).
12201220
// Since the reexecute bit is set for this call, no corresponding invoke bytecode exists.
12211221
Method* callee = attached_method();
1222-
if (attached_method->is_static()) {
1223-
bc = Bytecodes::_invokestatic;
1224-
} else {
1225-
receiver = Handle(current, callerFrame.retrieve_receiver(&reg_map2));
1226-
if (attached_method->method_holder()->is_interface()) {
1227-
bc = Bytecodes::_invokeinterface;
1228-
} else {
1229-
bc = Bytecodes::_invokevirtual;
1230-
}
1231-
}
1232-
1222+
assert(attached_method->is_static(), "attached method should be static");
1223+
bc = Bytecodes::_invokestatic;
12331224
LinkResolver::resolve_invoke(callinfo, receiver, attached_method, bc, CHECK_NH);
12341225
return receiver;
12351226
}

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

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,7 @@
5959
public class TestMethodBinding extends CodeInstallationTest {
6060

6161

62-
interface MethodProviderInterface {
63-
int invokeInterface();
64-
}
65-
66-
static abstract class AbstractMethodProvider implements MethodProviderInterface {
67-
public int invokeVirtual() {
68-
return 5 + 6;
69-
}
70-
}
71-
72-
static class MethodProvider extends AbstractMethodProvider {
73-
@Override
74-
public int invokeInterface() {
75-
return 3 + 4;
76-
}
77-
62+
static class MethodProvider {
7863
public static int invokeStatic() {
7964
return 1 + 2;
8065
}
@@ -83,19 +68,10 @@ public static int invokeStatic() {
8368
@Test
8469
public void test() {
8570
Class<?> returnType = int.class;
86-
Object receiver = new MethodProvider();
8771
Class<?>[] staticArgumentTypes = new Class<?>[]{};
88-
Class<?>[] interfaceArgumentTypes = new Class<?>[]{MethodProviderInterface.class};
89-
Class<?>[] virtualArgumentTypes = new Class<?>[]{AbstractMethodProvider.class};
9072
Object[] staticArguments = new Object[]{};
91-
Object[] interfaceArguments = new Object[]{receiver};
92-
Object[] virtualArguments = interfaceArguments;
93-
9473

95-
test(getMethod(MethodProvider.class, "invokeInterface"), returnType, interfaceArgumentTypes, virtualArguments, config.MARKID_INVOKEINTERFACE);
9674
test(getMethod(MethodProvider.class, "invokeStatic"), returnType, staticArgumentTypes, staticArguments, config.MARKID_INVOKESTATIC);
97-
test(getMethod(AbstractMethodProvider.class, "invokeVirtual"), returnType, virtualArgumentTypes, virtualArguments, config.MARKID_INVOKEVIRTUAL);
98-
test(getMethod(MethodProvider.class, "invokeInterface"), returnType, virtualArgumentTypes, virtualArguments, config.MARKID_INVOKESPECIAL);
9975
}
10076

10177

@@ -120,6 +96,8 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
12096

12197
asm.recordMark(markId);
12298
int[] pos = new int[2];
99+
// duringCall has to be false to trigger our bind logic in SharedRuntime::find_callee_info_helper
100+
// we are allowed to do this because the call has no side-effect
123101
BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, 0, false, false, new JavaValue[0], new JavaKind[0], 0, 0, 0);
124102
DebugInfo info = new DebugInfo(frame, new VirtualObject[0]);
125103
if (resolvedMethod.isStatic()) {

0 commit comments

Comments
 (0)