()
| 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(); |
no test coverage detected