66
66
import com .oracle .truffle .api .dsl .TypeSystemReference ;
67
67
import com .oracle .truffle .api .frame .Frame ;
68
68
import com .oracle .truffle .api .frame .VirtualFrame ;
69
- import com .oracle .truffle .api .interop .InteropLibrary ;
70
- import com .oracle .truffle .api .library .CachedLibrary ;
71
69
72
70
@ TypeSystemReference (PythonTypes .class )
73
71
@ ImportStatic ({PGuards .class , SpecialMethodNames .class })
@@ -109,12 +107,25 @@ public final Object execute(Frame frame, Object callableObject, Object... argume
109
107
return executeInternal (frame , callableObject , arguments , PKeyword .EMPTY_KEYWORDS );
110
108
}
111
109
112
- @ Specialization (guards = "!isCallable(callableObject) || isClass(callableObject, iLib)" , limit = "3" )
110
+ @ Specialization
111
+ protected Object functionCall (VirtualFrame frame , PFunction callable , Object [] arguments , PKeyword [] keywords ,
112
+ @ Shared ("dispatchNode" ) @ Cached CallDispatchNode dispatch ,
113
+ @ Shared ("argsNode" ) @ Cached CreateArgumentsNode createArgs ) {
114
+ return dispatch .executeCall (frame , callable , createArgs .execute (callable , arguments , keywords ));
115
+ }
116
+
117
+ @ Specialization
118
+ protected Object builtinFunctionCall (VirtualFrame frame , PBuiltinFunction callable , Object [] arguments , PKeyword [] keywords ,
119
+ @ Shared ("dispatchNode" ) @ Cached CallDispatchNode dispatch ,
120
+ @ Shared ("argsNode" ) @ Cached CreateArgumentsNode createArgs ) {
121
+ return dispatch .executeCall (frame , callable , createArgs .execute (callable , arguments , keywords ));
122
+ }
123
+
124
+ @ Specialization (guards = "!isCallable(callableObject)" )
113
125
protected Object doObjectAndType (VirtualFrame frame , Object callableObject , Object [] arguments , PKeyword [] keywords ,
114
- @ Cached PRaiseNode raise ,
115
- @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
116
- @ Cached CallVarargsMethodNode callCallNode ,
117
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("callableObject" ) InteropLibrary iLib ) {
126
+ @ Shared ("raise" ) @ Cached PRaiseNode raise ,
127
+ @ Shared ("lookupCall" ) @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
128
+ @ Shared ("callCall" ) @ Cached CallVarargsMethodNode callCallNode ) {
118
129
Object call = callAttrGetterNode .execute (callableObject );
119
130
return callCall (frame , callableObject , arguments , keywords , raise , callCallNode , call );
120
131
}
@@ -159,36 +170,20 @@ protected Object builtinMethodCallBuiltinDirect(VirtualFrame frame, PBuiltinMeth
159
170
return dispatch .executeCall (frame , callable .getFunction (), createArgs .execute (callable , arguments , keywords ));
160
171
}
161
172
162
- @ Specialization (guards = "!isFunction(callable.getFunction())" , limit = "3" )
173
+ @ Specialization (guards = "!isFunction(callable.getFunction())" )
163
174
protected Object methodCall (VirtualFrame frame , PMethod callable , Object [] arguments , PKeyword [] keywords ,
164
- @ Cached PRaiseNode raise ,
165
- @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
166
- @ Cached CallVarargsMethodNode callCallNode ,
167
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("callable" ) InteropLibrary iLib ) {
168
- return doObjectAndType (frame , callable , arguments , keywords , raise , callAttrGetterNode , callCallNode , iLib );
175
+ @ Shared ("raise" ) @ Cached PRaiseNode raise ,
176
+ @ Shared ("lookupCall" ) @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
177
+ @ Shared ("callCall" ) @ Cached CallVarargsMethodNode callCallNode ) {
178
+ return doObjectAndType (frame , callable , arguments , keywords , raise , callAttrGetterNode , callCallNode );
169
179
}
170
180
171
- @ Specialization (guards = "!isFunction(callable.getFunction())" , limit = "3" )
181
+ @ Specialization (guards = "!isFunction(callable.getFunction())" )
172
182
protected Object builtinMethodCall (VirtualFrame frame , PBuiltinMethod callable , Object [] arguments , PKeyword [] keywords ,
173
- @ Cached PRaiseNode raise ,
174
- @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
175
- @ Cached CallVarargsMethodNode callCallNode ,
176
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("callable" ) InteropLibrary iLib ) {
177
- return doObjectAndType (frame , callable , arguments , keywords , raise , callAttrGetterNode , callCallNode , iLib );
178
- }
179
-
180
- @ Specialization
181
- protected Object functionCall (VirtualFrame frame , PFunction callable , Object [] arguments , PKeyword [] keywords ,
182
- @ Shared ("dispatchNode" ) @ Cached CallDispatchNode dispatch ,
183
- @ Shared ("argsNode" ) @ Cached CreateArgumentsNode createArgs ) {
184
- return dispatch .executeCall (frame , callable , createArgs .execute (callable , arguments , keywords ));
185
- }
186
-
187
- @ Specialization
188
- protected Object builtinFunctionCall (VirtualFrame frame , PBuiltinFunction callable , Object [] arguments , PKeyword [] keywords ,
189
- @ Shared ("dispatchNode" ) @ Cached CallDispatchNode dispatch ,
190
- @ Shared ("argsNode" ) @ Cached CreateArgumentsNode createArgs ) {
191
- return dispatch .executeCall (frame , callable , createArgs .execute (callable , arguments , keywords ));
183
+ @ Shared ("raise" ) @ Cached PRaiseNode raise ,
184
+ @ Shared ("lookupCall" ) @ Cached ("create(__CALL__)" ) LookupInheritedAttributeNode callAttrGetterNode ,
185
+ @ Shared ("callVarargs" ) @ Cached CallVarargsMethodNode callCallNode ) {
186
+ return doObjectAndType (frame , callable , arguments , keywords , raise , callAttrGetterNode , callCallNode );
192
187
}
193
188
194
189
@ Specialization (replaces = {"doObjectAndType" , "methodCallBuiltinDirect" , "methodCallDirect" , "builtinMethodCallBuiltinDirectCached" ,
@@ -197,9 +192,9 @@ protected Object builtinFunctionCall(VirtualFrame frame, PBuiltinFunction callab
197
192
protected Object doGeneric (VirtualFrame frame , Object callableObject , Object [] arguments , PKeyword [] keywords ,
198
193
@ Shared ("dispatchNode" ) @ Cached CallDispatchNode dispatch ,
199
194
@ Shared ("argsNode" ) @ Cached CreateArgumentsNode createArgs ,
200
- @ Cached PRaiseNode raise ,
195
+ @ Shared ( "raise" ) @ Cached PRaiseNode raise ,
201
196
@ Cached LookupInheritedAttributeNode .Dynamic callAttrGetterNode ,
202
- @ Cached CallVarargsMethodNode callCallNode ) {
197
+ @ Shared ( "callVarargs" ) @ Cached CallVarargsMethodNode callCallNode ) {
203
198
if (callableObject instanceof PFunction ) {
204
199
return functionCall (frame , (PFunction ) callableObject , arguments , keywords , dispatch , createArgs );
205
200
} else if (callableObject instanceof PBuiltinFunction ) {
0 commit comments