src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.phases/src/org/graalvm/compiler/phases/schedule/SchedulePhase.java
changeset 58877 aec7bf35d6f5
parent 55509 d58442b8abc1
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
   204 
   204 
   205                 BlockMap<ArrayList<FloatingReadNode>> watchListMap = calcLatestBlocks(selectedStrategy, currentNodeMap, earliestBlockToNodesMap, visited, latestBlockToNodesMap, immutableGraph);
   205                 BlockMap<ArrayList<FloatingReadNode>> watchListMap = calcLatestBlocks(selectedStrategy, currentNodeMap, earliestBlockToNodesMap, visited, latestBlockToNodesMap, immutableGraph);
   206                 sortNodesLatestWithinBlock(cfg, earliestBlockToNodesMap, latestBlockToNodesMap, currentNodeMap, watchListMap, visited);
   206                 sortNodesLatestWithinBlock(cfg, earliestBlockToNodesMap, latestBlockToNodesMap, currentNodeMap, watchListMap, visited);
   207 
   207 
   208                 assert verifySchedule(cfg, latestBlockToNodesMap, currentNodeMap);
   208                 assert verifySchedule(cfg, latestBlockToNodesMap, currentNodeMap);
   209                 assert (!Assertions.detailedAssertionsEnabled(graph.getOptions())) || MemoryScheduleVerification.check(cfg.getStartBlock(), latestBlockToNodesMap);
   209                 assert (!Assertions.detailedAssertionsEnabled(graph.getOptions())) ||
       
   210                                 ScheduleVerification.check(cfg.getStartBlock(), latestBlockToNodesMap, currentNodeMap);
   210 
   211 
   211                 this.blockToNodesMap = latestBlockToNodesMap;
   212                 this.blockToNodesMap = latestBlockToNodesMap;
   212 
   213 
   213             }
   214             }
   214             cfg.setNodeToBlock(currentNodeMap);
   215             cfg.setNodeToBlock(currentNodeMap);
   356                 }
   357                 }
   357                 lastBlock = currentBlock;
   358                 lastBlock = currentBlock;
   358             }
   359             }
   359 
   360 
   360             if (lastBlock.getBeginNode() instanceof KillingBeginNode) {
   361             if (lastBlock.getBeginNode() instanceof KillingBeginNode) {
   361                 LocationIdentity locationIdentity = ((KillingBeginNode) lastBlock.getBeginNode()).getLocationIdentity();
   362                 LocationIdentity locationIdentity = ((KillingBeginNode) lastBlock.getBeginNode()).getKilledLocationIdentity();
   362                 if ((locationIdentity.isAny() || locationIdentity.equals(location)) && lastBlock != earliestBlock) {
   363                 if ((locationIdentity.isAny() || locationIdentity.equals(location)) && lastBlock != earliestBlock) {
   363                     // The begin of this block kills the location, so we *have* to schedule the node
   364                     // The begin of this block kills the location, so we *have* to schedule the node
   364                     // in the dominating block.
   365                     // in the dominating block.
   365                     lastBlock = lastBlock.getDominator();
   366                     lastBlock = lastBlock.getDominator();
   366                 }
   367                 }
   372         private static void fillKillSet(LocationSet killed, List<Node> subList) {
   373         private static void fillKillSet(LocationSet killed, List<Node> subList) {
   373             if (!killed.isAny()) {
   374             if (!killed.isAny()) {
   374                 for (Node n : subList) {
   375                 for (Node n : subList) {
   375                     // Check if this node kills a node in the watch list.
   376                     // Check if this node kills a node in the watch list.
   376                     if (n instanceof MemoryCheckpoint.Single) {
   377                     if (n instanceof MemoryCheckpoint.Single) {
   377                         LocationIdentity identity = ((MemoryCheckpoint.Single) n).getLocationIdentity();
   378                         LocationIdentity identity = ((MemoryCheckpoint.Single) n).getKilledLocationIdentity();
   378                         killed.add(identity);
   379                         killed.add(identity);
   379                         if (killed.isAny()) {
   380                         if (killed.isAny()) {
   380                             return;
   381                             return;
   381                         }
   382                         }
   382                     } else if (n instanceof MemoryCheckpoint.Multi) {
   383                     } else if (n instanceof MemoryCheckpoint.Multi) {
   383                         for (LocationIdentity identity : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) {
   384                         for (LocationIdentity identity : ((MemoryCheckpoint.Multi) n).getKilledLocationIdentities()) {
   384                             killed.add(identity);
   385                             killed.add(identity);
   385                             if (killed.isAny()) {
   386                             if (killed.isAny()) {
   386                                 return;
   387                                 return;
   387                             }
   388                             }
   388                         }
   389                         }
   469 
   470 
   470         private static void checkWatchList(Block b, NodeMap<Block> nodeMap, NodeBitMap unprocessed, ArrayList<Node> result, ArrayList<FloatingReadNode> watchList, Node n) {
   471         private static void checkWatchList(Block b, NodeMap<Block> nodeMap, NodeBitMap unprocessed, ArrayList<Node> result, ArrayList<FloatingReadNode> watchList, Node n) {
   471             if (watchList != null && !watchList.isEmpty()) {
   472             if (watchList != null && !watchList.isEmpty()) {
   472                 // Check if this node kills a node in the watch list.
   473                 // Check if this node kills a node in the watch list.
   473                 if (n instanceof MemoryCheckpoint.Single) {
   474                 if (n instanceof MemoryCheckpoint.Single) {
   474                     LocationIdentity identity = ((MemoryCheckpoint.Single) n).getLocationIdentity();
   475                     LocationIdentity identity = ((MemoryCheckpoint.Single) n).getKilledLocationIdentity();
   475                     checkWatchList(watchList, identity, b, result, nodeMap, unprocessed);
   476                     checkWatchList(watchList, identity, b, result, nodeMap, unprocessed);
   476                 } else if (n instanceof MemoryCheckpoint.Multi) {
   477                 } else if (n instanceof MemoryCheckpoint.Multi) {
   477                     for (LocationIdentity identity : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) {
   478                     for (LocationIdentity identity : ((MemoryCheckpoint.Multi) n).getKilledLocationIdentities()) {
   478                         checkWatchList(watchList, identity, b, result, nodeMap, unprocessed);
   479                         checkWatchList(watchList, identity, b, result, nodeMap, unprocessed);
   479                     }
   480                     }
   480                 }
   481                 }
   481             }
   482             }
   482         }
   483         }
   894                         next = next.getNext();
   895                         next = next.getNext();
   895                     }
   896                     }
   896                 }
   897                 }
   897             }
   898             }
   898 
   899 
   899             assert (!Assertions.detailedAssertionsEnabled(cfg.graph.getOptions())) || MemoryScheduleVerification.check(cfg.getStartBlock(), blockToNodes);
   900             assert (!Assertions.detailedAssertionsEnabled(cfg.graph.getOptions())) || ScheduleVerification.check(cfg.getStartBlock(), blockToNodes, nodeToBlock);
   900         }
   901         }
   901 
   902 
   902         private static void processNodes(NodeBitMap visited, NodeMap<MicroBlock> entries, NodeStack stack, MicroBlock startBlock, Iterable<? extends Node> nodes) {
   903         private static void processNodes(NodeBitMap visited, NodeMap<MicroBlock> entries, NodeStack stack, MicroBlock startBlock, Iterable<? extends Node> nodes) {
   903             for (Node node : nodes) {
   904             for (Node node : nodes) {
   904                 if (entries.get(node) == null) {
   905                 if (entries.get(node) == null) {
  1181 
  1182 
  1182         private static void printNode(Node n) {
  1183         private static void printNode(Node n) {
  1183             Formatter buf = new Formatter();
  1184             Formatter buf = new Formatter();
  1184             buf.format("%s", n);
  1185             buf.format("%s", n);
  1185             if (n instanceof MemoryCheckpoint.Single) {
  1186             if (n instanceof MemoryCheckpoint.Single) {
  1186                 buf.format(" // kills %s", ((MemoryCheckpoint.Single) n).getLocationIdentity());
  1187                 buf.format(" // kills %s", ((MemoryCheckpoint.Single) n).getKilledLocationIdentity());
  1187             } else if (n instanceof MemoryCheckpoint.Multi) {
  1188             } else if (n instanceof MemoryCheckpoint.Multi) {
  1188                 buf.format(" // kills ");
  1189                 buf.format(" // kills ");
  1189                 for (LocationIdentity locid : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) {
  1190                 for (LocationIdentity locid : ((MemoryCheckpoint.Multi) n).getKilledLocationIdentities()) {
  1190                     buf.format("%s, ", locid);
  1191                     buf.format("%s, ", locid);
  1191                 }
  1192                 }
  1192             } else if (n instanceof FloatingReadNode) {
  1193             } else if (n instanceof FloatingReadNode) {
  1193                 FloatingReadNode frn = (FloatingReadNode) n;
  1194                 FloatingReadNode frn = (FloatingReadNode) n;
  1194                 buf.format(" // from %s", frn.getLocationIdentity());
  1195                 buf.format(" // from %s", frn.getLocationIdentity());