41
41
package jdk .vm .ci .code .test ;
42
42
43
43
import static jdk .vm .ci .hotspot .HotSpotCallingConventionType .JavaCall ;
44
- import static jdk .vm .ci .hotspot .HotSpotCallingConventionType .NativeCall ;
45
44
46
45
import jdk .vm .ci .code .*;
47
46
import jdk .vm .ci .hotspot .HotSpotReferenceMap ;
53
52
import jdk .vm .ci .meta .JavaType ;
54
53
55
54
import java .lang .reflect .Method ;
56
- import java .util .ArrayList ;
57
- import java .util .List ;
58
55
59
56
public class TestMethodBinding extends CodeInstallationTest {
60
57
61
58
62
- static class MethodProvider {
63
- public static int invokeStatic () {
64
- return 1 + 2 ;
65
- }
59
+ public static int invokeStatic () {
60
+ return 1 + 2 ;
66
61
}
67
62
68
63
@ Test
@@ -71,19 +66,14 @@ public void test() {
71
66
Class <?>[] staticArgumentTypes = new Class <?>[]{};
72
67
Object [] staticArguments = new Object []{};
73
68
74
- test (getMethod (MethodProvider . class , "invokeStatic" ), returnType , staticArgumentTypes , staticArguments , config . MARKID_INVOKESTATIC );
69
+ test (getMethod ("invokeStatic" ), returnType , staticArgumentTypes , staticArguments );
75
70
}
76
71
77
72
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 ) {
79
74
try {
80
75
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" ;
87
77
test (asm -> {
88
78
JavaType [] argTypes = new JavaType [types .length ];
89
79
int i = 0 ;
@@ -94,19 +84,14 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
94
84
CallingConvention cc = codeCache .getRegisterConfig ().getCallingConvention (JavaCall , returnType , argTypes , asm .valueKindFactory );
95
85
asm .emitCallPrologue (cc , values );
96
86
97
- asm .recordMark (markId );
87
+ asm .recordMark (config . MARKID_INVOKESTATIC );
98
88
int [] pos = new int [2 ];
99
89
// duringCall has to be false to trigger our bind logic in SharedRuntime::find_callee_info_helper
100
90
// we are allowed to do this because the call has no side-effect
101
91
BytecodeFrame frame = new BytecodeFrame (null , resolvedMethod , 0 , false , false , new JavaValue [0 ], new JavaKind [0 ], 0 , 0 , 0 );
102
92
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 );
110
95
111
96
asm .recordCall (pos [0 ], pos [1 ], resolvedMethod , true , true , info );
112
97
asm .emitCallEpilogue (cc );
@@ -118,7 +103,7 @@ public void test(Method method, Class<?> returnClazz, Class<?>[] types, Object[]
118
103
assert false : "Unimplemented return type: " + returnClazz ;
119
104
}
120
105
121
- }, method , obj , args . toArray ( new Object [ args . size ()]) );
106
+ }, method , values );
122
107
} catch (Throwable e ) {
123
108
e .printStackTrace ();
124
109
throw e ;
0 commit comments