Skip to content

Commit fd7cc26

Browse files
committed
Cache builtin method in call node.
1 parent f645159 commit fd7cc26

File tree

1 file changed

+7
-0
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ protected Object builtinMethodCallDirect(VirtualFrame frame, PBuiltinMethod call
144144
return ensureDispatch().executeCall(frame, (PFunction) callable.getFunction(), ensureCreateArguments().execute(callable, arguments, keywords));
145145
}
146146

147+
@Specialization(limit = "1", guards = {"callable == cachedCallable", "isPBuiltinFunction(cachedCallable.getFunction())"}, assumptions = "singleContextAssumption()")
148+
protected Object builtinMethodCallBuiltinDirectCached(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod callable, Object[] arguments, PKeyword[] keywords,
149+
@Cached("callable") PBuiltinMethod cachedCallable) {
150+
// functions must be called directly otherwise the call stack is incorrect
151+
return ensureDispatch().executeCall(frame, (PBuiltinFunction) cachedCallable.getFunction(), ensureCreateArguments().execute(cachedCallable, arguments, keywords));
152+
}
153+
147154
@Specialization(guards = "isPBuiltinFunction(callable.getFunction())")
148155
protected Object builtinMethodCallBuiltinDirect(VirtualFrame frame, PBuiltinMethod callable, Object[] arguments, PKeyword[] keywords) {
149156
// functions must be called directly otherwise the call stack is incorrect

0 commit comments

Comments
 (0)