|
90 | 90 | import com.oracle.graal.python.nodes.bytecode.FrameInfo; |
91 | 91 | import com.oracle.graal.python.nodes.bytecode.PBytecodeRootNode; |
92 | 92 | import com.oracle.graal.python.nodes.bytecode_dsl.PBytecodeDSLRootNode; |
| 93 | +import com.oracle.graal.python.nodes.call.CallNode; |
93 | 94 | import com.oracle.graal.python.nodes.classes.IsSubtypeNode; |
94 | 95 | import com.oracle.graal.python.nodes.frame.ReadFrameNode; |
95 | 96 | import com.oracle.graal.python.nodes.function.BuiltinFunctionRootNode; |
96 | 97 | import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode; |
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.BuiltinClassProfiles.IsBuiltinClassExactProfile; |
100 | 102 | import com.oracle.graal.python.nodes.object.GetClassNode; |
| 103 | +import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode; |
101 | 104 | import com.oracle.graal.python.nodes.object.IsForeignObjectNode; |
102 | 105 | import com.oracle.graal.python.runtime.CallerFlags; |
103 | 106 | import com.oracle.graal.python.runtime.PythonOptions; |
104 | 107 | import com.oracle.graal.python.runtime.exception.PException; |
105 | 108 | import com.oracle.graal.python.runtime.exception.PythonErrorType; |
106 | 109 | import com.oracle.graal.python.runtime.object.PFactory; |
107 | 110 | import com.oracle.truffle.api.CompilerDirectives; |
| 111 | +import com.oracle.truffle.api.HostCompilerDirectives.InliningCutoff; |
108 | 112 | import com.oracle.truffle.api.bytecode.BytecodeFrame; |
109 | 113 | import com.oracle.truffle.api.bytecode.BytecodeNode; |
110 | 114 | import com.oracle.truffle.api.dsl.Bind; |
@@ -459,19 +463,37 @@ private Object supercheck(VirtualFrame frame, Node inliningTarget, Object cls, O |
459 | 463 | @GenerateNodeFactory |
460 | 464 | public abstract static class GetNode extends DescrGetBuiltinNode { |
461 | 465 | @Specialization |
462 | | - static Object doNoneOrBound(SuperObject self, Object obj, @SuppressWarnings("unused") Object type, |
| 466 | + static Object doNoneOrBound(VirtualFrame frame, SuperObject self, Object obj, @SuppressWarnings("unused") Object type, |
463 | 467 | @Bind Node inliningTarget, |
464 | 468 | @Cached InlinedConditionProfile objIsNoneProfile, |
465 | 469 | @Cached InlinedConditionProfile selfObjIsNullProfile, |
| 470 | + @Cached IsBuiltinClassExactProfile isBuiltinSuperProfile, |
466 | 471 | @Cached GetObjectNode getObject, |
| 472 | + @Cached GetTypeNode getType, |
| 473 | + @Cached GetPythonObjectClassNode getClass, |
| 474 | + @Cached CallNode callNode, |
| 475 | + @Cached InlinedConditionProfile superTypeIsNullProfile, |
467 | 476 | @Cached DoGetNode doGetNode) { |
468 | | - // TODO: (GR-53092) doesn't seem to handle super subclasses like CPython |
469 | 477 | if (objIsNoneProfile.profile(inliningTarget, PGuards.isPNone(obj)) || // |
470 | 478 | selfObjIsNullProfile.profile(inliningTarget, getObject.execute(inliningTarget, self) != null)) { |
471 | 479 | return self; |
472 | 480 | } |
| 481 | + Object cls = getClass.execute(inliningTarget, self); |
| 482 | + if (!isBuiltinSuperProfile.profileClass(inliningTarget, cls, PythonBuiltinClassType.Super)) { |
| 483 | + return doSuperSubclass(frame, inliningTarget, self, obj, cls, getType, callNode, superTypeIsNullProfile); |
| 484 | + } |
473 | 485 | return doGetNode.execute(inliningTarget, self, obj); |
474 | 486 | } |
| 487 | + |
| 488 | + @InliningCutoff |
| 489 | + private static Object doSuperSubclass(VirtualFrame frame, Node inliningTarget, SuperObject self, Object obj, Object cls, GetTypeNode getType, CallNode callNode, |
| 490 | + InlinedConditionProfile superTypeIsNullProfile) { |
| 491 | + Object superType = getType.execute(inliningTarget, self); |
| 492 | + if (superTypeIsNullProfile.profile(inliningTarget, superType == null)) { |
| 493 | + return callNode.execute(frame, cls); |
| 494 | + } |
| 495 | + return callNode.execute(frame, cls, superType, obj); |
| 496 | + } |
475 | 497 | } |
476 | 498 |
|
477 | 499 | @GenerateInline |
|
0 commit comments