示例#1
0
 private void visitForward(NodeBitMap visited, Node node) {
   if (node != null && !visited.isMarked(node)) {
     visited.mark(node);
     if (node.predecessor() != null) {
       visitForward(visited, node.predecessor());
     }
     if (node instanceof MergeNode) {
       // make sure that the cfg predecessors of a MergeNode are processed first
       MergeNode merge = (MergeNode) node;
       for (int i = 0; i < merge.forwardEndCount(); i++) {
         visitForward(visited, merge.forwardEndAt(i));
       }
     }
     for (Node input : node.inputs()) {
       visitForward(visited, input);
     }
     if (node instanceof LoopBeginNode) {
       LoopBeginNode loopBegin = (LoopBeginNode) node;
       for (LoopEndNode loopEnd : loopBegin.loopEnds()) {
         visitForward(visited, loopEnd);
       }
     }
     nodes.add(node);
   }
 }
 private boolean accept(T n) {
   if (n == null) {
     return true;
   }
   if (visited == null) {
     visited = n.graph().createNodeBitMap();
   }
   boolean accept = !visited.isMarked(n);
   visited.mark(n);
   return accept;
 }
示例#3
0
 private void visitBackward(NodeBitMap visited, Node node) {
   if (node != null && !visited.isMarked(node)) {
     visited.mark(node);
     for (Node successor : node.successors()) {
       visitBackward(visited, successor);
     }
     for (Node usage : node.usages()) {
       visitBackward(visited, usage);
     }
     nodes.add(node);
   }
 }
示例#4
0
    private static void resortEarliestWithinBlock(
        Block b,
        BlockMap<List<Node>> blockToNodes,
        NodeMap<Block> nodeToBlock,
        NodeBitMap unprocessed) {
      ArrayList<FloatingReadNode> watchList = new ArrayList<>();
      List<Node> oldList = blockToNodes.get(b);
      AbstractBeginNode beginNode = b.getBeginNode();
      for (Node n : oldList) {
        if (n instanceof FloatingReadNode) {
          FloatingReadNode floatingReadNode = (FloatingReadNode) n;
          LocationIdentity locationIdentity = floatingReadNode.getLocationIdentity();
          MemoryNode lastLocationAccess = floatingReadNode.getLastLocationAccess();
          if (locationIdentity.isMutable() && lastLocationAccess != null) {
            ValueNode lastAccessLocation = lastLocationAccess.asNode();
            if (nodeToBlock.get(lastAccessLocation) == b
                && lastAccessLocation != beginNode
                && !(lastAccessLocation instanceof MemoryPhiNode)) {
              // This node's last access location is within this block. Add to watch
              // list when processing the last access location.
            } else {
              watchList.add(floatingReadNode);
            }
          }
        }
      }

      ArrayList<Node> newList = new ArrayList<>(oldList.size());
      assert oldList.get(0) == beginNode;
      unprocessed.clear(beginNode);
      newList.add(beginNode);
      for (int i = 1; i < oldList.size(); ++i) {
        Node n = oldList.get(i);
        if (unprocessed.isMarked(n)) {
          if (n instanceof MemoryNode) {
            if (n instanceof MemoryCheckpoint) {
              assert n instanceof FixedNode;
              if (watchList.size() > 0) {
                // Check whether we need to commit reads from the watch list.
                checkWatchList(b, nodeToBlock, unprocessed, newList, watchList, n);
              }
            }
            // Add potential dependent reads to the watch list.
            for (Node usage : n.usages()) {
              if (usage instanceof FloatingReadNode) {
                FloatingReadNode floatingReadNode = (FloatingReadNode) usage;
                if (nodeToBlock.get(floatingReadNode) == b
                    && floatingReadNode.getLastLocationAccess() == n
                    && !(n instanceof MemoryPhiNode)) {
                  watchList.add(floatingReadNode);
                }
              }
            }
          }
          assert unprocessed.isMarked(n);
          unprocessed.clear(n);
          newList.add(n);
        } else {
          // This node was pulled up.
          assert !(n instanceof FixedNode) : n;
        }
      }

      for (Node n : newList) {
        unprocessed.mark(n);
      }

      assert newList.size() == oldList.size();
      blockToNodes.put(b, newList);
    }