MCPcopy Create free account
hub / github.com/dynjs/dynjs / deleteOrphanedBlocks

Method deleteOrphanedBlocks

src/main/java/org/dynjs/ir/representations/CFG.java:309–329  ·  view source on GitHub ↗
(DirectedGraph<BasicBlock> graph)

Source from the content-addressed store, hash-verified

307 }
308
309 private void deleteOrphanedBlocks(DirectedGraph<BasicBlock> graph) {
310 // System.out.println("\nGraph:\n" + toStringGraph());
311 // System.out.println("\nInstructions:\n" + toStringInstrs());
312
313 // FIXME: Quick and dirty implementation
314 while (true) {
315 BasicBlock bbToRemove = null;
316 for (BasicBlock b : graph.allData()) {
317 if (b == entryBB) continue; // Skip entry bb!
318
319 // Every other bb should have at least one incoming edge
320 if (graph.findVertexFor(b).getIncomingEdges().isEmpty()) {
321 bbToRemove = b;
322 break;
323 }
324 }
325 if (bbToRemove == null) break;
326
327 removeBB(bbToRemove);
328 }
329 }
330
331 public Collection<BasicBlock> getBasicBlocks() {
332 return graph.allData();

Callers 1

optimizeMethod · 0.95

Calls 2

removeBBMethod · 0.95
isEmptyMethod · 0.45

Tested by

no test coverage detected