Skip to content

Commit 7c38718

Browse files
committed
Avoid using InteropLibrary in CallNode
1 parent 8fc5b7d commit 7c38718

File tree

1 file changed

+30
-35
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call

1 file changed

+30
-35
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/CallNode.java

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
import com.oracle.truffle.api.dsl.TypeSystemReference;
6767
import com.oracle.truffle.api.frame.Frame;
6868
import com.oracle.truffle.api.frame.VirtualFrame;
69-
import com.oracle.truffle.api.interop.InteropLibrary;
70-
import com.oracle.truffle.api.library.CachedLibrary;
7169

7270
@TypeSystemReference(PythonTypes.class)
7371
@ImportStatic({PGuards.class, SpecialMethodNames.class})
@@ -109,12 +107,25 @@ public final Object execute(Frame frame, Object callableObject, Object... argume
109107
return executeInternal(frame, callableObject, arguments, PKeyword.EMPTY_KEYWORDS);
110108
}
111109

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)")
113125
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) {
118129
Object call = callAttrGetterNode.execute(callableObject);
119130
return callCall(frame, callableObject, arguments, keywords, raise, callCallNode, call);
120131
}
@@ -159,36 +170,20 @@ protected Object builtinMethodCallBuiltinDirect(VirtualFrame frame, PBuiltinMeth
159170
return dispatch.executeCall(frame, callable.getFunction(), createArgs.execute(callable, arguments, keywords));
160171
}
161172

162-
@Specialization(guards = "!isFunction(callable.getFunction())", limit = "3")
173+
@Specialization(guards = "!isFunction(callable.getFunction())")
163174
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);
169179
}
170180

171-
@Specialization(guards = "!isFunction(callable.getFunction())", limit = "3")
181+
@Specialization(guards = "!isFunction(callable.getFunction())")
172182
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);
192187
}
193188

194189
@Specialization(replaces = {"doObjectAndType", "methodCallBuiltinDirect", "methodCallDirect", "builtinMethodCallBuiltinDirectCached",
@@ -197,9 +192,9 @@ protected Object builtinFunctionCall(VirtualFrame frame, PBuiltinFunction callab
197192
protected Object doGeneric(VirtualFrame frame, Object callableObject, Object[] arguments, PKeyword[] keywords,
198193
@Shared("dispatchNode") @Cached CallDispatchNode dispatch,
199194
@Shared("argsNode") @Cached CreateArgumentsNode createArgs,
200-
@Cached PRaiseNode raise,
195+
@Shared("raise") @Cached PRaiseNode raise,
201196
@Cached LookupInheritedAttributeNode.Dynamic callAttrGetterNode,
202-
@Cached CallVarargsMethodNode callCallNode) {
197+
@Shared("callVarargs") @Cached CallVarargsMethodNode callCallNode) {
203198
if (callableObject instanceof PFunction) {
204199
return functionCall(frame, (PFunction) callableObject, arguments, keywords, dispatch, createArgs);
205200
} else if (callableObject instanceof PBuiltinFunction) {

0 commit comments

Comments
 (0)