comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GraphDecoder.java @ 21502:553445b73d99

Bugfix for Graph Decoder: ensure that guard dependencies to block begins are correctly re-wired during decoding
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 26 May 2015 16:19:16 -0700
parents 0042b1960e71
children 28cbfacd0518 31fc2fce38f3
comparison
equal deleted inserted replaced
21501:ce585b0ac3e2 21502:553445b73d99
269 protected final void decode(MethodScope methodScope, FixedWithNextNode startNode) { 269 protected final void decode(MethodScope methodScope, FixedWithNextNode startNode) {
270 Graph.Mark start = methodScope.graph.getMark(); 270 Graph.Mark start = methodScope.graph.getMark();
271 LoopScope loopScope = new LoopScope(methodScope); 271 LoopScope loopScope = new LoopScope(methodScope);
272 FixedNode firstNode; 272 FixedNode firstNode;
273 if (startNode != null) { 273 if (startNode != null) {
274 /*
275 * The start node of a graph can be referenced as the guard for a GuardedNode. We
276 * register the previous block node, so that such guards are correctly anchored when
277 * doing inlining during graph decoding.
278 */
279 registerNode(loopScope, GraphEncoder.START_NODE_ORDER_ID, AbstractBeginNode.prevBegin(startNode), false, false);
280
274 firstNode = makeStubNode(methodScope, loopScope, GraphEncoder.FIRST_NODE_ORDER_ID); 281 firstNode = makeStubNode(methodScope, loopScope, GraphEncoder.FIRST_NODE_ORDER_ID);
275 startNode.setNext(firstNode); 282 startNode.setNext(firstNode);
276 loopScope.nodesToProcess.set(GraphEncoder.FIRST_NODE_ORDER_ID); 283 loopScope.nodesToProcess.set(GraphEncoder.FIRST_NODE_ORDER_ID);
277 } else { 284 } else {
278 firstNode = methodScope.graph.start(); 285 firstNode = methodScope.graph.start();
330 337
331 if ((node instanceof MergeNode || (node instanceof LoopBeginNode && (methodScope.loopExplosion == LoopExplosionKind.FULL_UNROLL || methodScope.loopExplosion == LoopExplosionKind.FULL_EXPLODE))) && 338 if ((node instanceof MergeNode || (node instanceof LoopBeginNode && (methodScope.loopExplosion == LoopExplosionKind.FULL_UNROLL || methodScope.loopExplosion == LoopExplosionKind.FULL_EXPLODE))) &&
332 ((AbstractMergeNode) node).forwardEndCount() == 1) { 339 ((AbstractMergeNode) node).forwardEndCount() == 1) {
333 AbstractMergeNode merge = (AbstractMergeNode) node; 340 AbstractMergeNode merge = (AbstractMergeNode) node;
334 EndNode singleEnd = merge.forwardEndAt(0); 341 EndNode singleEnd = merge.forwardEndAt(0);
342
343 /* Nodes that would use this merge as the guard need to use the previous block. */
344 registerNode(loopScope, nodeOrderId, AbstractBeginNode.prevBegin(singleEnd), true, false);
345
335 FixedNode next = makeStubNode(methodScope, loopScope, nodeOrderId + GraphEncoder.BEGIN_NEXT_ORDER_ID_OFFSET); 346 FixedNode next = makeStubNode(methodScope, loopScope, nodeOrderId + GraphEncoder.BEGIN_NEXT_ORDER_ID_OFFSET);
336 singleEnd.replaceAtPredecessor(next); 347 singleEnd.replaceAtPredecessor(next);
337 348
338 merge.safeDelete(); 349 merge.safeDelete();
339 singleEnd.safeDelete(); 350 singleEnd.safeDelete();
820 * Decodes a non-fixed node, but does not do any post-processing and does not register it. 831 * Decodes a non-fixed node, but does not do any post-processing and does not register it.
821 */ 832 */
822 protected Node decodeFloatingNode(MethodScope methodScope, LoopScope loopScope, int nodeOrderId) { 833 protected Node decodeFloatingNode(MethodScope methodScope, LoopScope loopScope, int nodeOrderId) {
823 long readerByteIndex = methodScope.reader.getByteIndex(); 834 long readerByteIndex = methodScope.reader.getByteIndex();
824 Node node = instantiateNode(methodScope, nodeOrderId); 835 Node node = instantiateNode(methodScope, nodeOrderId);
825 assert !(node instanceof FixedNode); 836 if (node instanceof FixedNode) {
837 /*
838 * This is a severe error that will lead to a corrupted graph, so it is better not to
839 * continue decoding at all.
840 */
841 throw shouldNotReachHere("Not a floating node: " + node.getClass().getName());
842 }
826 843
827 /* Read the properties of the node. */ 844 /* Read the properties of the node. */
828 readProperties(methodScope, node); 845 readProperties(methodScope, node);
829 /* There must not be any successors to read, since it is a non-fixed node. */ 846 /* There must not be any successors to read, since it is a non-fixed node. */
830 assert node.getNodeClass().getEdges(Edges.Type.Successors).getCount() == 0; 847 assert node.getNodeClass().getEdges(Edges.Type.Successors).getCount() == 0;