< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/BinaryGraphPrinter.java

Print this page
rev 52509 : [mq]: graal2


 212 
 213     @Override
 214     public List<Block> blockSuccessors(Block block) {
 215         return Arrays.asList(block.getSuccessors());
 216     }
 217 
 218     @Override
 219     public Iterable<Node> nodes(GraphInfo info) {
 220         return info.graph.getNodes();
 221     }
 222 
 223     @Override
 224     public int nodesCount(GraphInfo info) {
 225         return info.graph.getNodeCount();
 226     }
 227 
 228     @Override
 229     @SuppressWarnings({"unchecked", "rawtypes"})
 230     public void nodeProperties(GraphInfo info, Node node, Map<String, Object> props) {
 231         node.getDebugProperties((Map) props);
 232         Graph graph = info.graph;
 233         ControlFlowGraph cfg = info.cfg;
 234         NodeMap<Block> nodeToBlocks = info.nodeToBlocks;
 235         if (cfg != null && DebugOptions.PrintGraphProbabilities.getValue(graph.getOptions()) && node instanceof FixedNode) {
 236             try {
 237                 props.put("probability", cfg.blockFor(node).probability());
 238             } catch (Throwable t) {
 239                 props.put("probability", 0.0);
 240                 props.put("probability-exception", t);
 241             }
 242         }
 243 
 244         try {
 245             props.put("NodeCost-Size", node.estimatedNodeSize());
 246             props.put("NodeCost-Cycles", node.estimatedNodeCycles());
 247         } catch (Throwable t) {
 248             props.put("node-cost-exception", t.getMessage());
 249         }
 250 
 251         if (nodeToBlocks != null) {
 252             Object block = getBlockForNode(node, nodeToBlocks);
 253             if (block != null) {
 254                 props.put("node-to-block", block);
 255             }
 256         }
 257 
 258         if (node instanceof ControlSinkNode) {
 259             props.put("category", "controlSink");
 260         } else if (node instanceof ControlSplitNode) {
 261             props.put("category", "controlSplit");
 262         } else if (node instanceof AbstractMergeNode) {
 263             props.put("category", "merge");
 264         } else if (node instanceof AbstractBeginNode) {
 265             props.put("category", "begin");
 266         } else if (node instanceof AbstractEndNode) {
 267             props.put("category", "end");
 268         } else if (node instanceof FixedNode) {
 269             props.put("category", "fixed");
 270         } else if (node instanceof VirtualState) {
 271             props.put("category", "state");
 272         } else if (node instanceof PhiNode) {
 273             props.put("category", "phi");
 274         } else if (node instanceof ProxyNode) {
 275             props.put("category", "proxy");
 276         } else {
 277             if (node instanceof ConstantNode) {
 278                 ConstantNode cn = (ConstantNode) node;
 279                 updateStringPropertiesForConstant((Map) props, cn);
 280             }
 281             props.put("category", "floating");
 282         }
 283         if (getSnippetReflectionProvider() != null) {
 284             for (Map.Entry<String, Object> prop : props.entrySet()) {
 285                 if (prop.getValue() instanceof JavaConstantFormattable) {
 286                     props.put(prop.getKey(), ((JavaConstantFormattable) prop.getValue()).format(this));
 287                 }
 288             }
 289         }
 290     }
 291 
 292     private Object getBlockForNode(Node node, NodeMap<Block> nodeToBlocks) {
 293         if (nodeToBlocks.isNew(node)) {
 294             return "NEW (not in schedule)";
 295         } else {
 296             Block block = nodeToBlocks.get(node);
 297             if (block != null) {
 298                 return block.getId();
 299             } else if (node instanceof PhiNode) {
 300                 return getBlockForNode(((PhiNode) node).merge(), nodeToBlocks);
 301             }
 302         }
 303         return null;
 304     }
 305 
 306     private static void findExtraNodes(Node node, Collection<? super Node> extraNodes) {
 307         if (node instanceof AbstractMergeNode) {
 308             AbstractMergeNode merge = (AbstractMergeNode) node;
 309             for (PhiNode phi : merge.phis()) {
 310                 extraNodes.add(phi);
 311             }
 312         }
 313     }
 314 
 315     @Override
 316     public boolean nodeHasPredecessor(Node node) {
 317         return node.predecessor() != null;
 318     }




 212 
 213     @Override
 214     public List<Block> blockSuccessors(Block block) {
 215         return Arrays.asList(block.getSuccessors());
 216     }
 217 
 218     @Override
 219     public Iterable<Node> nodes(GraphInfo info) {
 220         return info.graph.getNodes();
 221     }
 222 
 223     @Override
 224     public int nodesCount(GraphInfo info) {
 225         return info.graph.getNodeCount();
 226     }
 227 
 228     @Override
 229     @SuppressWarnings({"unchecked", "rawtypes"})
 230     public void nodeProperties(GraphInfo info, Node node, Map<String, Object> props) {
 231         node.getDebugProperties((Map) props);


 232         NodeMap<Block> nodeToBlocks = info.nodeToBlocks;
 233 
 234         if (nodeToBlocks != null) {
 235             Block block = getBlockForNode(node, nodeToBlocks);
 236             if (block != null) {
 237                 props.put("relativeFrequency", block.getRelativeFrequency());
 238                 props.put("nodeToBlock", block);
 239             }
 240         }
 241 
 242         props.put("nodeCostSize", node.estimatedNodeSize());
 243         props.put("nodeCostCycles", node.estimatedNodeCycles());




 244 
 245         if (nodeToBlocks != null) {
 246             Object block = getBlockForNode(node, nodeToBlocks);
 247             if (block != null) {
 248                 props.put("nodeToBlock", block);
 249             }
 250         }
 251 
 252         if (node instanceof ControlSinkNode) {
 253             props.put("category", "controlSink");
 254         } else if (node instanceof ControlSplitNode) {
 255             props.put("category", "controlSplit");
 256         } else if (node instanceof AbstractMergeNode) {
 257             props.put("category", "merge");
 258         } else if (node instanceof AbstractBeginNode) {
 259             props.put("category", "begin");
 260         } else if (node instanceof AbstractEndNode) {
 261             props.put("category", "end");
 262         } else if (node instanceof FixedNode) {
 263             props.put("category", "fixed");
 264         } else if (node instanceof VirtualState) {
 265             props.put("category", "state");
 266         } else if (node instanceof PhiNode) {
 267             props.put("category", "phi");
 268         } else if (node instanceof ProxyNode) {
 269             props.put("category", "proxy");
 270         } else {
 271             if (node instanceof ConstantNode) {
 272                 ConstantNode cn = (ConstantNode) node;
 273                 updateStringPropertiesForConstant((Map) props, cn);
 274             }
 275             props.put("category", "floating");
 276         }
 277         if (getSnippetReflectionProvider() != null) {
 278             for (Map.Entry<String, Object> prop : props.entrySet()) {
 279                 if (prop.getValue() instanceof JavaConstantFormattable) {
 280                     props.put(prop.getKey(), ((JavaConstantFormattable) prop.getValue()).format(this));
 281                 }
 282             }
 283         }
 284     }
 285 
 286     private Block getBlockForNode(Node node, NodeMap<Block> nodeToBlocks) {
 287         if (nodeToBlocks.isNew(node)) {
 288             return null;
 289         } else {
 290             Block block = nodeToBlocks.get(node);
 291             if (block != null) {
 292                 return block;
 293             } else if (node instanceof PhiNode) {
 294                 return getBlockForNode(((PhiNode) node).merge(), nodeToBlocks);
 295             }
 296         }
 297         return null;
 298     }
 299 
 300     private static void findExtraNodes(Node node, Collection<? super Node> extraNodes) {
 301         if (node instanceof AbstractMergeNode) {
 302             AbstractMergeNode merge = (AbstractMergeNode) node;
 303             for (PhiNode phi : merge.phis()) {
 304                 extraNodes.add(phi);
 305             }
 306         }
 307     }
 308 
 309     @Override
 310     public boolean nodeHasPredecessor(Node node) {
 311         return node.predecessor() != null;
 312     }


< prev index next >