115 */
116 public MergeNode loopExplosionHead;
117
118 protected MethodScope(LoopScope callerLoopScope, StructuredGraph graph, EncodedGraph encodedGraph, LoopExplosionKind loopExplosion) {
119 this.callerLoopScope = callerLoopScope;
120 this.methodStartMark = graph.getMark();
121 this.encodedGraph = encodedGraph;
122 this.loopExplosion = loopExplosion;
123 this.returnAndUnwindNodes = new ArrayList<>(2);
124
125 if (encodedGraph != null) {
126 reader = UnsafeArrayTypeReader.create(encodedGraph.getEncoding(), encodedGraph.getStartOffset(), architecture.supportsUnalignedMemoryAccess());
127 maxFixedNodeOrderId = reader.getUVInt();
128 if (encodedGraph.nodeStartOffsets == null) {
129 int nodeCount = reader.getUVInt();
130 int[] nodeStartOffsets = new int[nodeCount];
131 for (int i = 0; i < nodeCount; i++) {
132 nodeStartOffsets[i] = encodedGraph.getStartOffset() - reader.getUVInt();
133 }
134 encodedGraph.nodeStartOffsets = nodeStartOffsets;
135 }
136 } else {
137 reader = null;
138 maxFixedNodeOrderId = 0;
139 }
140
141 if (loopExplosion != LoopExplosionKind.NONE) {
142 loopExplosionMerges = EconomicSet.create(Equivalence.IDENTITY);
143 } else {
144 loopExplosionMerges = null;
145 }
146 }
147
148 public boolean isInlinedMethod() {
149 return false;
150 }
151
152 public NodeSourcePosition getCallerBytecodePosition() {
153 return getCallerBytecodePosition(null);
154 }
1305 }
1306 return false;
1307 }
1308
1309 protected Node lookupNode(LoopScope loopScope, int nodeOrderId) {
1310 return loopScope.createdNodes[nodeOrderId];
1311 }
1312
1313 protected void registerNode(LoopScope loopScope, int nodeOrderId, Node node, boolean allowOverwrite, boolean allowNull) {
1314 assert node == null || node.isAlive();
1315 assert allowNull || node != null;
1316 assert allowOverwrite || lookupNode(loopScope, nodeOrderId) == null;
1317 loopScope.createdNodes[nodeOrderId] = node;
1318 }
1319
1320 protected int readOrderId(MethodScope methodScope) {
1321 return methodScope.reader.getUVInt();
1322 }
1323
1324 protected Object readObject(MethodScope methodScope) {
1325 return methodScope.encodedGraph.getObjects()[methodScope.reader.getUVInt()];
1326 }
1327
1328 /**
1329 * Removes unnecessary nodes from the graph after decoding.
1330 *
1331 * @param methodScope The current method.
1332 */
1333 protected void cleanupGraph(MethodScope methodScope) {
1334 assert verifyEdges();
1335 }
1336
1337 protected boolean verifyEdges() {
1338 for (Node node : graph.getNodes()) {
1339 assert node.isAlive();
1340 for (Node i : node.inputs()) {
1341 assert i.isAlive();
1342 assert i.usages().contains(node);
1343 }
1344 for (Node s : node.successors()) {
1345 assert s.isAlive();
|
115 */
116 public MergeNode loopExplosionHead;
117
118 protected MethodScope(LoopScope callerLoopScope, StructuredGraph graph, EncodedGraph encodedGraph, LoopExplosionKind loopExplosion) {
119 this.callerLoopScope = callerLoopScope;
120 this.methodStartMark = graph.getMark();
121 this.encodedGraph = encodedGraph;
122 this.loopExplosion = loopExplosion;
123 this.returnAndUnwindNodes = new ArrayList<>(2);
124
125 if (encodedGraph != null) {
126 reader = UnsafeArrayTypeReader.create(encodedGraph.getEncoding(), encodedGraph.getStartOffset(), architecture.supportsUnalignedMemoryAccess());
127 maxFixedNodeOrderId = reader.getUVInt();
128 if (encodedGraph.nodeStartOffsets == null) {
129 int nodeCount = reader.getUVInt();
130 int[] nodeStartOffsets = new int[nodeCount];
131 for (int i = 0; i < nodeCount; i++) {
132 nodeStartOffsets[i] = encodedGraph.getStartOffset() - reader.getUVInt();
133 }
134 encodedGraph.nodeStartOffsets = nodeStartOffsets;
135 graph.setGuardsStage((StructuredGraph.GuardsStage) readObject(this));
136 }
137 } else {
138 reader = null;
139 maxFixedNodeOrderId = 0;
140 }
141
142 if (loopExplosion != LoopExplosionKind.NONE) {
143 loopExplosionMerges = EconomicSet.create(Equivalence.IDENTITY);
144 } else {
145 loopExplosionMerges = null;
146 }
147 }
148
149 public boolean isInlinedMethod() {
150 return false;
151 }
152
153 public NodeSourcePosition getCallerBytecodePosition() {
154 return getCallerBytecodePosition(null);
155 }
1306 }
1307 return false;
1308 }
1309
1310 protected Node lookupNode(LoopScope loopScope, int nodeOrderId) {
1311 return loopScope.createdNodes[nodeOrderId];
1312 }
1313
1314 protected void registerNode(LoopScope loopScope, int nodeOrderId, Node node, boolean allowOverwrite, boolean allowNull) {
1315 assert node == null || node.isAlive();
1316 assert allowNull || node != null;
1317 assert allowOverwrite || lookupNode(loopScope, nodeOrderId) == null;
1318 loopScope.createdNodes[nodeOrderId] = node;
1319 }
1320
1321 protected int readOrderId(MethodScope methodScope) {
1322 return methodScope.reader.getUVInt();
1323 }
1324
1325 protected Object readObject(MethodScope methodScope) {
1326 return methodScope.encodedGraph.getObject(methodScope.reader.getUVInt());
1327 }
1328
1329 /**
1330 * Removes unnecessary nodes from the graph after decoding.
1331 *
1332 * @param methodScope The current method.
1333 */
1334 protected void cleanupGraph(MethodScope methodScope) {
1335 assert verifyEdges();
1336 }
1337
1338 protected boolean verifyEdges() {
1339 for (Node node : graph.getNodes()) {
1340 assert node.isAlive();
1341 for (Node i : node.inputs()) {
1342 assert i.isAlive();
1343 assert i.usages().contains(node);
1344 }
1345 for (Node s : node.successors()) {
1346 assert s.isAlive();
|