Skip to content

Commit 62cd349

Browse files
committed
Pass callee to CallTargetInvokeNode
1 parent 19f21c8 commit 62cd349

File tree

4 files changed

+17
-27
lines changed

4 files changed

+17
-27
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PyTruffleObjectAlloc.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444

4545
import com.oracle.graal.python.PythonLanguage;
4646
import com.oracle.graal.python.builtins.objects.frame.PFrame;
47-
import com.oracle.graal.python.nodes.call.CallTargetInvokeNode;
4847
import com.oracle.graal.python.nodes.call.GenericInvokeNode;
4948
import com.oracle.graal.python.nodes.frame.GetCurrentFrameRef;
5049
import com.oracle.graal.python.nodes.util.CannotCastException;
@@ -125,11 +124,6 @@ Object execute(Object[] arguments,
125124
return -2;
126125
}
127126

128-
static CallTargetInvokeNode createInvokeNode(ContextReference<PythonContext> contextRef) {
129-
CApiContext cApiContext = contextRef.get().getCApiContext();
130-
return CallTargetInvokeNode.create(cApiContext.getTriggerAsyncActionsCallTarget(), null, false, false);
131-
}
132-
133127
static AllocationReporter getAllocationReporter(ContextReference<PythonContext> contextRef) {
134128
return contextRef.get().getEnv().lookup(AllocationReporter.class);
135129
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/GeneratorBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static Object cached(VirtualFrame frame, PGenerator self, Object sendValue,
153153
PArguments.setSpecialArgument(arguments, sendValue);
154154
}
155155
try {
156-
return call.execute(frame, null, null, arguments);
156+
return call.execute(frame, null, null, null, arguments);
157157
} catch (PException e) {
158158
self.markAsFinished();
159159
throw e;
@@ -183,7 +183,7 @@ static Object generic(VirtualFrame frame, PGenerator self, Object sendValue,
183183
}
184184

185185
protected static CallTargetInvokeNode createDirectCall(CallTarget target) {
186-
return CallTargetInvokeNode.create(target, null, false, true);
186+
return CallTargetInvokeNode.create(target, false, true);
187187
}
188188

189189
protected static boolean sameCallTarget(RootCallTarget target1, CallTarget target2) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected Object callFunctionCachedCode(VirtualFrame frame, @SuppressWarnings("u
115115
protected Object callFunctionCachedCt(VirtualFrame frame, PFunction callee, Object[] arguments,
116116
@SuppressWarnings("unused") @Cached("callee.getCallTarget()") RootCallTarget ct,
117117
@Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
118-
return invoke.execute(frame, callee.getGlobals(), callee.getClosure(), arguments);
118+
return invoke.execute(frame, callee, callee.getGlobals(), callee.getClosure(), arguments);
119119
}
120120

121121
@Specialization(guards = {"callee == cachedCallee"}, limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "singleContextAssumption()")
@@ -129,7 +129,7 @@ protected Object callBuiltinFunctionCached(VirtualFrame frame, @SuppressWarnings
129129
protected Object callBuiltinFunctionCachedCt(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinFunction callee, Object[] arguments,
130130
@SuppressWarnings("unused") @Cached("callee.getCallTarget()") RootCallTarget ct,
131131
@Cached("createCtInvokeNode(callee)") CallTargetInvokeNode invoke) {
132-
return invoke.execute(frame, null, null, arguments);
132+
return invoke.execute(frame, null, null, null, arguments);
133133
}
134134

135135
@Specialization(replaces = {"callFunctionCached", "callFunctionCachedCode", "callFunctionCachedCt"})

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,16 @@
6565
public abstract class CallTargetInvokeNode extends DirectInvokeNode {
6666
@Child private DirectCallNode callNode;
6767
@Child private CallContext callContext;
68-
// Needed only for generator functions, will be null for builtins and other callables that
69-
// cannot be generator functions
70-
private final PFunction callee;
7168
protected final boolean isBuiltin;
7269

73-
protected CallTargetInvokeNode(CallTarget callTarget, PFunction callee, boolean isBuiltin, boolean isGenerator) {
70+
protected CallTargetInvokeNode(CallTarget callTarget, boolean isBuiltin, boolean isGenerator) {
7471
this.callNode = Truffle.getRuntime().createDirectCallNode(callTarget);
7572
if (isBuiltin) {
7673
callNode.cloneCallTarget();
7774
}
7875
if (isGenerator && shouldInlineGenerators()) {
7976
this.callNode.forceInlining();
8077
}
81-
this.callee = callee;
8278
this.callContext = CallContext.create();
8379
this.isBuiltin = isBuiltin;
8480
}
@@ -87,28 +83,28 @@ protected CallTargetInvokeNode(CallTarget callTarget, PFunction callee, boolean
8783
public static CallTargetInvokeNode create(PFunction callee) {
8884
RootCallTarget callTarget = getCallTarget(callee);
8985
boolean builtin = isBuiltin(callee);
90-
return CallTargetInvokeNodeGen.create(callTarget, callee, builtin, callee.isGeneratorFunction());
86+
return CallTargetInvokeNodeGen.create(callTarget, builtin, callee.isGeneratorFunction());
9187
}
9288

9389
@TruffleBoundary
9490
public static CallTargetInvokeNode create(PBuiltinFunction callee) {
9591
RootCallTarget callTarget = getCallTarget(callee);
9692
boolean builtin = isBuiltin(callee);
97-
return CallTargetInvokeNodeGen.create(callTarget, null, builtin, false);
93+
return CallTargetInvokeNodeGen.create(callTarget, builtin, false);
9894
}
9995

100-
public static CallTargetInvokeNode create(CallTarget callTarget, PFunction callee, boolean isBuiltin, boolean isGenerator) {
101-
return CallTargetInvokeNodeGen.create(callTarget, callee, isBuiltin, isGenerator);
96+
public static CallTargetInvokeNode create(CallTarget callTarget, boolean isBuiltin, boolean isGenerator) {
97+
return CallTargetInvokeNodeGen.create(callTarget, isBuiltin, isGenerator);
10298
}
10399

104-
public final Object execute(VirtualFrame frame, Object[] arguments) {
105-
return execute(frame, null, null, arguments);
106-
}
107-
108-
public abstract Object execute(VirtualFrame frame, PythonObject globals, PCell[] closure, Object[] arguments);
100+
/**
101+
* @param callee A PFunction if the callee is one, otherwise null. Used for generator functions
102+
* only.
103+
*/
104+
public abstract Object execute(VirtualFrame frame, PFunction callee, PythonObject globals, PCell[] closure, Object[] arguments);
109105

110106
@Specialization(guards = {"globals == null", "closure == null"})
111-
protected Object doNoClosure(VirtualFrame frame, @SuppressWarnings("unused") PythonObject globals, @SuppressWarnings("unused") PCell[] closure, Object[] arguments,
107+
protected Object doNoClosure(VirtualFrame frame, PFunction callee, @SuppressWarnings("unused") PythonObject globals, @SuppressWarnings("unused") PCell[] closure, Object[] arguments,
112108
@Cached("createBinaryProfile()") ConditionProfile classBodyProfile,
113109
@Cached("createBinaryProfile()") ConditionProfile generatorFunctionProfile,
114110
@CachedContext(PythonLanguage.class) PythonContext context) {
@@ -134,13 +130,13 @@ protected Object doNoClosure(VirtualFrame frame, @SuppressWarnings("unused") Pyt
134130
}
135131

136132
@Specialization(replaces = "doNoClosure")
137-
protected Object doGeneric(VirtualFrame frame, PythonObject globals, PCell[] closure, Object[] arguments,
133+
protected Object doGeneric(VirtualFrame frame, PFunction callee, PythonObject globals, PCell[] closure, Object[] arguments,
138134
@Cached("createBinaryProfile()") ConditionProfile classBodyProfile,
139135
@Cached("createBinaryProfile()") ConditionProfile generatorFunctionProfile,
140136
@CachedContext(PythonLanguage.class) PythonContext context) {
141137
PArguments.setGlobals(arguments, globals);
142138
PArguments.setClosure(arguments, closure);
143-
return doNoClosure(frame, null, null, arguments, classBodyProfile, generatorFunctionProfile, context);
139+
return doNoClosure(frame, callee, null, null, arguments, classBodyProfile, generatorFunctionProfile, context);
144140
}
145141

146142
public final CallTarget getCallTarget() {

0 commit comments

Comments
 (0)