Skip to content

Commit 61dca0c

Browse files
author
Michael Haas
committed
Remove non-static logic again.
1 parent b9fb31f commit 61dca0c

File tree

5 files changed

+16
-52
lines changed

5 files changed

+16
-52
lines changed

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import org.junit.Assert;
4545

4646
import java.lang.reflect.Method;
47-
import java.util.ArrayList;
48-
import java.util.List;
4947

5048
/**
5149
* Base class for code installation tests.
@@ -89,24 +87,16 @@ private TestAssembler createAssembler() {
8987
}
9088
}
9189

92-
protected Method getMethod(Class<?> clazz, String name, Class<?>... args) {
90+
protected Method getMethod(String name, Class<?>... args) {
9391
try {
94-
return clazz.getMethod(name, args);
92+
return getClass().getMethod(name, args);
9593
} catch (NoSuchMethodException e) {
9694
Assert.fail("method not found");
9795
return null;
9896
}
9997
}
10098

101-
protected Method getMethod(String name, Class<?>... args) {
102-
return getMethod(getClass(), name, args);
103-
}
104-
10599
protected HotSpotNmethod test(TestCompiler compiler, Method method, Object... args) {
106-
return test(compiler, method, null, args);
107-
}
108-
109-
protected HotSpotNmethod test(TestCompiler compiler, Method method, Object obj, Object... args) {
110100
try {
111101
HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
112102
TestAssembler asm = createAssembler();
@@ -123,13 +113,8 @@ protected HotSpotNmethod test(TestCompiler compiler, Method method, Object obj,
123113
System.out.println(str);
124114
}
125115

126-
Object expected = method.invoke(obj, args);
127-
List<Object> newArgs = new ArrayList<>();
128-
if (obj != null) {
129-
newArgs.add(obj);
130-
}
131-
newArgs.addAll(List.of(args));
132-
Object actual = installed.executeVarargs(newArgs.toArray(new Object[newArgs.size()]));
116+
Object expected = method.invoke(null, args);
117+
Object actual = installed.executeVarargs(args);
133118
Assert.assertEquals(expected, actual);
134119
return (HotSpotNmethod) installed;
135120
} catch (Exception e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ private byte[] finish() {
476476
*/
477477
public abstract void emitCall(long addr);
478478

479-
public void emitJavaCall(int[] pos, DebugInfo info, int markId) {
479+
public void emitJavaCall(int[] pos, DebugInfo info) {
480480
throw new UnsupportedOperationException("Java calls are not supported.");
481481
}
482482

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ public TestHotSpotVMConfig(HotSpotVMConfigStore config, Architecture arch) {
5151
public final int MARKID_FRAME_COMPLETE = getConstant("CodeInstaller::FRAME_COMPLETE", Integer.class);
5252
public final int MARKID_ENTRY_BARRIER_PATCH = getConstant("CodeInstaller::ENTRY_BARRIER_PATCH", Integer.class);
5353
public final long handleDeoptStub = getFieldValue("CompilerToVM::Data::SharedRuntime_deopt_blob_unpack", Long.class, "address");
54-
55-
public final int MARKID_INVOKEINTERFACE = getConstant("CodeInstaller::INVOKEINTERFACE", Integer.class);
56-
public final int MARKID_INVOKEVIRTUAL = getConstant("CodeInstaller::INVOKEVIRTUAL", Integer.class);
54+
5755
public final int MARKID_INVOKESTATIC = getConstant("CodeInstaller::INVOKESTATIC", Integer.class);
58-
public final int MARKID_INVOKESPECIAL = getConstant("CodeInstaller::INVOKESPECIAL", Integer.class);
5956
public final boolean continuationsEnabled = getFieldValue("CompilerToVM::Data::continuations_enabled", Boolean.class, "bool");
6057

6158
public final int maxOopMapStackOffset = getFieldValue("CompilerToVM::Data::_max_oop_map_stack_offset", Integer.class, "int");

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

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
package jdk.vm.ci.code.test;
4242

4343
import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.JavaCall;
44-
import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall;
4544

4645
import jdk.vm.ci.code.*;
4746
import jdk.vm.ci.hotspot.HotSpotReferenceMap;
@@ -53,16 +52,12 @@
5352
import jdk.vm.ci.meta.JavaType;
5453

5554
import java.lang.reflect.Method;
56-
import java.util.ArrayList;
57-
import java.util.List;
5855

5956
public class TestMethodBinding extends CodeInstallationTest {
6057

6158

62-
static class MethodProvider {
63-
public static int invokeStatic() {
64-
return 1 + 2;
65-
}
59+
public static int invokeStatic() {
60+
return 1 + 2;
6661
}
6762

6863
@Test
@@ -71,19 +66,14 @@ public void test() {
7166
Class<?>[] staticArgumentTypes = new Class<?>[]{};
7267
Object[] staticArguments = new Object[]{};
7368

74-
test(getMethod(MethodProvider.class, "invokeStatic"), returnType, staticArgumentTypes, staticArguments, config.MARKID_INVOKESTATIC);
69+
test(getMethod("invokeStatic"), returnType, staticArgumentTypes, staticArguments);
7570
}
7671

7772

78-
public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[] values, int markId) {
73+
public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[] values) {
7974
try {
8075
ResolvedJavaMethod resolvedMethod = metaAccess.lookupJavaMethod(method);
81-
Object obj = null;
82-
List<Object> args = new ArrayList<>(List.of(values));
83-
if (!resolvedMethod.isStatic()) {
84-
obj = values[0];
85-
args.removeFirst();
86-
}
76+
assert resolvedMethod.isStatic() : "method should be static";
8777
test(asm -> {
8878
JavaType[] argTypes = new JavaType[types.length];
8979
int i = 0;
@@ -94,19 +84,14 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
9484
CallingConvention cc = codeCache.getRegisterConfig().getCallingConvention(JavaCall, returnType, argTypes, asm.valueKindFactory);
9585
asm.emitCallPrologue(cc, values);
9686

97-
asm.recordMark(markId);
87+
asm.recordMark(config.MARKID_INVOKESTATIC);
9888
int[] pos = new int[2];
9989
// duringCall has to be false to trigger our bind logic in SharedRuntime::find_callee_info_helper
10090
// we are allowed to do this because the call has no side-effect
10191
BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, 0, false, false, new JavaValue[0], new JavaKind[0], 0, 0, 0);
10292
DebugInfo info = new DebugInfo(frame, new VirtualObject[0]);
103-
if (resolvedMethod.isStatic()) {
104-
info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
105-
} else {
106-
assert values.length == 1 : "Only a receiver argument is allowed";
107-
info.setReferenceMap(new HotSpotReferenceMap(new Location[]{Location.register(((RegisterValue) cc.getArgument(0)).getRegister())}, new Location[]{null}, new int[]{asm.config.heapWordSize}, 8));
108-
}
109-
asm.emitJavaCall(pos, info, markId);
93+
info.setReferenceMap(new HotSpotReferenceMap(new Location[0], new Location[0], new int[0], 8));
94+
asm.emitJavaCall(pos, info);
11095

11196
asm.recordCall(pos[0], pos[1], resolvedMethod, true, true, info);
11297
asm.emitCallEpilogue(cc);
@@ -118,7 +103,7 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
118103
assert false : "Unimplemented return type: " + returnClazz;
119104
}
120105

121-
}, method, obj, args.toArray(new Object[args.size()]));
106+
}, method, values);
122107
} catch (Throwable e) {
123108
e.printStackTrace();
124109
throw e;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,7 @@ private void nop(int count) {
523523
}
524524
}
525525

526-
public void emitJavaCall(int[] pos, DebugInfo info, int markId) {
527-
if (markId == config.MARKID_INVOKEVIRTUAL || markId == config.MARKID_INVOKEINTERFACE) {
528-
emitLoadLong(AMD64.rax, 0);
529-
}
526+
public void emitJavaCall(int[] pos, DebugInfo info) {
530527
int displacementPos = code.position() + 1;
531528
if (displacementPos % 4 != 0) {
532529
nop(4 - displacementPos % 4);

0 commit comments

Comments
 (0)