Interface RegionRecoveryBridge

  • All Known Implementing Classes:
    StatementRecoverer

    public interface RegionRecoveryBridge
    The narrow set of statement/expression recovery leaves the reaching-condition engine needs from the host StatementRecoverer.
    • Method Detail

      • recoverSimpleBlock

        List<Statement> recoverSimpleBlock​(IRBlock block)
        The straight-line statements of block (its terminator branch is not emitted here).
        Parameters:
        block - the block to recover
        Returns:
        its straight-line statements
      • recoverCondition

        Expression recoverCondition​(IRBlock block,
                                    boolean negate)
        The branch condition of block, negated when negate is set.
        Parameters:
        block - the block terminated by the branch
        negate - whether to recover the complement
        Returns:
        the condition expression
      • conditionInlinesSideEffect

        boolean conditionInlinesSideEffect​(IRBlock block)
        True when recovering block's branch condition would inline an allocation or call - a side effect a shared-tail guard must not duplicate by re-emitting the condition.
        Parameters:
        block - the block whose branch condition is inspected
        Returns:
        true when re-emitting the condition would repeat a side effect
      • guardAtomExceptionFree

        boolean guardAtomExceptionFree​(IRBlock block)
        True when recovering block's branch condition inlines no operation that can throw.
        Parameters:
        block - the block whose branch condition is inspected
        Returns:
        true when the condition inlines nothing that can throw
      • isDuplicationSafe

        boolean isDuplicationSafe​(IRBlock block)
        True when block may be duplicated - re-recovered once per reaching edge - without changing semantics or perturbing the round trip.
        Parameters:
        block - the block a region would re-recover per reaching edge
        Returns:
        true when duplicating it is safe
      • lowerPhisOnEdge

        List<Statement> lowerPhisOnEdge​(IRBlock pred,
                                        IRBlock succ)
        SSA-destruction copies realized when the edge pred -> succ is taken.
        Parameters:
        pred - the source block of the edge
        succ - the target block whose phis are lowered
        Returns:
        the copies for that edge
      • stackPhiCopiesOnEdge

        List<Statement> stackPhiCopiesOnEdge​(IRBlock pred,
                                             IRBlock succ)
        Copies for the operand-stack merge phis of succ whose incoming on this edge is produced by no instruction in pred.
        Parameters:
        pred - the source block of the edge
        succ - the merge block whose stack phis are lowered
        Returns:
        the copies that arm owes the merge, empty when the arm already produced them
      • recoverUnconsumedForLoopInits

        List<Statement> recoverUnconsumedForLoopInits​(IRBlock header)
        The still-unconsumed for-induction inits of header's preheader.
        Parameters:
        header - the loop header whose preheader holds the inits
        Returns:
        the init declarations, empty when none remain
      • regionContainsUnprocessedHandler

        boolean regionContainsUnprocessedHandler​(Set<IRBlock> region)
        True when some block in region starts an exception handler the surrounding recovery has not yet consumed - a nested try the engine must decline so the try/catch scaffolding recovers it.
        Parameters:
        region - the blocks under consideration
        Returns:
        true when one of them starts an unconsumed handler
      • markRegionBlockProcessed

        void markRegionBlockProcessed​(IRBlock block,
                                      List<Statement> statements)
        Records block's recovered statements and marks it emitted so nothing re-emits it.
        Parameters:
        block - the block being consumed
        statements - the statements recovered for it
      • isRegionBlockProcessed

        boolean isRegionBlockProcessed​(IRBlock block)
        True once block has been emitted.
        Parameters:
        block - the block to test
        Returns:
        true when it has already been emitted
      • processedReturnStatements

        List<Statement> processedReturnStatements​(IRBlock block)
        The statements of a processed RETURN block, for idempotent re-emission - a trailing return two paths share is recovered once by the first path's pass.
        Parameters:
        block - the shared trailing block
        Returns:
        its recovered return statements, empty when it is not a bare processed return
      • tryCollapseTernaryDiamond

        boolean tryCollapseTernaryDiamond​(IRBlock branch)
        Collapses a value-producing ternary diamond headed by branch to a cached ternary expression, returning true when it applies.
        Parameters:
        branch - the candidate diamond head
        Returns:
        true when the diamond was collapsed and its arms marked emitted
      • decodeSwitch

        SwitchDescriptor decodeSwitch​(IRBlock switchBlock)
        Decodes switchBlock into a structuring-ready SwitchDescriptor - selector, merge, ordered cases and labels - without recovering case bodies or marking any block, so the reaching-condition engine can structure the cases itself.
        Parameters:
        switchBlock - the block terminated by the switch
        Returns:
        the decoded descriptor, or null for a shape the engine does not own natively
      • recoverSwitchHeaderStatements

        List<Statement> recoverSwitchHeaderStatements​(IRBlock header)
        The switch header's own statements for emission before the switch.
        Parameters:
        header - the switch header block
        Returns:
        the statements to emit before the switch
      • startsUnprocessedHandler

        boolean startsUnprocessedHandler​(IRBlock block)
        True when block starts the protected range of an exception handler no recovery has consumed.
        Parameters:
        block - the candidate protected-range start
        Returns:
        true when an unconsumed handler protects a range starting there
      • isRetiredHandlerBlock

        boolean isRetiredHandlerBlock​(IRBlock block)
        Whether block is the entry of an exception handler the surrounding recovery has already consumed - a retired copy-side guard catch or a de-duplicated finally's scaffolding.
        Parameters:
        block - the candidate handler entry
        Returns:
        true when it is a retired handler entry
      • decodeTryNode

        TryNodeDescriptor decodeTryNode​(IRBlock block,
                                        Set<IRBlock> regionStops)
        Statically decodes the try starting at block into an opaque TryNodeDescriptor - the blocks the try/catch recovery will consume and the single join it continues at - without recovering or marking anything.
        Parameters:
        block - the candidate try entry
        regionStops - blocks that bound the enclosing region's walk
        Returns:
        the decoded node, or null for a shape the node model does not own
      • recoverBoundaryTail

        List<Statement> recoverBoundaryTail​(IRBlock tail)
        Recovers a straight terminal tail (single-successor blocks chaining into a return/throw) as fresh statements, without marking the blocks processed.
        Parameters:
        tail - the first block of the candidate tail chain
        Returns:
        the tail's statements, or null when the shape is not a straight terminal tail
      • unrecoveredTryNode

        void unrecoveredTryNode​(IRBlock block)
        Signals that the host's try recovery produced nothing for a try node the engine had decoded - a routing gap, since every region structures through the engine.
        Parameters:
        block - the try entry whose recovery produced nothing