Ejemplo n.º 1
0
    protected void calcLatestBlock(
        Block earliestBlock,
        SchedulingStrategy strategy,
        Node currentNode,
        NodeMap<Block> currentNodeMap,
        LocationIdentity constrainingLocation,
        BlockMap<ArrayList<FloatingReadNode>> watchListMap,
        BlockMap<List<Node>> latestBlockToNodesMap,
        NodeBitMap visited,
        boolean immutableGraph) {
      Block latestBlock = null;
      assert currentNode.hasUsages();
      for (Node usage : currentNode.usages()) {
        if (immutableGraph && !visited.contains(usage)) {
          /*
           * Normally, dead nodes are deleted by the scheduler before we reach this point.
           * Only when the scheduler is asked to not modify a graph, we can see dead nodes
           * here.
           */
          continue;
        }
        latestBlock = calcBlockForUsage(currentNode, usage, latestBlock, currentNodeMap);
      }

      if (strategy == SchedulingStrategy.FINAL_SCHEDULE
          || strategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS) {
        while (latestBlock.getLoopDepth() > earliestBlock.getLoopDepth()
            && latestBlock != earliestBlock.getDominator()) {
          latestBlock = latestBlock.getDominator();
        }
      }

      if (latestBlock != earliestBlock
          && latestBlock != earliestBlock.getDominator()
          && constrainingLocation != null) {
        latestBlock = checkKillsBetween(earliestBlock, latestBlock, constrainingLocation);
      }

      selectLatestBlock(
          currentNode,
          earliestBlock,
          latestBlock,
          currentNodeMap,
          watchListMap,
          constrainingLocation,
          latestBlockToNodesMap);
    }