@@ -60,11 +60,12 @@ public static NativeEntryPoint make(ABIDescriptor abi,
60
60
MethodType methodType ,
61
61
boolean needsReturnBuffer ,
62
62
int capturedStateMask ,
63
- boolean needsTransition ) {
63
+ boolean needsTransition ,
64
+ boolean usingAddressPairs ) {
64
65
if (returnMoves .length > 1 != needsReturnBuffer ) {
65
66
throw new AssertionError ("Multiple register return, but needsReturnBuffer was false" );
66
67
}
67
- checkType (methodType , needsReturnBuffer , capturedStateMask );
68
+ checkMethodType (methodType , needsReturnBuffer , capturedStateMask , usingAddressPairs );
68
69
69
70
CacheKey key = new CacheKey (methodType , abi , Arrays .asList (argMoves ), Arrays .asList (returnMoves ),
70
71
needsReturnBuffer , capturedStateMask , needsTransition );
@@ -80,14 +81,26 @@ public static NativeEntryPoint make(ABIDescriptor abi,
80
81
});
81
82
}
82
83
83
- private static void checkType (MethodType methodType , boolean needsReturnBuffer , int savedValueMask ) {
84
- if (methodType .parameterType (0 ) != long .class ) {
85
- throw new AssertionError ("Address expected as first param: " + methodType );
84
+ private static void checkMethodType (MethodType methodType , boolean needsReturnBuffer , int savedValueMask ,
85
+ boolean usingAddressPairs ) {
86
+ int checkIdx = 0 ;
87
+ checkParamType (methodType , checkIdx ++, long .class , "Function address" );
88
+ if (needsReturnBuffer ) {
89
+ checkParamType (methodType , checkIdx ++, long .class , "Return buffer address" );
86
90
}
87
- int checkIdx = 1 ;
88
- if ((needsReturnBuffer && methodType .parameterType (checkIdx ++) != long .class )
89
- || (savedValueMask != 0 && methodType .parameterType (checkIdx ) != long .class )) {
90
- throw new AssertionError ("return buffer and/or preserved value address expected: " + methodType );
91
+ if (savedValueMask != 0 ) { // capturing call state
92
+ if (usingAddressPairs ) {
93
+ checkParamType (methodType , checkIdx ++, Object .class , "Capture state heap base" );
94
+ checkParamType (methodType , checkIdx , long .class , "Capture state offset" );
95
+ } else {
96
+ checkParamType (methodType , checkIdx , long .class , "Capture state address" );
97
+ }
98
+ }
99
+ }
100
+
101
+ private static void checkParamType (MethodType methodType , int checkIdx , Class <?> expectedType , String name ) {
102
+ if (methodType .parameterType (checkIdx ) != expectedType ) {
103
+ throw new AssertionError (name + " expected at index " + checkIdx + ": " + methodType );
91
104
}
92
105
}
93
106
0 commit comments