Ejemplo n.º 1
0
Archivo: CFG.java Proyecto: cwgem/jruby
  public String toStringInstrs() {
    StringBuilder buf = new StringBuilder();

    for (BasicBlock b : getSortedBasicBlocks()) {
      buf.append(b.toStringInstrs());
    }
    buf.append("\n\n------ Rescue block map ------\n");
    for (BasicBlock bb : rescuerMap.keySet()) {
      buf.append("BB ")
          .append(bb.getID())
          .append(" --> BB ")
          .append(rescuerMap.get(bb).getID())
          .append("\n");
    }
    buf.append("\n\n------ Ensure block map ------\n");
    for (BasicBlock bb : ensurerMap.keySet()) {
      buf.append("BB ")
          .append(bb.getID())
          .append(" --> BB ")
          .append(ensurerMap.get(bb).getID())
          .append("\n");
    }

    List<IRClosure> closures = scope.getClosures();
    if (!closures.isEmpty()) {
      buf.append("\n\n------ Closures encountered in this scope ------\n");
      for (IRClosure c : closures) {
        buf.append(c.toStringBody());
      }
      buf.append("------------------------------------------------\n");
    }

    return buf.toString();
  }
Ejemplo n.º 2
0
Archivo: CFG.java Proyecto: cwgem/jruby
  private LinkedList<BasicBlock> buildPostOrderList() {
    LinkedList<BasicBlock> list = new LinkedList<BasicBlock>();
    BasicBlock root = getEntryBB();
    Stack<BasicBlock> stack = new Stack<BasicBlock>();
    stack.push(root);
    BitSet bbSet = new BitSet(1 + getMaxNodeID());
    bbSet.set(root.getID());

    // Non-recursive post-order traversal (the added flag is required to handle cycles and common
    // ancestors)
    while (!stack.empty()) {
      // Check if all children of the top of the stack have been added
      BasicBlock b = stack.peek();
      boolean allChildrenDone = true;
      for (BasicBlock dst : getOutgoingDestinations(b)) {
        int dstID = dst.getID();
        if (!bbSet.get(dstID)) {
          allChildrenDone = false;
          stack.push(dst);
          bbSet.set(dstID);
        }
      }

      // If all children have been added previously, we are ready with 'b' in this round!
      if (allChildrenDone) {
        stack.pop();
        list.add(b);
      }
    }

    // Sanity check!
    for (BasicBlock b : getBasicBlocks()) {
      if (!bbSet.get(b.getID())) {
        printError("BB " + b.getID() + " missing from po list!");
        break;
      }
    }

    return list;
  }
Ejemplo n.º 3
0
  @Override
  public String toString() {
    StringBuilder buf = new StringBuilder("Vertex ");

    buf.append(basicBlock.getID()).append(":\nincoming edges\n");
    for (Edge edge : getIncomingEdges()) {
      buf.append(edge).append("\n");
    }

    buf.append("outgoing edges\n");
    for (Edge edge : getOutgoingEdges()) {
      buf.append(edge).append("\n");
    }

    return buf.toString();
  }