Interface RegionRecoveryBridge
-
- All Known Implementing Classes:
StatementRecoverer
public interface RegionRecoveryBridgeThe narrow set of statement/expression recovery leaves the reaching-condition engine needs from the hostStatementRecoverer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanconditionInlinesSideEffect(IRBlock block)True when recoveringblock's branch condition would inline an allocation or call - a side effect a shared-tail guard must not duplicate by re-emitting the condition.SwitchDescriptordecodeSwitch(IRBlock switchBlock)DecodesswitchBlockinto a structuring-readySwitchDescriptor- selector, merge, ordered cases and labels - without recovering case bodies or marking any block, so the reaching-condition engine can structure the cases itself.TryNodeDescriptordecodeTryNode(IRBlock block, Set<IRBlock> regionStops)Statically decodes the try starting atblockinto an opaqueTryNodeDescriptor- the blocks the try/catch recovery will consume and the single join it continues at - without recovering or marking anything.booleanguardAtomExceptionFree(IRBlock block)True when recoveringblock's branch condition inlines no operation that can throw.booleanisDuplicationSafe(IRBlock block)True whenblockmay be duplicated - re-recovered once per reaching edge - without changing semantics or perturbing the round trip.booleanisRegionBlockProcessed(IRBlock block)True onceblockhas been emitted.booleanisRetiredHandlerBlock(IRBlock block)Whetherblockis 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.List<Statement>lowerInductionPhiInitsOnEdge(IRBlock pred, IRBlock succ)List<Statement>lowerPhisOnEdge(IRBlock pred, IRBlock succ)SSA-destruction copies realized when the edgepred -> succis taken.voidmarkRegionBlockProcessed(IRBlock block, List<Statement> statements)Recordsblock's recovered statements and marks it emitted so nothing re-emits it.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.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.ExpressionrecoverCondition(IRBlock block, boolean negate)The branch condition ofblock, negated whennegateis set.booleanrecoveredTryTerminates(Statement recovered)Whether a statement recovered byrecoverTryNode(com.tonic.analysis.ssa.cfg.IRBlock, com.tonic.analysis.source.recovery.rcs.TryNodeDescriptor, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>)leaves no normal fall-through.List<Statement>recoverSimpleBlock(IRBlock block)The straight-line statements ofblock(its terminator branch is not emitted here).List<Statement>recoverSwitchHeaderStatements(IRBlock header)The switch header's own statements for emission before theswitch.StatementrecoverTryNode(IRBlock block, TryNodeDescriptor node, Set<IRBlock> stopBlocks, Set<IRBlock> alreadyEmitted)Recovers the try node starting atblockas one statement via the host's try/catch machinery, marking its handler and blocks consumed.List<Statement>recoverUnconsumedForLoopInits(IRBlock header)The still-unconsumed for-induction inits ofheader's preheader.booleanregionContainsUnprocessedHandler(Set<IRBlock> region)True when some block inregionstarts an exception handler the surrounding recovery has not yet consumed - a nested try the engine must decline so the try/catch scaffolding recovers it.List<Statement>stackPhiCopiesOnEdge(IRBlock pred, IRBlock succ)Copies for the operand-stack merge phis ofsuccwhose incoming on this edge is produced by no instruction inpred.booleanstartsUnprocessedHandler(IRBlock block)True whenblockstarts the protected range of an exception handler no recovery has consumed.booleantryCollapseTernaryDiamond(IRBlock branch)Collapses a value-producing ternary diamond headed bybranchto a cached ternary expression, returning true when it applies.voidunrecoveredTryNode(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.
-
-
-
Method Detail
-
recoverSimpleBlock
List<Statement> recoverSimpleBlock(IRBlock block)
The straight-line statements ofblock(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 ofblock, negated whennegateis set.- Parameters:
block- the block terminated by the branchnegate- whether to recover the complement- Returns:
- the condition expression
-
conditionInlinesSideEffect
boolean conditionInlinesSideEffect(IRBlock block)
True when recoveringblock'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 recoveringblock'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 whenblockmay 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 edgepred -> succis taken.- Parameters:
pred- the source block of the edgesucc- 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 ofsuccwhose incoming on this edge is produced by no instruction inpred.- Parameters:
pred- the source block of the edgesucc- the merge block whose stack phis are lowered- Returns:
- the copies that arm owes the merge, empty when the arm already produced them
-
lowerInductionPhiInitsOnEdge
List<Statement> lowerInductionPhiInitsOnEdge(IRBlock pred, IRBlock succ)
-
recoverUnconsumedForLoopInits
List<Statement> recoverUnconsumedForLoopInits(IRBlock header)
The still-unconsumed for-induction inits ofheader'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 inregionstarts 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)
Recordsblock's recovered statements and marks it emitted so nothing re-emits it.- Parameters:
block- the block being consumedstatements- the statements recovered for it
-
isRegionBlockProcessed
boolean isRegionBlockProcessed(IRBlock block)
True onceblockhas 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 bybranchto 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)
DecodesswitchBlockinto a structuring-readySwitchDescriptor- 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 theswitch.- Parameters:
header- the switch header block- Returns:
- the statements to emit before the switch
-
startsUnprocessedHandler
boolean startsUnprocessedHandler(IRBlock block)
True whenblockstarts 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)
Whetherblockis 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 atblockinto an opaqueTryNodeDescriptor- 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 entryregionStops- 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
-
recoverTryNode
Statement recoverTryNode(IRBlock block, TryNodeDescriptor node, Set<IRBlock> stopBlocks, Set<IRBlock> alreadyEmitted)
Recovers the try node starting atblockas one statement via the host's try/catch machinery, marking its handler and blocks consumed.- Parameters:
block- the try entrynode- the descriptor decoded bydecodeTryNode(com.tonic.analysis.ssa.cfg.IRBlock, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>)stopBlocks- blocks the try's walk must not cross intoalreadyEmitted- region blocks recovered before the node- Returns:
- the try statement, or null when the shape cannot be recovered
-
recoveredTryTerminates
boolean recoveredTryTerminates(Statement recovered)
Whether a statement recovered byrecoverTryNode(com.tonic.analysis.ssa.cfg.IRBlock, com.tonic.analysis.source.recovery.rcs.TryNodeDescriptor, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>)leaves no normal fall-through.- Parameters:
recovered- a statement produced byrecoverTryNode(com.tonic.analysis.ssa.cfg.IRBlock, com.tonic.analysis.source.recovery.rcs.TryNodeDescriptor, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>, java.util.Set<com.tonic.analysis.ssa.cfg.IRBlock>)- Returns:
- true when every path out of it returns or throws
-
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
-
-