|
291 | 291 | import com.oracle.truffle.api.nodes.RootNode; |
292 | 292 | import com.oracle.truffle.api.nodes.UnexpectedResultException; |
293 | 293 | import com.oracle.truffle.api.object.DynamicObject; |
294 | | -import com.oracle.truffle.api.profiles.InlinedBranchProfile; |
295 | 294 | import com.oracle.truffle.api.profiles.InlinedConditionProfile; |
296 | 295 | import com.oracle.truffle.api.source.Source; |
297 | 296 | import com.oracle.truffle.api.source.SourceSection; |
@@ -3550,67 +3549,54 @@ static void doInteropException(AbstractTruffleException exception) { |
3550 | 3549 | @ConstantOperand(type = LocalAccessor.class) |
3551 | 3550 | @ConstantOperand(type = int.class) |
3552 | 3551 | public static final class CheckAndLoadLocal { |
3553 | | - @Specialization(rewriteOn = UnexpectedResultException.class) |
| 3552 | + |
| 3553 | + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "!accessor.isCleared(bytecodeNode, frame)") |
3554 | 3554 | public static int doInt(VirtualFrame frame, LocalAccessor accessor, int index, |
3555 | | - @Bind PBytecodeDSLRootNode rootNode, |
3556 | | - @Bind BytecodeNode bytecodeNode, |
3557 | | - @Bind Node inliningTarget, |
3558 | | - @Shared @Cached InlinedBranchProfile localUnboundProfile) throws UnexpectedResultException { |
3559 | | - if (accessor.isCleared(bytecodeNode, frame)) { |
3560 | | - localUnboundProfile.enter(inliningTarget); |
3561 | | - throw raiseUnbound(rootNode, inliningTarget, index); |
3562 | | - } |
| 3555 | + @Bind BytecodeNode bytecodeNode) throws UnexpectedResultException { |
3563 | 3556 | return accessor.getInt(bytecodeNode, frame); |
3564 | 3557 | } |
3565 | 3558 |
|
3566 | | - @Specialization(rewriteOn = UnexpectedResultException.class) |
| 3559 | + @Specialization(rewriteOn = UnexpectedResultException.class, guards = "!accessor.isCleared(bytecodeNode, frame)") |
3567 | 3560 | public static boolean doBoolean(VirtualFrame frame, LocalAccessor accessor, int index, |
3568 | | - @Bind PBytecodeDSLRootNode rootNode, |
3569 | | - @Bind BytecodeNode bytecodeNode, |
3570 | | - @Bind Node inliningTarget, |
3571 | | - @Shared @Cached InlinedBranchProfile localUnboundProfile) throws UnexpectedResultException { |
3572 | | - if (accessor.isCleared(bytecodeNode, frame)) { |
3573 | | - localUnboundProfile.enter(inliningTarget); |
3574 | | - throw raiseUnbound(rootNode, inliningTarget, index); |
3575 | | - } |
| 3561 | + @Bind BytecodeNode bytecodeNode) throws UnexpectedResultException { |
3576 | 3562 | return accessor.getBoolean(bytecodeNode, frame); |
3577 | 3563 | } |
3578 | 3564 |
|
3579 | | - @Specialization(replaces = {"doInt", "doBoolean"}) |
| 3565 | + @Specialization(replaces = {"doInt", "doBoolean"}, guards = "!accessor.isCleared(bytecodeNode, frame)") |
3580 | 3566 | public static Object doObject(VirtualFrame frame, LocalAccessor accessor, int index, |
3581 | | - @Bind PBytecodeDSLRootNode rootNode, |
3582 | | - @Bind BytecodeNode bytecodeNode, |
3583 | | - @Bind Node inliningTarget, |
3584 | | - @Shared @Cached InlinedBranchProfile localUnboundProfile) { |
3585 | | - if (accessor.isCleared(bytecodeNode, frame)) { |
3586 | | - localUnboundProfile.enter(inliningTarget); |
3587 | | - throw raiseUnbound(rootNode, inliningTarget, index); |
3588 | | - } |
| 3567 | + @Bind BytecodeNode bytecodeNode) { |
3589 | 3568 | return accessor.getObject(bytecodeNode, frame); |
3590 | 3569 | } |
| 3570 | + |
| 3571 | + @Fallback |
| 3572 | + public static Object doFallback(VirtualFrame frame, LocalAccessor accessor, int index, |
| 3573 | + @Bind BytecodeNode bytecodeNode, @Bind Node inliningTarget) { |
| 3574 | + throw raiseUnbound(bytecodeNode, inliningTarget, index); |
| 3575 | + } |
3591 | 3576 | } |
3592 | 3577 |
|
3593 | 3578 | @Operation(storeBytecodeIndex = true) |
3594 | 3579 | @ConstantOperand(type = LocalAccessor.class) |
3595 | 3580 | @ConstantOperand(type = int.class) |
3596 | 3581 | public static final class DeleteLocal { |
3597 | | - @Specialization |
| 3582 | + |
| 3583 | + @Specialization(guards = "!accessor.isCleared(bytecodeNode, frame)") |
3598 | 3584 | public static void doObject(VirtualFrame frame, LocalAccessor accessor, int index, |
3599 | | - @Bind PBytecodeDSLRootNode rootNode, |
3600 | 3585 | @Bind BytecodeNode bytecodeNode, |
3601 | | - @Bind Node inliningTarget, |
3602 | | - @Cached InlinedBranchProfile localUnboundProfile) { |
3603 | | - if (accessor.isCleared(bytecodeNode, frame)) { |
3604 | | - localUnboundProfile.enter(inliningTarget); |
3605 | | - throw raiseUnbound(rootNode, inliningTarget, index); |
3606 | | - } |
| 3586 | + @Bind Node inliningTarget) { |
3607 | 3587 | accessor.clear(bytecodeNode, frame); |
3608 | 3588 | } |
| 3589 | + |
| 3590 | + @Fallback |
| 3591 | + public static void doFallback(VirtualFrame frame, LocalAccessor accessor, int index, |
| 3592 | + @Bind BytecodeNode bytecodeNode, @Bind Node inliningTarget) { |
| 3593 | + throw raiseUnbound(bytecodeNode, inliningTarget, index); |
| 3594 | + } |
3609 | 3595 | } |
3610 | 3596 |
|
3611 | 3597 | @TruffleBoundary |
3612 | | - private static PException raiseUnbound(PBytecodeDSLRootNode rootNode, Node inliningTarget, int index) { |
3613 | | - TruffleString localName = rootNode.getCodeUnit().varnames[index]; |
| 3598 | + private static PException raiseUnbound(BytecodeNode bytecodeNode, Node inliningTarget, int index) { |
| 3599 | + TruffleString localName = ((PBytecodeDSLRootNode) bytecodeNode.getRootNode()).getCodeUnit().varnames[index]; |
3614 | 3600 | throw PRaiseNode.raiseStatic(inliningTarget, PythonBuiltinClassType.UnboundLocalError, ErrorMessages.LOCAL_VAR_REFERENCED_BEFORE_ASSIGMENT, localName); |
3615 | 3601 | } |
3616 | 3602 |
|
|
0 commit comments