Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2712:a0dd2b907806
Removed implicit safepoints.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Thu, 19 May 2011 13:09:37 +0200 |
parents | 4272b7af2d17 |
children | 95e2aa413d95 |
comparison
equal
deleted
inserted
replaced
2708:4272b7af2d17 | 2712:a0dd2b907806 |
---|---|
244 } | 244 } |
245 | 245 |
246 private void finishStartBlock(BlockBegin startBlock, BlockBegin stdEntry) { | 246 private void finishStartBlock(BlockBegin startBlock, BlockBegin stdEntry) { |
247 assert curBlock == startBlock; | 247 assert curBlock == startBlock; |
248 FrameState stateAfter = frameState.create(bci()); | 248 FrameState stateAfter = frameState.create(bci()); |
249 Goto base = new Goto(stdEntry, stateAfter, false, graph); | 249 Goto base = new Goto(stdEntry, stateAfter, graph); |
250 appendWithoutOptimization(base, 0); | 250 appendWithoutOptimization(base, 0); |
251 startBlock.setEnd(base); | 251 startBlock.setEnd(base); |
252 assert stdEntry.stateBefore() == null; | 252 assert stdEntry.stateBefore() == null; |
253 stdEntry.mergeOrClone(stateAfter, method()); | 253 stdEntry.mergeOrClone(stateAfter, method()); |
254 } | 254 } |
312 successor = exceptionHandlers.get(current).entryBlock(); | 312 successor = exceptionHandlers.get(current).entryBlock(); |
313 current--; | 313 current--; |
314 } else { | 314 } else { |
315 if (unwindBlock == null) { | 315 if (unwindBlock == null) { |
316 unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph); | 316 unwindBlock = new BlockBegin(bci, ir.nextBlockNumber(), graph); |
317 Unwind unwind = new Unwind(null, false, graph); | 317 Unwind unwind = new Unwind(null, graph); |
318 unwindBlock.appendNext(unwind, bci); | 318 unwindBlock.appendNext(unwind, bci); |
319 unwindBlock.setEnd(unwind); | 319 unwindBlock.setEnd(unwind); |
320 } | 320 } |
321 successor = unwindBlock; | 321 successor = unwindBlock; |
322 } | 322 } |
337 if (newSucc != null) { | 337 if (newSucc != null) { |
338 successor = newSucc; | 338 successor = newSucc; |
339 } else { | 339 } else { |
340 BlockBegin dispatchEntry = new BlockBegin(handler.handlerBCI(), ir.nextBlockNumber(), graph); | 340 BlockBegin dispatchEntry = new BlockBegin(handler.handlerBCI(), ir.nextBlockNumber(), graph); |
341 if (handler.handler.catchType().isResolved()) { | 341 if (handler.handler.catchType().isResolved()) { |
342 ExceptionDispatch end = new ExceptionDispatch(null, handler.entryBlock(), null, handler, null, false, graph); | 342 ExceptionDispatch end = new ExceptionDispatch(null, handler.entryBlock(), null, handler, null, graph); |
343 end.setBlockSuccessor(0, successor); | 343 end.setBlockSuccessor(0, successor); |
344 dispatchEntry.appendNext(end, handler.handlerBCI()); | 344 dispatchEntry.appendNext(end, handler.handlerBCI()); |
345 dispatchEntry.setEnd(end); | 345 dispatchEntry.setEnd(end); |
346 } else { | 346 } else { |
347 Deoptimize deopt = new Deoptimize(graph, null); | 347 Deoptimize deopt = new Deoptimize(graph, null); |
348 dispatchEntry.appendNext(deopt, bci); | 348 dispatchEntry.appendNext(deopt, bci); |
349 Goto end = new Goto(successor, null, false, graph); | 349 Goto end = new Goto(successor, null, graph); |
350 deopt.appendNext(end, bci); | 350 deopt.appendNext(end, bci); |
351 dispatchEntry.setEnd(end); | 351 dispatchEntry.setEnd(end); |
352 } | 352 } |
353 newBlocks.add(dispatchEntry); | 353 newBlocks.add(dispatchEntry); |
354 successor = dispatchEntry; | 354 successor = dispatchEntry; |
360 BlockBegin entry = new BlockBegin(bci, ir.nextBlockNumber(), graph); | 360 BlockBegin entry = new BlockBegin(bci, ir.nextBlockNumber(), graph); |
361 entry.setStateBefore(entryState); | 361 entry.setStateBefore(entryState); |
362 ExceptionObject exception = new ExceptionObject(graph); | 362 ExceptionObject exception = new ExceptionObject(graph); |
363 entry.appendNext(exception, bci); | 363 entry.appendNext(exception, bci); |
364 FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); | 364 FrameState stateWithException = entryState.duplicateModified(bci, CiKind.Void, exception); |
365 BlockEnd end = new Goto(successor, stateWithException, false, graph); | 365 BlockEnd end = new Goto(successor, stateWithException, graph); |
366 exception.appendNext(end, bci); | 366 exception.appendNext(end, bci); |
367 entry.setEnd(end); | 367 entry.setEnd(end); |
368 | 368 |
369 if (x instanceof Invoke) { | 369 if (x instanceof Invoke) { |
370 ((Invoke) x).setExceptionEdge(entry); | 370 ((Invoke) x).setExceptionEdge(entry); |
603 Value y = append(Constant.forInt(delta, graph)); | 603 Value y = append(Constant.forInt(delta, graph)); |
604 frameState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), false, graph))); | 604 frameState.storeLocal(index, append(new ArithmeticOp(IADD, CiKind.Int, x, y, isStrict(method().accessFlags()), false, graph))); |
605 } | 605 } |
606 | 606 |
607 private void genGoto(int fromBCI, int toBCI) { | 607 private void genGoto(int fromBCI, int toBCI) { |
608 boolean isSafepoint = !noSafepoints() && toBCI <= fromBCI; | 608 append(new Goto(blockAt(toBCI), null, graph)); |
609 append(new Goto(blockAt(toBCI), null, isSafepoint, graph)); | |
610 } | 609 } |
611 | 610 |
612 private void ifNode(Value x, Condition cond, Value y, FrameState stateBefore) { | 611 private void ifNode(Value x, Condition cond, Value y, FrameState stateBefore) { |
613 BlockBegin tsucc = blockAt(stream().readBranchDest()); | 612 BlockBegin tsucc = blockAt(stream().readBranchDest()); |
614 BlockBegin fsucc = blockAt(stream().nextBCI()); | 613 BlockBegin fsucc = blockAt(stream().nextBCI()); |
615 int bci = stream().currentBCI(); | 614 int bci = stream().currentBCI(); |
616 boolean isSafepoint = !noSafepoints() && (tsucc.bci() <= bci || fsucc.bci() <= bci); | 615 boolean isSafepoint = !noSafepoints() && (tsucc.bci() <= bci || fsucc.bci() <= bci); |
617 if (isSafepoint) { | 616 if (isSafepoint) { |
618 append(new If(x, cond, y, tsucc, fsucc, stateBefore, isSafepoint, graph)); | 617 append(new If(x, cond, y, tsucc, fsucc, stateBefore, graph)); |
619 } else { | 618 } else { |
620 append(new If(x, cond, y, tsucc, fsucc, null, isSafepoint, graph)); | 619 append(new If(x, cond, y, tsucc, fsucc, null, graph)); |
621 stateBefore.delete(); | 620 stateBefore.delete(); |
622 } | 621 } |
623 } | 622 } |
624 | 623 |
625 private void genIfZero(Condition cond) { | 624 private void genIfZero(Condition cond) { |
643 ifNode(x, cond, y, stateBefore); | 642 ifNode(x, cond, y, stateBefore); |
644 } | 643 } |
645 | 644 |
646 private void genThrow(int bci) { | 645 private void genThrow(int bci) { |
647 FrameState stateBefore = frameState.create(bci); | 646 FrameState stateBefore = frameState.create(bci); |
648 Throw t = new Throw(frameState.apop(), !noSafepoints(), graph); | 647 Throw t = new Throw(frameState.apop(), graph); |
649 t.setStateBefore(stateBefore); | 648 t.setStateBefore(stateBefore); |
650 appendWithoutOptimization(t, bci); | 649 appendWithoutOptimization(t, bci); |
651 } | 650 } |
652 | 651 |
653 private void genCheckCast() { | 652 private void genCheckCast() { |
952 append(lockAddress); | 951 append(lockAddress); |
953 } | 952 } |
954 append(new MonitorExit(rootMethodSynchronizedObject, lockAddress, lockNumber, graph)); | 953 append(new MonitorExit(rootMethodSynchronizedObject, lockAddress, lockNumber, graph)); |
955 frameState.unlock(); | 954 frameState.unlock(); |
956 } | 955 } |
957 append(new Return(x, !noSafepoints(), graph)); | 956 append(new Return(x, graph)); |
958 } | 957 } |
959 | 958 |
960 private void genMonitorEnter(Value x, int bci) { | 959 private void genMonitorEnter(Value x, int bci) { |
961 int lockNumber = frameState.locksSize(); | 960 int lockNumber = frameState.locksSize(); |
962 MonitorAddress lockAddress = null; | 961 MonitorAddress lockAddress = null; |
1009 int offset = ts.defaultOffset(); | 1008 int offset = ts.defaultOffset(); |
1010 isBackwards |= offset < 0; // if the default successor is backwards | 1009 isBackwards |= offset < 0; // if the default successor is backwards |
1011 list.add(blockAt(bci + offset)); | 1010 list.add(blockAt(bci + offset)); |
1012 boolean isSafepoint = isBackwards && !noSafepoints(); | 1011 boolean isSafepoint = isBackwards && !noSafepoints(); |
1013 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; | 1012 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; |
1014 append(new TableSwitch(frameState.ipop(), list, ts.lowKey(), stateBefore, isSafepoint, graph)); | 1013 append(new TableSwitch(frameState.ipop(), list, ts.lowKey(), stateBefore, graph)); |
1015 } | 1014 } |
1016 | 1015 |
1017 private void genLookupswitch() { | 1016 private void genLookupswitch() { |
1018 int bci = bci(); | 1017 int bci = bci(); |
1019 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); | 1018 BytecodeLookupSwitch ls = new BytecodeLookupSwitch(stream(), bci); |
1031 int offset = ls.defaultOffset(); | 1030 int offset = ls.defaultOffset(); |
1032 isBackwards |= offset < 0; // if the default successor is backwards | 1031 isBackwards |= offset < 0; // if the default successor is backwards |
1033 list.add(blockAt(bci + offset)); | 1032 list.add(blockAt(bci + offset)); |
1034 boolean isSafepoint = isBackwards && !noSafepoints(); | 1033 boolean isSafepoint = isBackwards && !noSafepoints(); |
1035 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; | 1034 FrameState stateBefore = isSafepoint ? frameState.create(bci()) : null; |
1036 append(new LookupSwitch(frameState.ipop(), list, keys, stateBefore, isSafepoint, graph)); | 1035 append(new LookupSwitch(frameState.ipop(), list, keys, stateBefore, graph)); |
1037 } | 1036 } |
1038 | 1037 |
1039 private Value appendConstant(CiConstant type) { | 1038 private Value appendConstant(CiConstant type) { |
1040 return appendWithBCI(new Constant(type, graph), bci()); | 1039 return appendWithBCI(new Constant(type, graph), bci()); |
1041 } | 1040 } |
1161 | 1160 |
1162 while (bci < endBCI) { | 1161 while (bci < endBCI) { |
1163 BlockBegin nextBlock = blockAtOrNull(bci); | 1162 BlockBegin nextBlock = blockAtOrNull(bci); |
1164 if (nextBlock != null && nextBlock != block) { | 1163 if (nextBlock != null && nextBlock != block) { |
1165 // we fell through to the next block, add a goto and break | 1164 // we fell through to the next block, add a goto and break |
1166 end = new Goto(nextBlock, null, false, graph); | 1165 end = new Goto(nextBlock, null, graph); |
1167 lastInstr = lastInstr.appendNext(end, prevBCI); | 1166 lastInstr = lastInstr.appendNext(end, prevBCI); |
1168 break; | 1167 break; |
1169 } | 1168 } |
1170 // read the opcode | 1169 // read the opcode |
1171 int opcode = stream.currentBC(); | 1170 int opcode = stream.currentBC(); |