Skip to content

Commit bdde3ba

Browse files
committed
Call function of method directly if possible.
1 parent 0304c84 commit bdde3ba

File tree

1 file changed

+14
-2
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,26 @@ private CallDispatchNode ensureDispatch() {
100100
return dispatch;
101101
}
102102

103-
@Specialization
103+
@Specialization(guards = "isFunction(callable.getFunction())")
104+
protected Object methodCallDirect(VirtualFrame frame, PMethod callable, Object[] arguments, PKeyword[] keywords) {
105+
// functions must be called directly otherwise the call stack is incorrect
106+
return ensureDispatch().executeCall(frame, callable.getFunction(), ensureCreateArguments().executeWithSelf(callable.getSelf(), arguments), keywords);
107+
}
108+
109+
@Specialization(guards = "isFunction(callable.getFunction())")
110+
protected Object builtinMethodCallDirect(VirtualFrame frame, PBuiltinMethod callable, Object[] arguments, PKeyword[] keywords) {
111+
// functions must be called directly otherwise the call stack is incorrect
112+
return ensureDispatch().executeCall(frame, callable.getFunction(), ensureCreateArguments().executeWithSelf(callable.getSelf(), arguments), keywords);
113+
}
114+
115+
@Specialization(guards = "!isFunction(callable.getFunction())")
104116
protected Object methodCall(VirtualFrame frame, PMethod callable, Object[] arguments, PKeyword[] keywords,
105117
@Cached("create(__CALL__)") LookupInheritedAttributeNode callAttrGetterNode,
106118
@Cached("create()") CallVarargsMethodNode callCallNode) {
107119
return specialCall(frame, callable, arguments, keywords, callAttrGetterNode, callCallNode);
108120
}
109121

110-
@Specialization
122+
@Specialization(guards = "!isFunction(callable.getFunction())")
111123
protected Object builtinMethodCall(VirtualFrame frame, PBuiltinMethod callable, Object[] arguments, PKeyword[] keywords,
112124
@Cached("create(__CALL__)") LookupInheritedAttributeNode callAttrGetterNode,
113125
@Cached("create()") CallVarargsMethodNode callCallNode) {

0 commit comments

Comments
 (0)