Skip to content

Commit 5153cbb

Browse files
committed
CallUnaryMethodNode uses PythonLanguage#isSingleContext
1 parent f3fcabd commit 5153cbb

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/CallSpecialMethodNode.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
5151
import com.oracle.graal.python.builtins.objects.method.PMethod;
5252
import com.oracle.graal.python.nodes.PGuards;
53+
import com.oracle.graal.python.nodes.PNodeWithContext;
5354
import com.oracle.graal.python.nodes.PRaiseNode;
5455
import com.oracle.graal.python.nodes.PRootNode;
5556
import com.oracle.graal.python.nodes.builtins.FunctionNodes.GetCallTargetNode;
@@ -62,7 +63,6 @@
6263
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
6364
import com.oracle.graal.python.nodes.truffle.PythonTypes;
6465
import com.oracle.graal.python.runtime.PythonOptions;
65-
import com.oracle.truffle.api.Assumption;
6666
import com.oracle.truffle.api.CompilerAsserts;
6767
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
6868
import com.oracle.truffle.api.RootCallTarget;
@@ -72,15 +72,14 @@
7272
import com.oracle.truffle.api.dsl.NodeField;
7373
import com.oracle.truffle.api.dsl.TypeSystemReference;
7474
import com.oracle.truffle.api.frame.VirtualFrame;
75-
import com.oracle.truffle.api.nodes.Node;
7675
import com.oracle.truffle.api.nodes.NodeUtil;
7776
import com.oracle.truffle.api.nodes.RootNode;
7877
import com.oracle.truffle.api.nodes.UnexpectedResultException;
7978

8079
@TypeSystemReference(PythonTypes.class)
8180
@ImportStatic({PythonOptions.class, PGuards.class})
8281
@NodeField(name = "maxSizeExceeded", type = boolean.class)
83-
abstract class CallSpecialMethodNode extends Node {
82+
abstract class CallSpecialMethodNode extends PNodeWithContext {
8483

8584
/**
8685
* for interpreter performance: cache if we exceeded the max caller size. We never allow
@@ -130,10 +129,6 @@ private <T extends PythonBuiltinBaseNode> boolean callerExceedsMaxSize(T builtin
130129
return true;
131130
}
132131

133-
protected Assumption singleContextAssumption() {
134-
return PythonLanguage.get(this).singleContextAssumption;
135-
}
136-
137132
protected static boolean frameIsUnused(PythonBuiltinBaseNode builtinNode) {
138133
return builtinNode == null || !builtinNode.getClass().getAnnotation(GeneratedBy.class).value().getAnnotationsByType(Builtin.class)[0].needsFrame();
139134
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/CallUnaryMethodNode.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,26 @@ Object callSpecialMethodSlotCallTarget(VirtualFrame frame, BuiltinMethodDescript
124124
return invokeNode.execute(frame, callTarget, arguments);
125125
}
126126

127-
@Specialization(guards = {"func == cachedFunc", "builtinNode != null", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "singleContextAssumption()")
127+
@Specialization(guards = {"isSingleContext()", "func == cachedFunc", "builtinNode != null", "frame != null || unusedFrame"}, //
128+
limit = "getCallSiteInlineCacheMaxDepth()")
128129
Object callObjectSingle(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinFunction func, Object receiver,
129130
@SuppressWarnings("unused") @Cached("func") PBuiltinFunction cachedFunc,
130131
@Cached("getUnary(frame, func)") PythonUnaryBuiltinNode builtinNode,
131132
@SuppressWarnings("unused") @Cached("frameIsUnused(builtinNode)") boolean unusedFrame) {
132133
return builtinNode.execute(frame, receiver);
133134
}
134135

135-
@Specialization(guards = {"func.getCallTarget() == ct", "builtinNode != null", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
136+
@Specialization(guards = {"func.getCallTarget() == ct", "builtinNode != null", "frame != null || unusedFrame"}, //
137+
limit = "getCallSiteInlineCacheMaxDepth()")
136138
Object callObject(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinFunction func, Object receiver,
137139
@SuppressWarnings("unused") @Cached(value = "func.getCallTarget()") RootCallTarget ct,
138140
@Cached("getUnary(frame, func)") PythonUnaryBuiltinNode builtinNode,
139141
@SuppressWarnings("unused") @Cached("frameIsUnused(builtinNode)") boolean unusedFrame) {
140142
return builtinNode.execute(frame, receiver);
141143
}
142144

143-
@Specialization(guards = {"func == cachedFunc", "builtinNode != null", "!takesSelfArg",
144-
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "singleContextAssumption()")
145+
@Specialization(guards = {"isSingleContext()", "func == cachedFunc", "builtinNode != null", "!takesSelfArg",
146+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
145147
Object callMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object receiver,
146148
@SuppressWarnings("unused") @Cached("func") PBuiltinMethod cachedFunc,
147149
@SuppressWarnings("unused") @Cached("takesSelfArg(func)") boolean takesSelfArg,
@@ -150,7 +152,8 @@ Object callMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused") P
150152
return builtinNode.execute(frame, receiver);
151153
}
152154

153-
@Specialization(guards = {"builtinNode != null", "getCallTarget(func, getCt) == ct", "!takesSelfArg", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
155+
@Specialization(guards = {"builtinNode != null", "getCallTarget(func, getCt) == ct", "!takesSelfArg",
156+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
154157
Object callMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object receiver,
155158
@SuppressWarnings("unused") @Cached GetCallTargetNode getCt,
156159
@SuppressWarnings("unused") @Cached("getCallTarget(func, getCt)") RootCallTarget ct,
@@ -160,8 +163,8 @@ Object callMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod
160163
return builtinNode.execute(frame, receiver);
161164
}
162165

163-
@Specialization(guards = {"func == cachedFunc", "builtinNode != null", "takesSelfArg",
164-
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "singleContextAssumption()")
166+
@Specialization(guards = {"isSingleContext()", "func == cachedFunc", "builtinNode != null", "takesSelfArg",
167+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
165168
Object callSelfMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object arg,
166169
@SuppressWarnings("unused") @Cached(value = "func", weak = true) PBuiltinMethod cachedFunc,
167170
@SuppressWarnings("unused") @Cached("takesSelfArg(func)") boolean takesSelfArg,
@@ -170,7 +173,8 @@ Object callSelfMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused
170173
return builtinNode.execute(frame, func.getSelf(), arg);
171174
}
172175

173-
@Specialization(guards = {"builtinNode != null", "getCallTarget(func, getCt) == ct", "takesSelfArg", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
176+
@Specialization(guards = {"builtinNode != null", "getCallTarget(func, getCt) == ct", "takesSelfArg",
177+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
174178
Object callSelfMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object arg,
175179
@SuppressWarnings("unused") @Cached GetCallTargetNode getCt,
176180
@SuppressWarnings("unused") @Cached("getCallTarget(func, getCt)") RootCallTarget ct,
@@ -180,8 +184,8 @@ Object callSelfMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMe
180184
return builtinNode.execute(frame, func.getSelf(), arg);
181185
}
182186

183-
@Specialization(guards = {"func == cachedFunc", "builtinNode != null", "!takesSelfArg", "minArgs == 1",
184-
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()", assumptions = "singleContextAssumption()")
187+
@Specialization(guards = {"isSingleContext()", "func == cachedFunc", "builtinNode != null", "!takesSelfArg", "minArgs == 1",
188+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
185189
static Object callBinaryMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object receiver,
186190
@SuppressWarnings("unused") @Cached("func") PBuiltinMethod cachedFunc,
187191
@SuppressWarnings("unused") @Cached("takesSelfArg(func)") boolean takesSelfArg,
@@ -191,7 +195,8 @@ static Object callBinaryMethodSingleContext(VirtualFrame frame, @SuppressWarning
191195
return builtinNode.execute(frame, receiver, PNone.NO_VALUE);
192196
}
193197

194-
@Specialization(guards = {"builtinNode != null", "minArgs == 1", "getCallTarget(func, getCt) == ct", "!takesSelfArg", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
198+
@Specialization(guards = {"builtinNode != null", "minArgs == 1", "getCallTarget(func, getCt) == ct", "!takesSelfArg",
199+
"frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()")
195200
static Object callBinaryMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object arg,
196201
@SuppressWarnings("unused") @Cached GetCallTargetNode getCt,
197202
@SuppressWarnings("unused") @Cached("getCallTarget(func, getCt)") RootCallTarget ct,

0 commit comments

Comments
 (0)