comparison graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GraphDecoder.java @ 21379:0042b1960e71

Bugfix: non-simplifying GraphDecoder must not cleanup graph
author Christian Wimmer <christian.wimmer@oracle.com>
date Thu, 14 May 2015 16:03:49 -0700
parents 3703ad7bf6b5
children 553445b73d99 93c50cefb9e8
comparison
equal deleted inserted replaced
21378:a847538be6e3 21379:0042b1960e71
30 import com.oracle.graal.api.meta.*; 30 import com.oracle.graal.api.meta.*;
31 import com.oracle.graal.compiler.common.*; 31 import com.oracle.graal.compiler.common.*;
32 import com.oracle.graal.compiler.common.util.*; 32 import com.oracle.graal.compiler.common.util.*;
33 import com.oracle.graal.debug.*; 33 import com.oracle.graal.debug.*;
34 import com.oracle.graal.graph.*; 34 import com.oracle.graal.graph.*;
35 import com.oracle.graal.nodes.util.*;
36 35
37 /** 36 /**
38 * Decoder for {@link EncodedGraph encoded graphs} produced by {@link GraphEncoder}. Support for 37 * Decoder for {@link EncodedGraph encoded graphs} produced by {@link GraphEncoder}. Support for
39 * loop explosion during decoding is built into this class, because it requires many interactions 38 * loop explosion during decoding is built into this class, because it requires many interactions
40 * with the decoding process. Subclasses can provide canonicalization and simplification of nodes 39 * with the decoding process. Subclasses can provide canonicalization and simplification of nodes
1152 for (LoopBeginNode innerInner : innerLoopsMap.get(inner)) { 1151 for (LoopBeginNode innerInner : innerLoopsMap.get(inner)) {
1153 addLoopExits(currentGraph, loopBegin, innerInner, innerLoopsMap, visited); 1152 addLoopExits(currentGraph, loopBegin, innerInner, innerLoopsMap, visited);
1154 } 1153 }
1155 } 1154 }
1156 1155
1156 /**
1157 * Removes unnecessary nodes from the graph after decoding.
1158 *
1159 * @param methodScope The current method.
1160 * @param start Marker for the begin of the current method in the graph.
1161 */
1157 protected void cleanupGraph(MethodScope methodScope, Graph.Mark start) { 1162 protected void cleanupGraph(MethodScope methodScope, Graph.Mark start) {
1158 assert verifyEdges(methodScope); 1163 assert verifyEdges(methodScope);
1159
1160 for (Node node : methodScope.graph.getNewNodes(start)) {
1161 if (node instanceof MergeNode) {
1162 MergeNode mergeNode = (MergeNode) node;
1163 if (mergeNode.forwardEndCount() == 1) {
1164 methodScope.graph.reduceTrivialMerge(mergeNode);
1165 }
1166 }
1167 }
1168
1169 for (Node node : methodScope.graph.getNewNodes(start)) {
1170 if (node instanceof BeginNode || node instanceof KillingBeginNode) {
1171 if (!(node.predecessor() instanceof ControlSplitNode) && node.hasNoUsages()) {
1172 GraphUtil.unlinkFixedNode((AbstractBeginNode) node);
1173 node.safeDelete();
1174 }
1175 }
1176 }
1177
1178 for (Node node : methodScope.graph.getNewNodes(start)) {
1179 if (!(node instanceof FixedNode) && node.hasNoUsages()) {
1180 GraphUtil.killCFG(node);
1181 }
1182 }
1183 } 1164 }
1184 1165
1185 protected boolean verifyEdges(MethodScope methodScope) { 1166 protected boolean verifyEdges(MethodScope methodScope) {
1186 for (Node node : methodScope.graph.getNodes()) { 1167 for (Node node : methodScope.graph.getNodes()) {
1187 assert node.isAlive(); 1168 assert node.isAlive();