private LocationIterator() { this.blockIter = blockIterator(); findNext(); }
/** * Look up a BasicBlock by its unique label. * * @param blockLabel * the label of a BasicBlock * @return the BasicBlock with the given label, or null if there is no such * BasicBlock */ public BasicBlock lookupBlockByLabel(int blockLabel) { for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); if (basicBlock.getLabel() == blockLabel) { return basicBlock; } } return null; }
/** * Get Collection of basic blocks whose IDs are specified by given BitSet. * * @param labelSet * BitSet of block labels * @return a Collection containing the blocks whose IDs are given */ public Collection<BasicBlock> getBlocks(BitSet labelSet) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (labelSet.get(block.getLabel())) { result.add(block); } } return result; }
/** * Get a Collection of basic blocks which contain the bytecode instruction * with given offset. * * @param offset * the bytecode offset of an instruction * @return Collection of BasicBlock objects which contain the instruction * with that offset */ public Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset) { LinkedList<BasicBlock> result = new LinkedList<>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock block = i.next(); if (block.containsInstructionWithOffset(offset)) { result.add(block); } } return result; }
public void checkIntegrity() { // Ensure that basic blocks have only consecutive instructions for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); InstructionHandle prev = null; for (Iterator<InstructionHandle> j = basicBlock.instructionIterator(); j.hasNext();) { InstructionHandle handle = j.next(); if (prev != null && prev.getNext() != handle) { throw new IllegalStateException("Non-consecutive instructions in block " + basicBlock.getLabel() + ": prev=" + prev + ", handle=" + handle); } prev = handle; } } }
/** * Get a bitset containing the unique IDs of all blocks in CFG dominated (or * postdominated, depending on how the analysis was done) by given block. * * @param dominator * we want to get all blocks dominated (or postdominated) by this * block * @return BitSet of the ids of all blocks dominated by the given block */ public BitSet getAllDominatedBy(BasicBlock dominator) { BitSet allDominated = new BitSet(); for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) { BasicBlock block = i.next(); BitSet dominators = getResultFact(block); if (dominators.get(dominator.getLabel())) { allDominated.set(block.getLabel()); } } return allDominated; }
/** * Find set of blocks which were known to be dead before doing the null * pointer analysis. * * @return set of previously dead blocks, indexed by block id * @throws CFGBuilderException * @throws DataflowAnalysisException */ private BitSet findPreviouslyDeadBlocks() throws DataflowAnalysisException, CFGBuilderException { BitSet deadBlocks = new BitSet(); ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); for (Iterator<BasicBlock> i = vnaDataflow.getCFG().blockIterator(); i.hasNext();) { BasicBlock block = i.next(); ValueNumberFrame vnaFrame = vnaDataflow.getStartFact(block); if (vnaFrame.isTop()) { deadBlocks.set(block.getLabel()); } } return deadBlocks; }
/** * Find set of blocks which were known to be dead before doing the null * pointer analysis. * * @return set of previously dead blocks, indexed by block id * @throws CFGBuilderException * @throws DataflowAnalysisException */ private BitSet findPreviouslyDeadBlocks() throws DataflowAnalysisException, CFGBuilderException { BitSet deadBlocks = new BitSet(); ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); for (Iterator<BasicBlock> i = vnaDataflow.getCFG().blockIterator(); i.hasNext();) { BasicBlock block = i.next(); ValueNumberFrame vnaFrame = vnaDataflow.getStartFact(block); if (vnaFrame.isTop()) { deadBlocks.set(block.getLabel()); } } return deadBlocks; }
Iterator<GenLocation> genIterator() { return new Iterator<FindUselessObjects.GenLocation>() { Iterator<Location> locIterator = cfg.locationIterator(); Iterator<BasicBlock> blockIterator = cfg.blockIterator(); GenLocation next = advance();
public void print(PrintStream out) { Iterator<BasicBlock> i = cfg.blockIterator(); while (i.hasNext()) { BasicBlock bb = i.next(); out.println(); out.println("BASIC BLOCK: " + bb.getLabel() + (bb.isExceptionThrower() ? " [EXCEPTION THROWER]" : "") + blockStartAnnotate(bb)); if (bb.isExceptionThrower()) { out.println(" Exception thrower: " + bb.getExceptionThrower()); } CodeExceptionGen exceptionGen = bb.getExceptionGen(); if (exceptionGen != null) { out.println("\tCATCHES " + exceptionGen.getCatchType()); } Iterator<InstructionHandle> j = instructionIterator(bb); while (j.hasNext()) { InstructionHandle handle = j.next(); out.println(handle + instructionAnnotate(handle, bb)); } out.println("END" + blockAnnotate(bb)); Iterator<Edge> edgeIter = isForwards ? cfg.outgoingEdgeIterator(bb) : cfg.incomingEdgeIterator(bb); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); out.println(" " + edge.formatAsString(!isForwards) + " " + edgeAnnotate(edge)); } } }
Iterator<BasicBlock> bbi = cfg.blockIterator(); while (bbi.hasNext()) { BasicBlock bb = bbi.next();
Iterator<BasicBlock> i = cfg.blockIterator(); while (i.hasNext()) { BasicBlock block = i.next();
InstructionHandle domInstruction = dominator.getMatchedInstructionInstructionHandle(); for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) { BasicBlock block = i.next(); boolean includeInstructions = block != domBlock;
Iterator<BasicBlock> i = cfg.blockIterator(); while (i.hasNext()) { BasicBlock block = i.next();
Iterator<BasicBlock> bbi = cfg.blockIterator(); while (bbi.hasNext()) { BasicBlock bb = bbi.next();
for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next(); if (!basicBlock.isExceptionThrower()) {
Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator(); while (bbIter.hasNext()) { BasicBlock basicBlock = bbIter.next();
TypeDataflow typeDataflow = classContext.getTypeDataflow(method); for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) { BasicBlock basicBlock = i.next();
Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator(); LineNumberTable table = method.getLineNumberTable(); int position = exceptionThrowerHandle.getPosition();
Iterator<BasicBlock> bbIter = cfg.blockIterator(); ConstantPoolGen cpg = classContext.getConstantPoolGen(); ValueNumber valueNumberForThis = null;