@Override public boolean isEntryBlock() { return this == SSACFG.this.entry(); }
@Override public boolean isEntryBlock() { return this == SSACFG.this.entry(); }
private void renameVariables() { for (int V = 1; V <= getMaxValueNumber(); V++) { if (!skip(V)) { C[V] = 0; S[V] = new IntStack(); } } initializeVariables(); SEARCH(CFG.entry()); }
private void renameVariables() { for (int V = 1; V <= getMaxValueNumber(); V++) { if (!skip(V)) { C[V] = 0; S[V] = new IntStack(); } } initializeVariables(); SEARCH(CFG.entry()); }
public IntraproceduralNullPointerAnalysis(IR ir) { if (ir == null || ir.isEmptyIR()) { throw new IllegalArgumentException("IR may not be null or empty."); } this.ir = ir; final int maxVarNum = ir.getSymbolTable().getMaxValueNumber(); SSACFG cfg = ir.getControlFlowGraph(); final NullPointerFrameWork<ISSABasicBlock> problem = new NullPointerFrameWork<>( cfg, ir); this.solver = new NullPointerSolver<>(problem, maxVarNum, ir, cfg.entry()); try { this.solver.solve(NO_PROGRESS_MONITOR); } catch (final CancelException e) { // can't happen as we have no monitor } }
public IntraproceduralNullPointerAnalysis(IR ir) { if (ir == null || ir.isEmptyIR()) { throw new IllegalArgumentException("IR may not be null or empty."); } this.ir = ir; final int maxVarNum = ir.getSymbolTable().getMaxValueNumber(); SSACFG cfg = ir.getControlFlowGraph(); final NullPointerFrameWork<ISSABasicBlock> problem = new NullPointerFrameWork<>( cfg, ir); this.solver = new NullPointerSolver<>(problem, maxVarNum, ir, cfg.entry()); try { this.solver.solve(NO_PROGRESS_MONITOR); } catch (final CancelException e) { // can't happen as we have no monitor } }
@Override public List<IExplodedBasicBlock> getExceptionalSuccessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(exit)) { return Collections.emptyList(); } if (eb.isEntryBlock() || eb.instructionIndex == eb.original.getLastInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); ISSABasicBlock orig = eb.original; if (eb.isEntryBlock() && orig == null) { orig = ir.getControlFlowGraph().entry(); } for (ISSABasicBlock s : ir.getControlFlowGraph().getExceptionalSuccessors(orig)) { if (s.equals(ir.getControlFlowGraph().exit())) { result.add(exit()); } else { assert normalNodes.get(s.getFirstInstructionIndex()) != null; result.add(normalNodes.get(s.getFirstInstructionIndex())); } } return result; } else { return Collections.emptyList(); } }
@Override public List<IExplodedBasicBlock> getExceptionalSuccessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(exit)) { return Collections.emptyList(); } if (eb.isEntryBlock() || eb.instructionIndex == eb.original.getLastInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); ISSABasicBlock orig = eb.original; if (eb.isEntryBlock() && orig == null) { orig = ir.getControlFlowGraph().entry(); } for (ISSABasicBlock s : ir.getControlFlowGraph().getExceptionalSuccessors(orig)) { if (s.equals(ir.getControlFlowGraph().exit())) { result.add(exit()); } else { assert normalNodes.get(s.getFirstInstructionIndex()) != null; result.add(normalNodes.get(s.getFirstInstructionIndex())); } } return result; } else { return Collections.emptyList(); } }
@Override public Collection<IExplodedBasicBlock> getNormalPredecessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(entry)) { return Collections.emptySet(); } if (eb.isExitBlock() || eb.instructionIndex == eb.original.getFirstInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); for (ISSABasicBlock s : ir.getControlFlowGraph().getNormalPredecessors(eb.original)) { if (s.equals(ir.getControlFlowGraph().entry())) { if (s.getLastInstructionIndex() >= 0) { assert normalNodes.get(s.getLastInstructionIndex()) != null; result.add(normalNodes.get(s.getLastInstructionIndex())); } else { result.add(entry()); } } else { assert normalNodes.get(s.getLastInstructionIndex()) != null; result.add(normalNodes.get(s.getLastInstructionIndex())); } } return result; } else { assert normalNodes.get(eb.instructionIndex - 1) != null; return Collections.singleton(normalNodes.get(eb.instructionIndex - 1)); } }
@Override public Collection<IExplodedBasicBlock> getNormalPredecessors(IExplodedBasicBlock bb) { ExplodedBasicBlock eb = (ExplodedBasicBlock) bb; assert eb != null; if (eb.equals(entry)) { return Collections.emptySet(); } if (eb.isExitBlock() || eb.instructionIndex == eb.original.getFirstInstructionIndex()) { List<IExplodedBasicBlock> result = new ArrayList<>(); for (ISSABasicBlock s : ir.getControlFlowGraph().getNormalPredecessors(eb.original)) { if (s.equals(ir.getControlFlowGraph().entry())) { if (s.getLastInstructionIndex() >= 0) { assert normalNodes.get(s.getLastInstructionIndex()) != null; result.add(normalNodes.get(s.getLastInstructionIndex())); } else { result.add(entry()); } } else { assert normalNodes.get(s.getLastInstructionIndex()) != null; result.add(normalNodes.get(s.getLastInstructionIndex())); } } return result; } else { assert normalNodes.get(eb.instructionIndex - 1) != null; return Collections.singleton(normalNodes.get(eb.instructionIndex - 1)); } }
protected AbstractSSAConversion(IR ir, SSAOptions options) { this.CFG = ir.getControlFlowGraph(); this.DF = new DominanceFrontiers<>(ir.getControlFlowGraph(), ir.getControlFlowGraph().entry()); this.dominatorTree = DF.dominatorTree(); this.flags = new int[2 * ir.getControlFlowGraph().getNumberOfNodes()]; this.instructions = getInstructions(ir); this.phiCounts = new int[CFG.getNumberOfNodes()]; this.symbolTable = ir.getSymbolTable(); this.defaultValues = options.getDefaultValues(); }
protected AbstractSSAConversion(IR ir, SSAOptions options) { this.CFG = ir.getControlFlowGraph(); this.DF = new DominanceFrontiers<>(ir.getControlFlowGraph(), ir.getControlFlowGraph().entry()); this.dominatorTree = DF.dominatorTree(); this.flags = new int[2 * ir.getControlFlowGraph().getNumberOfNodes()]; this.instructions = getInstructions(ir); this.phiCounts = new int[CFG.getNumberOfNodes()]; this.symbolTable = ir.getSymbolTable(); this.defaultValues = options.getDefaultValues(); }
private int findRethrowException() { int index = getCurrentInstructionIndex(); SSACFG.BasicBlock bb = cfg.getBlockForInstruction(index); if (bb.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) bb; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { // TODO: should we really use dominators here? maybe it would be cleaner to propagate // the notion of 'current exception to rethrow' using the abstract interpreter. if (dom == null) { dom = Dominators.make(cfg, cfg.entry()); } ISSABasicBlock x = bb; while (x != null) { if (x.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) x; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { x = dom.getIdom(x); } } // assert false; return -1; } }
private int findRethrowException() { int index = getCurrentInstructionIndex(); SSACFG.BasicBlock bb = cfg.getBlockForInstruction(index); if (bb.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) bb; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { // TODO: should we really use dominators here? maybe it would be cleaner to propagate // the notion of 'current exception to rethrow' using the abstract interpreter. if (dom == null) { dom = Dominators.make(cfg, cfg.entry()); } ISSABasicBlock x = bb; while (x != null) { if (x.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) x; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { x = dom.getIdom(x); } } // assert false; return -1; } }
@SuppressWarnings("unused") private int findRethrowException() { int index = getCurrentInstructionIndex(); SSACFG.BasicBlock bb = cfg.getBlockForInstruction(index); if (bb.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) bb; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { // TODO: should we really use dominators here? maybe it would be cleaner to propagate // the notion of 'current exception to rethrow' using the abstract interpreter. if (dom == null) { dom = Dominators.make(cfg, cfg.entry()); } ISSABasicBlock x = bb; while (x != null) { if (x.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) x; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { x = dom.getIdom(x); } } // assert false; return -1; } }
@SuppressWarnings("unused") private int findRethrowException() { int index = getCurrentInstructionIndex(); SSACFG.BasicBlock bb = cfg.getBlockForInstruction(index); if (bb.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) bb; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { // TODO: should we really use dominators here? maybe it would be cleaner to propagate // the notion of 'current exception to rethrow' using the abstract interpreter. if (dom == null) { dom = Dominators.make(cfg, cfg.entry()); } ISSABasicBlock x = bb; while (x != null) { if (x.isCatchBlock()) { SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) x; SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); return s.getDef(); } else { x = dom.getIdom(x); } } // assert false; return -1; } }
System.out.println(graph); BasicBlock exit = ir.getControlFlowGraph().exit(); if (!exit.equals(ir.getControlFlowGraph().entry())) { Assert.assertTrue(graph.getPredNodeCount(exit) > 0);