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

Method optimize

src/main/java/org/dynjs/ir/representations/CFG.java:410–442  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

408 }
409
410 private void optimize() {
411 List<Edge> toRemove = new ArrayList<Edge>();
412
413 for (BasicBlock b : graph.allData()) {
414 boolean noExceptions = true;
415 for (Instruction i : b.getInstructions()) {
416 if (i.canRaiseException()) {
417 noExceptions = false;
418 break;
419 }
420 }
421
422 if (noExceptions) {
423 for (Edge<BasicBlock> e : graph.findVertexFor(b).getOutgoingEdgesOfType(EdgeType.EXCEPTION)) {
424 BasicBlock source = e.getSource().getData();
425 BasicBlock destination = e.getDestination().getData();
426 toRemove.add(e);
427
428 if (rescuerMap.get(source) == destination) rescuerMap.remove(source);
429 }
430 }
431 }
432
433 if (!toRemove.isEmpty()) {
434 for (Edge edge: toRemove) {
435 graph.removeEdge(edge);
436 }
437 }
438
439 deleteOrphanedBlocks(graph);
440
441 collapseStraightLineBBs();
442 }
443
444 public int outDegree(BasicBlock b) {
445 return graph.findVertexFor(b).outDegree();

Callers 1

buildMethod · 0.95

Calls 8

deleteOrphanedBlocksMethod · 0.95
canRaiseExceptionMethod · 0.80
getMethod · 0.65
getInstructionsMethod · 0.45
addMethod · 0.45
removeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected