comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2756:bfcdda4fdd73

Removed the direct connection between BlockBegin and BlockEnd.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Fri, 20 May 2011 14:51:45 +0200
parents 0d268cf66e24
children 152b98832b0e
comparison
equal deleted inserted replaced
2754:e91608c2daff 2756:bfcdda4fdd73
255 assert bci() == 0; 255 assert bci() == 0;
256 FrameState stateAfter = frameState.create(bci()); 256 FrameState stateAfter = frameState.create(bci());
257 Instruction target = createTargetAt(0, stateAfter); 257 Instruction target = createTargetAt(0, stateAfter);
258 Goto base = new Goto(target, stateAfter, graph); 258 Goto base = new Goto(target, stateAfter, graph);
259 appendWithBCI(base); 259 appendWithBCI(base);
260 ((BlockBegin) startBlock.firstInstruction).setEnd(base);
261 } 260 }
262 261
263 public void mergeOrClone(Block target, FrameStateAccess newState) { 262 public void mergeOrClone(Block target, FrameStateAccess newState) {
264 assert target.firstInstruction instanceof BlockBegin; 263 assert target.firstInstruction instanceof BlockBegin;
265 if (target.isLoopHeader) { 264 if (target.isLoopHeader) {
373 } else { 372 } else {
374 if (unwindBlock == null) { 373 if (unwindBlock == null) {
375 unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph); 374 unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph);
376 Unwind unwind = new Unwind(null, graph); 375 Unwind unwind = new Unwind(null, graph);
377 unwindBlock.appendNext(unwind); 376 unwindBlock.appendNext(unwind);
378 unwindBlock.setEnd(unwind);
379 } 377 }
380 successor = unwindBlock; 378 successor = unwindBlock;
381 } 379 }
382 380
383 for (; current >= 0; current--) { 381 for (; current >= 0; current--) {
401 if (handler.handler.catchType().isResolved()) { 399 if (handler.handler.catchType().isResolved()) {
402 Instruction entry = createTarget(handler.entryBlock(), null); 400 Instruction entry = createTarget(handler.entryBlock(), null);
403 ExceptionDispatch end = new ExceptionDispatch(null, entry, null, handler, null, graph); 401 ExceptionDispatch end = new ExceptionDispatch(null, entry, null, handler, null, graph);
404 end.setBlockSuccessor(0, successor); 402 end.setBlockSuccessor(0, successor);
405 dispatchEntry.appendNext(end); 403 dispatchEntry.appendNext(end);
406 dispatchEntry.setEnd(end);
407 } else { 404 } else {
408 Deoptimize deopt = new Deoptimize(graph); 405 Deoptimize deopt = new Deoptimize(graph);
409 dispatchEntry.appendNext(deopt); 406 dispatchEntry.appendNext(deopt);
410 Goto end = new Goto(successor, null, graph); 407 Goto end = new Goto(successor, null, graph);
411 deopt.appendNext(end); 408 deopt.appendNext(end);
412 dispatchEntry.setEnd(end);
413 } 409 }
414 410
415 newBlocks.add(dispatchEntry); 411 newBlocks.add(dispatchEntry);
416 successor = dispatchEntry; 412 successor = dispatchEntry;
417 } 413 }
424 ExceptionObject exception = new ExceptionObject(graph); 420 ExceptionObject exception = new ExceptionObject(graph);
425 entry.appendNext(exception); 421 entry.appendNext(exception);
426 FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); 422 FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception);
427 BlockEnd end = new Goto(successor, stateWithException, graph); 423 BlockEnd end = new Goto(successor, stateWithException, graph);
428 exception.appendNext(end); 424 exception.appendNext(end);
429 entry.setEnd(end);
430 425
431 if (x instanceof Invoke) { 426 if (x instanceof Invoke) {
432 ((Invoke) x).setExceptionEdge(entry); 427 ((Invoke) x).setExceptionEdge(entry);
433 } else { 428 } else {
434 ((Throw) x).setExceptionEdge(entry); 429 ((Throw) x).setExceptionEdge(entry);
1163 // exit the monitor 1158 // exit the monitor
1164 genMonitorExit(lock, Instruction.SYNCHRONIZATION_ENTRY_BCI); 1159 genMonitorExit(lock, Instruction.SYNCHRONIZATION_ENTRY_BCI);
1165 1160
1166 genThrow(bci); 1161 genThrow(bci);
1167 BlockEnd end = (BlockEnd) lastInstr; 1162 BlockEnd end = (BlockEnd) lastInstr;
1168 ((BlockBegin) syncHandler.firstInstruction).setEnd(end);
1169 end.setStateAfter(frameState.create(bci())); 1163 end.setStateAfter(frameState.create(bci()));
1170 1164
1171 frameState.initializeFrom(origState); 1165 frameState.initializeFrom(origState);
1172 origState.delete(); 1166 origState.delete();
1173 lastInstr = origLast; 1167 lastInstr = origLast;
1176 private void iterateAllBlocks() { 1170 private void iterateAllBlocks() {
1177 Block block; 1171 Block block;
1178 while ((block = removeFromWorkList()) != null) { 1172 while ((block = removeFromWorkList()) != null) {
1179 1173
1180 // remove blocks that have no predecessors by the time it their bytecodes are parsed 1174 // remove blocks that have no predecessors by the time it their bytecodes are parsed
1181 if (block.firstInstruction.predecessors().size() == 0) { 1175 Instruction firstInstruction = block.firstInstruction;
1176 if (firstInstruction.predecessors().size() == 0) {
1182 markVisited(block); 1177 markVisited(block);
1183 continue; 1178 continue;
1184 } 1179 }
1185 1180
1186 if (!isVisited(block)) { 1181 if (!isVisited(block)) {
1187 markVisited(block); 1182 markVisited(block);
1188 // now parse the block 1183 // now parse the block
1189 frameState.initializeFrom(((BlockBegin) block.firstInstruction).stateBefore()); 1184 frameState.initializeFrom(((BlockBegin) firstInstruction).stateBefore());
1190 lastInstr = block.firstInstruction; 1185 lastInstr = firstInstruction;
1191 assert block.firstInstruction.next() == null; 1186 assert firstInstruction.next() == null;
1192 1187
1193 iterateBytecodesForBlock(block); 1188 iterateBytecodesForBlock(block);
1194 } 1189 }
1195 } 1190 }
1196 } 1191 }
1244 // connect to begin and set state 1239 // connect to begin and set state
1245 // NOTE that inlining may have changed the block we are parsing 1240 // NOTE that inlining may have changed the block we are parsing
1246 assert end != null : "end should exist after iterating over bytecodes"; 1241 assert end != null : "end should exist after iterating over bytecodes";
1247 FrameState stateAtEnd = frameState.create(bci()); 1242 FrameState stateAtEnd = frameState.create(bci());
1248 end.setStateAfter(stateAtEnd); 1243 end.setStateAfter(stateAtEnd);
1249 if (block.firstInstruction instanceof BlockBegin) {
1250 ((BlockBegin) block.firstInstruction).setEnd(end);
1251 }
1252 return end; 1244 return end;
1253 } 1245 }
1254 1246
1255 private void traceState() { 1247 private void traceState() {
1256 if (C1XOptions.TraceBytecodeParserLevel >= TRACELEVEL_STATE && !TTY.isSuppressed()) { 1248 if (C1XOptions.TraceBytecodeParserLevel >= TRACELEVEL_STATE && !TTY.isSuppressed()) {