private static void setupCatchTypes(SSACFG cfg, Map<IBasicBlock<SSAInstruction>, TypeReference[]> map) { for(Entry<IBasicBlock<SSAInstruction>, TypeReference[]> e : map.entrySet()) { if (e.getKey().getNumber() != -1) { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber()); for (int j = 0; j < e.getValue().length; j++) { bb.addCaughtExceptionType(e.getValue()[j]); } } } }
TwoLevelIterator() { currentBlockIndex = 0; currentBlockIterator = cfg.getNode(0).iteratePhis(); if (!currentBlockIterator.hasNext()) { advanceBlock(); } }
private static void setupCatchTypes(SSACFG cfg, Map<IBasicBlock<SSAInstruction>, TypeReference[]> map) { for(Entry<IBasicBlock<SSAInstruction>, TypeReference[]> e : map.entrySet()) { if (e.getKey().getNumber() != -1) { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(e.getKey().getNumber()); for (int j = 0; j < e.getValue().length; j++) { bb.addCaughtExceptionType(e.getValue()[j]); } } } }
TwoLevelIterator() { currentBlockIndex = 0; currentBlockIterator = cfg.getNode(0).iteratePhis(); if (!currentBlockIterator.hasNext()) { advanceBlock(); } }
private void advanceBlock() { for (int i = currentBlockIndex + 1; i <= cfg.getMaxNumber(); i++) { Iterator<? extends SSAInstruction> it = getBlockIterator(cfg.getNode(i)); if (it.hasNext()) { currentBlockIndex = i; currentBlockIterator = it; return; } } currentBlockIterator = null; currentBlockIndex = -1; } }
private void advanceBlock() { for (int i = currentBlockIndex + 1; i <= cfg.getMaxNumber(); i++) { Iterator<? extends SSAInstruction> it = getBlockIterator(cfg.getNode(i)); if (it.hasNext()) { currentBlockIndex = i; currentBlockIterator = it; return; } } currentBlockIterator = null; currentBlockIndex = -1; } }
@Override public String toString() { StringBuilder s = new StringBuilder(); for (int i = 0; i <= getNumber(exit()); i++) { BasicBlock bb = getNode(i); s.append("BB").append(i).append('[').append(bb.getFirstInstructionIndex()).append("..").append(bb.getLastInstructionIndex()) .append("]\n"); Iterator<ISSABasicBlock> succNodes = getSuccNodes(bb); while (succNodes.hasNext()) { s.append(" -> BB").append(((BasicBlock) succNodes.next()).getNumber()).append('\n'); } } return s.toString(); }
@Override public String toString() { StringBuilder s = new StringBuilder(); for (int i = 0; i <= getNumber(exit()); i++) { BasicBlock bb = getNode(i); s.append("BB").append(i).append('[').append(bb.getFirstInstructionIndex()).append("..").append(bb.getLastInstructionIndex()) .append("]\n"); Iterator<ISSABasicBlock> succNodes = getSuccNodes(bb); while (succNodes.hasNext()) { s.append(" -> BB").append(((BasicBlock) succNodes.next()).getNumber()).append('\n'); } } return s.toString(); }
private void advanceBlock() { for (int i = currentBlockIndex + 1; i < cfg.getMaxNumber(); i++) { if (hasCatch(cfg.getNode(i))) { currentBlockIndex = i; return; } } currentBlockIndex = -1; } }
CatchIterator() { currentBlockIndex = 0; if (!hasCatch(cfg.getNode(0))) { advanceBlock(); } }
CatchIterator() { currentBlockIndex = 0; if (!hasCatch(cfg.getNode(0))) { advanceBlock(); } }
@Override public SSAInstruction next() { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(currentBlockIndex); SSAInstruction result = bb.getCatchInstruction(); advanceBlock(); return result; }
private void advanceBlock() { for (int i = currentBlockIndex + 1; i < cfg.getMaxNumber(); i++) { if (hasCatch(cfg.getNode(i))) { currentBlockIndex = i; return; } } currentBlockIndex = -1; } }
@Override public SSAInstruction next() { ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) cfg.getNode(currentBlockIndex); SSAInstruction result = bb.getCatchInstruction(); advanceBlock(); return result; }
public static void testCFG(SSACFG cfg, int[][] assertions) { for(int i = 0; i < assertions.length; i++) { SSACFG.BasicBlock bb= cfg.getNode(i); Assert.assertEquals("basic block " + i, assertions[i].length, cfg.getSuccNodeCount(bb)); for(int j = 0; j < assertions[i].length; j++) { Assert.assertTrue(cfg.hasEdge(bb, cfg.getNode(assertions[i][j]))); } } } }
@Override public int meetStackAtCatchBlock(BasicBlock bb) { int bbNumber = shrikeCFG.getNumber(bb); SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) cfg.getNode(bbNumber); SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); int exceptionValue; if (s == null) { exceptionValue = symbolTable.newSymbol(); s = insts.GetCaughtExceptionInstruction(SSAInstruction.NO_INDEX, bbNumber, exceptionValue); newBB.setCatchInstruction(s); } else { exceptionValue = s.getException(); } return exceptionValue; } }
private void setCatchInstructions(SSACFG ssacfg, AbstractCFG<?, ?> oldcfg) { for (int i = 0; i < oldcfg.getNumberOfNodes(); i++) if (oldcfg.isCatchBlock(i)) { ExceptionHandlerBasicBlock B = (ExceptionHandlerBasicBlock) ssacfg.getNode(i); B.setCatchInstruction((SSAGetCaughtExceptionInstruction) getInstructions()[B.getFirstInstructionIndex()]); getInstructions()[B.getFirstInstructionIndex()] = null; } }
private void setCatchInstructions(SSACFG ssacfg, AbstractCFG<?, ?> oldcfg) { for (int i = 0; i < oldcfg.getNumberOfNodes(); i++) if (oldcfg.isCatchBlock(i)) { ExceptionHandlerBasicBlock B = (ExceptionHandlerBasicBlock) ssacfg.getNode(i); B.setCatchInstruction((SSAGetCaughtExceptionInstruction) getInstructions()[B.getFirstInstructionIndex()]); getInstructions()[B.getFirstInstructionIndex()] = null; } }
@Override public int meetStackAtCatchBlock(BasicBlock bb) { int bbNumber = shrikeCFG.getNumber(bb); SSACFG.ExceptionHandlerBasicBlock newBB = (SSACFG.ExceptionHandlerBasicBlock) cfg.getNode(bbNumber); SSAGetCaughtExceptionInstruction s = newBB.getCatchInstruction(); int exceptionValue; if (s == null) { exceptionValue = symbolTable.newSymbol(); s = insts.GetCaughtExceptionInstruction(SSAInstruction.NO_INDEX, bbNumber, exceptionValue); newBB.setCatchInstruction(s); } else { exceptionValue = s.getException(); } return exceptionValue; } }
protected void verifyCFGAssertions(CallGraph CG, Object[][] assertionData) { for(Object[] dat : assertionData) { String function = (String) dat[0]; for(CGNode N : getNodes(CG, function)) { int[][] edges = (int[][]) dat[1]; SSACFG cfg = N.getIR().getControlFlowGraph(); for (int i = 0; i < edges.length; i++) { SSACFG.BasicBlock bb = cfg.getNode(i); Assert.assertEquals("basic block " + i, edges[i].length, cfg.getSuccNodeCount(bb)); for (int j = 0; j < edges[i].length; j++) { Assert.assertTrue(cfg.hasEdge(bb, cfg.getNode(edges[i][j]))); } } } } }