Skip to content

Commit 24bd0b5

Browse files
committed
with a constant CallTarget, the arity is also constant
1 parent 91c92b6 commit 24bd0b5

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected Object callMethod(VirtualFrame frame, PMethod method, Object[] argumen
7979
protected Object callMethod(VirtualFrame frame, PMethod method, Object[] arguments, PKeyword[] keywords,
8080
@Cached("method.getFunction().getCallTarget()") RootCallTarget ct,
8181
@Cached("createCtInvokeNode(method)") CallTargetInvokeNode invoke) {
82-
return invoke.execute(frame, method.getGlobals(), method.getClosure(), method.getArity(), arguments, keywords);
82+
return invoke.execute(frame, method.getGlobals(), method.getClosure(), arguments, keywords);
8383
}
8484

8585
@SuppressWarnings("unused")
@@ -95,7 +95,7 @@ protected Object callBuiltinMethod(VirtualFrame frame, PBuiltinMethod method, Ob
9595
protected Object callBuiltinMethod(VirtualFrame frame, PBuiltinMethod method, Object[] arguments, PKeyword[] keywords,
9696
@Cached("method.getFunction().getCallTarget()") RootCallTarget ct,
9797
@Cached("createCtInvokeNode(method)") CallTargetInvokeNode invoke) {
98-
return invoke.execute(frame, method.getGlobals(), method.getClosure(), method.getArity(), arguments, keywords);
98+
return invoke.execute(frame, method.getGlobals(), method.getClosure(), arguments, keywords);
9999
}
100100

101101
@SuppressWarnings("unused")
@@ -111,15 +111,15 @@ protected Object callFunction(VirtualFrame frame, PythonCallable callee, Object[
111111
protected Object callFunction(VirtualFrame frame, PFunction callee, Object[] arguments, PKeyword[] keywords,
112112
@Cached("callee.getCallTarget()") RootCallTarget ct,
113113
@Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
114-
return invoke.execute(frame, callee.getGlobals(), callee.getClosure(), callee.getArity(), arguments, keywords);
114+
return invoke.execute(frame, callee.getGlobals(), callee.getClosure(), arguments, keywords);
115115
}
116116

117117
@SuppressWarnings("unused")
118118
@Specialization(guards = "callee.getCallTarget() == ct", limit = "getCallSiteInlineCacheMaxDepth()")
119119
protected Object callFunction(VirtualFrame frame, PBuiltinFunction callee, Object[] arguments, PKeyword[] keywords,
120120
@Cached("callee.getCallTarget()") RootCallTarget ct,
121121
@Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
122-
return invoke.execute(frame, callee.getGlobals(), callee.getClosure(), callee.getArity(), arguments, keywords);
122+
return invoke.execute(frame, callee.getGlobals(), callee.getClosure(), arguments, keywords);
123123
}
124124

125125
@Specialization(replaces = {"callMethod", "callBuiltinMethod", "callFunction"})

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ protected Object execute(VirtualFrame frame, PythonCallable callee, Object[] arg
150150
abstract class CallTargetInvokeNode extends AbstractInvokeNode {
151151
@Child private DirectCallNode callNode;
152152
@Child private ArityCheckNode arityCheck = ArityCheckNode.create();
153+
private final Arity arity;
153154
protected final boolean isBuiltin;
154155

155-
protected CallTargetInvokeNode(CallTarget callTarget, boolean isBuiltin, boolean isGenerator) {
156+
protected CallTargetInvokeNode(CallTarget callTarget, Arity arity, boolean isBuiltin, boolean isGenerator) {
156157
this.callNode = Truffle.getRuntime().createDirectCallNode(callTarget);
158+
this.arity = arity;
157159
if (isBuiltin) {
158160
callNode.cloneCallTarget();
159161
}
@@ -167,13 +169,13 @@ protected CallTargetInvokeNode(CallTarget callTarget, boolean isBuiltin, boolean
167169
public static CallTargetInvokeNode create(PythonCallable callee) {
168170
RootCallTarget callTarget = getCallTarget(callee);
169171
boolean builtin = isBuiltin(callee);
170-
return CallTargetInvokeNodeGen.create(callTarget, builtin, callee.isGeneratorFunction());
172+
return CallTargetInvokeNodeGen.create(callTarget, callee.getArity(), builtin, callee.isGeneratorFunction());
171173
}
172174

173-
public abstract Object execute(VirtualFrame frame, PythonObject globals, PCell[] closure, Arity arity, Object[] arguments, PKeyword[] keywords);
175+
public abstract Object execute(VirtualFrame frame, PythonObject globals, PCell[] closure, Object[] arguments, PKeyword[] keywords);
174176

175177
@Specialization(guards = {"keywords.length == 0"})
176-
protected Object doNoKeywords(VirtualFrame frame, PythonObject globals, PCell[] closure, Arity arity, Object[] arguments, PKeyword[] keywords) {
178+
protected Object doNoKeywords(VirtualFrame frame, PythonObject globals, PCell[] closure, Object[] arguments, PKeyword[] keywords) {
177179
PArguments.setGlobals(arguments, globals);
178180
PArguments.setClosure(arguments, closure);
179181
PArguments.setCallerFrame(arguments, getCallerFrame(frame, callNode.getCallTarget()));
@@ -182,7 +184,7 @@ protected Object doNoKeywords(VirtualFrame frame, PythonObject globals, PCell[]
182184
}
183185

184186
@Specialization(guards = {"!isBuiltin"})
185-
protected Object doWithKeywords(VirtualFrame frame, PythonObject globals, PCell[] closure, Arity arity, Object[] arguments, PKeyword[] keywords,
187+
protected Object doWithKeywords(VirtualFrame frame, PythonObject globals, PCell[] closure, Object[] arguments, PKeyword[] keywords,
186188
@Cached("create()") ApplyKeywordsNode applyKeywords) {
187189
Object[] combined = applyKeywords.execute(arity, arguments, keywords);
188190
PArguments.setGlobals(combined, globals);
@@ -193,7 +195,7 @@ protected Object doWithKeywords(VirtualFrame frame, PythonObject globals, PCell[
193195
}
194196

195197
@Specialization(guards = "isBuiltin")
196-
protected Object doBuiltinWithKeywords(VirtualFrame frame, @SuppressWarnings("unused") PythonObject globals, @SuppressWarnings("unused") PCell[] closure, Arity arity, Object[] arguments,
198+
protected Object doBuiltinWithKeywords(VirtualFrame frame, @SuppressWarnings("unused") PythonObject globals, @SuppressWarnings("unused") PCell[] closure, Object[] arguments,
197199
PKeyword[] keywords) {
198200
PArguments.setKeywordArguments(arguments, keywords);
199201
PArguments.setCallerFrame(arguments, getCallerFrame(frame, callNode.getCallTarget()));

0 commit comments

Comments
 (0)