|
40 | 40 | */
|
41 | 41 | package com.oracle.graal.python.nodes.call.special;
|
42 | 42 |
|
| 43 | +import com.oracle.graal.python.builtins.objects.PNone; |
43 | 44 | import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
|
44 | 45 | import com.oracle.graal.python.builtins.objects.function.PKeyword;
|
45 | 46 | import com.oracle.graal.python.builtins.objects.method.PBuiltinMethod;
|
@@ -220,8 +221,39 @@ Object callSelfMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMe
|
220 | 221 | return builtinNode.call(frame, func.getSelf(), arg);
|
221 | 222 | }
|
222 | 223 |
|
| 224 | + @Specialization(guards = { // |
| 225 | + "func == cachedFunc", // |
| 226 | + "builtinNode != null", // |
| 227 | + "!takesSelfArg", // |
| 228 | + "minArgs == 1", // |
| 229 | + "frame != null || unusedFrame"}, // |
| 230 | + limit = "getCallSiteInlineCacheMaxDepth()", // |
| 231 | + assumptions = "singleContextAssumption()") |
| 232 | + static Object callBinaryMethodSingleContext(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object receiver, |
| 233 | + @SuppressWarnings("unused") @Cached("func") PBuiltinMethod cachedFunc, |
| 234 | + @SuppressWarnings("unused") @Cached("takesSelfArg(func)") boolean takesSelfArg, |
| 235 | + @SuppressWarnings("unused") @Cached("getMinArgs(func)") int minArgs, |
| 236 | + @Cached("getBinary(frame, func.getFunction())") PythonBinaryBuiltinNode builtinNode, |
| 237 | + @SuppressWarnings("unused") @Cached("frameIsUnused(builtinNode)") boolean unusedFrame) { |
| 238 | + return builtinNode.call(frame, receiver, PNone.NO_VALUE); |
| 239 | + } |
| 240 | + |
| 241 | + /** |
| 242 | + * In case the function takes at least 1 argument (so is <it>at least</it> unary) we also try |
| 243 | + * higher orders. |
| 244 | + */ |
| 245 | + @Specialization(guards = {"builtinNode != null", "minArgs == 1", "getCallTarget(func) == ct", "!takesSelfArg", "frame != null || unusedFrame"}, limit = "getCallSiteInlineCacheMaxDepth()") |
| 246 | + static Object callBinaryMethod(VirtualFrame frame, @SuppressWarnings("unused") PBuiltinMethod func, Object arg, |
| 247 | + @SuppressWarnings("unused") @Cached("getCallTarget(func)") RootCallTarget ct, |
| 248 | + @SuppressWarnings("unused") @Cached("takesSelfArg(func)") boolean takesSelfArg, |
| 249 | + @SuppressWarnings("unused") @Cached("getMinArgs(func)") int minArgs, |
| 250 | + @Cached("getBinary(frame, func.getFunction())") PythonBinaryBuiltinNode builtinNode, |
| 251 | + @SuppressWarnings("unused") @Cached("frameIsUnused(builtinNode)") boolean unusedFrame) { |
| 252 | + return builtinNode.call(frame, arg, PNone.NO_VALUE); |
| 253 | + } |
| 254 | + |
223 | 255 | @Specialization(replaces = {"callIntSingle", "callInt", "callLongSingle", "callLong", "callDoubleSingle", "callDouble", "callBoolSingle", "callBool", "callObjectSingleContext",
|
224 |
| - "callMethodSingleContext", "callSelfMethodSingleContext", "callMethod", "callSelfMethod"}) |
| 256 | + "callMethodSingleContext", "callSelfMethodSingleContext", "callMethod", "callSelfMethod", "callBinaryMethodSingleContext", "callBinaryMethod"}) |
225 | 257 | static Object call(VirtualFrame frame, Object func, Object receiver,
|
226 | 258 | @Cached("create()") CallNode callNode,
|
227 | 259 | @Cached ConditionProfile isBoundProfile) {
|
|
0 commit comments