|
82 | 82 | import com.oracle.graal.python.builtins.objects.type.slots.TpSlotVarargsFactory.CallSlotTpCallNodeGen; |
83 | 83 | import com.oracle.graal.python.builtins.objects.type.slots.TpSlotVarargsFactory.CallSlotTpInitNodeGen; |
84 | 84 | import com.oracle.graal.python.builtins.objects.type.slots.TpSlotVarargsFactory.CallSlotTpNewNodeGen; |
| 85 | +import com.oracle.graal.python.lib.PyObjectGetAttr; |
85 | 86 | import com.oracle.graal.python.nodes.ErrorMessages; |
86 | 87 | import com.oracle.graal.python.nodes.PGuards; |
87 | 88 | import com.oracle.graal.python.nodes.PRaiseNode; |
|
97 | 98 | import com.oracle.graal.python.nodes.function.builtins.PythonTernaryBuiltinNode; |
98 | 99 | import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode; |
99 | 100 | import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode; |
| 101 | +import com.oracle.graal.python.nodes.object.GetClassNode; |
100 | 102 | import com.oracle.graal.python.runtime.IndirectCallData.BoundaryCallData; |
101 | 103 | import com.oracle.graal.python.runtime.PythonContext; |
102 | 104 | import com.oracle.graal.python.runtime.PythonContext.GetThreadStateNode; |
|
110 | 112 | import com.oracle.truffle.api.Truffle; |
111 | 113 | import com.oracle.truffle.api.dsl.Bind; |
112 | 114 | import com.oracle.truffle.api.dsl.Cached; |
| 115 | +import com.oracle.truffle.api.dsl.Cached.Exclusive; |
113 | 116 | import com.oracle.truffle.api.dsl.Fallback; |
114 | 117 | import com.oracle.truffle.api.dsl.GenerateCached; |
115 | 118 | import com.oracle.truffle.api.dsl.GenerateInline; |
@@ -484,14 +487,27 @@ public static Object executeUncached(TpSlot slot, Object self, Object[] args, PK |
484 | 487 | return CallSlotTpNewNodeGen.getUncached().execute(null, null, slot, self, args, keywords); |
485 | 488 | } |
486 | 489 |
|
487 | | - @Specialization |
488 | | - static Object callPython(VirtualFrame frame, Node inliningTarget, TpSlotPythonSingle slot, Object self, Object[] args, PKeyword[] keywords, |
| 490 | + @Specialization(guards = "hasDefaultMetatype(inliningTarget, self, getClassNode)", limit = "1") |
| 491 | + static Object callPythonFast(VirtualFrame frame, Node inliningTarget, TpSlotPythonSingle slot, Object self, Object[] args, PKeyword[] keywords, |
| 492 | + @Cached GetClassNode getClassNode, |
489 | 493 | @Cached BindNewMethodNode bindNew, |
490 | | - @Cached(inline = false) CallNode callNode) { |
| 494 | + @Exclusive @Cached(inline = false) CallNode callNode) { |
491 | 495 | Object callable = bindNew.execute(frame, inliningTarget, slot.getCallable(), self); |
492 | 496 | return callNode.execute(frame, callable, PythonUtils.prependArgument(self, args), keywords); |
493 | 497 | } |
494 | 498 |
|
| 499 | + @Specialization(replaces = "callPythonFast") |
| 500 | + static Object callPython(VirtualFrame frame, Node inliningTarget, @SuppressWarnings("unused") TpSlotPythonSingle slot, Object self, Object[] args, PKeyword[] keywords, |
| 501 | + @Cached PyObjectGetAttr getNew, |
| 502 | + @Exclusive @Cached(inline = false) CallNode callNode) { |
| 503 | + Object callable = getNew.execute(frame, inliningTarget, self, T___NEW__); |
| 504 | + return callNode.execute(frame, callable, PythonUtils.prependArgument(self, args), keywords); |
| 505 | + } |
| 506 | + |
| 507 | + static boolean hasDefaultMetatype(Node inliningTarget, Object self, GetClassNode getClassNode) { |
| 508 | + return getClassNode.execute(inliningTarget, self) == PythonBuiltinClassType.PythonClass; |
| 509 | + } |
| 510 | + |
495 | 511 | @Specialization |
496 | 512 | @InliningCutoff |
497 | 513 | static Object callNative(VirtualFrame frame, TpSlotCExtNative slot, Object self, Object[] args, PKeyword[] keywords, |
|
0 commit comments