comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2565:cc1f1d396288

Remove inlining (3rd part)
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Fri, 29 Apr 2011 16:46:30 +0200
parents 274360f98f97
children d524ad648049
comparison
equal deleted inserted replaced
2564:274360f98f97 2565:cc1f1d396288
118 // 2. compute the block map and get the entrypoint(s) 118 // 2. compute the block map and get the entrypoint(s)
119 BlockMap blockMap = compilation.getBlockMap(rootMethod); 119 BlockMap blockMap = compilation.getBlockMap(rootMethod);
120 BlockBegin stdEntry = blockMap.get(0); 120 BlockBegin stdEntry = blockMap.get(0);
121 pushRootScope(rootMethod, blockMap, startBlock); 121 pushRootScope(rootMethod, blockMap, startBlock);
122 MutableFrameState initialState = stateAtEntry(rootMethod); 122 MutableFrameState initialState = stateAtEntry(rootMethod);
123 startBlock.mergeOrClone(initialState); 123 startBlock.mergeOrClone(initialState, rootMethod);
124 BlockBegin syncHandler = null; 124 BlockBegin syncHandler = null;
125 125
126 // 3. setup internal state for appending instructions 126 // 3. setup internal state for appending instructions
127 curBlock = startBlock; 127 curBlock = startBlock;
128 lastInstr = startBlock; 128 lastInstr = startBlock;
168 appendWithoutOptimization(base, 0); 168 appendWithoutOptimization(base, 0);
169 FrameState stateAfter = curState.immutableCopy(bci()); 169 FrameState stateAfter = curState.immutableCopy(bci());
170 base.setStateAfter(stateAfter); 170 base.setStateAfter(stateAfter);
171 startBlock.setEnd(base); 171 startBlock.setEnd(base);
172 assert stdEntry.stateBefore() == null; 172 assert stdEntry.stateBefore() == null;
173 stdEntry.mergeOrClone(stateAfter); 173 stdEntry.mergeOrClone(stateAfter, method());
174 } 174 }
175 175
176 void pushRootScope(RiMethod method, BlockMap blockMap, BlockBegin start) { 176 void pushRootScope(RiMethod method, BlockMap blockMap, BlockBegin start) {
177 BytecodeStream stream = new BytecodeStream(method.code()); 177 BytecodeStream stream = new BytecodeStream(method.code());
178 RiConstantPool constantPool = compilation.runtime.getConstantPool(method); 178 RiConstantPool constantPool = compilation.runtime.getConstantPool(method);
376 assert entryState == null || curState.locksSize() == entryState.locksSize() : "locks do not match"; 376 assert entryState == null || curState.locksSize() == entryState.locksSize() : "locks do not match";
377 377
378 // exception handler starts with an empty expression stack 378 // exception handler starts with an empty expression stack
379 curState = curState.immutableCopyWithEmptyStack(); 379 curState = curState.immutableCopyWithEmptyStack();
380 380
381 entry.mergeOrClone(curState); 381 entry.mergeOrClone(curState, method());
382 382
383 // add current state for correct handling of phi functions 383 // add current state for correct handling of phi functions
384 int phiOperand = entry.addExceptionState(curState); 384 int phiOperand = entry.addExceptionState(curState);
385 385
386 // add entry to the list of exception handlers of this block 386 // add entry to the list of exception handlers of this block
1047 1047
1048 curState.truncateStack(0); 1048 curState.truncateStack(0);
1049 if (Modifier.isSynchronized(method().accessFlags())) { 1049 if (Modifier.isSynchronized(method().accessFlags())) {
1050 FrameState stateBefore = curState.immutableCopy(bci()); 1050 FrameState stateBefore = curState.immutableCopy(bci());
1051 // unlock before exiting the method 1051 // unlock before exiting the method
1052 int lockNumber = curState.totalLocksSize() - 1; 1052 int lockNumber = curState.locksSize() - 1;
1053 MonitorAddress lockAddress = null; 1053 MonitorAddress lockAddress = null;
1054 if (compilation.runtime.sizeOfBasicObjectLock() != 0) { 1054 if (compilation.runtime.sizeOfBasicObjectLock() != 0) {
1055 lockAddress = new MonitorAddress(lockNumber); 1055 lockAddress = new MonitorAddress(lockNumber);
1056 append(lockAddress); 1056 append(lockAddress);
1057 } 1057 }
1081 monitorEnter.setStateAfter(curState.immutableCopy(bci)); 1081 monitorEnter.setStateAfter(curState.immutableCopy(bci));
1082 killMemoryMap(); // prevent any optimizations across synchronization 1082 killMemoryMap(); // prevent any optimizations across synchronization
1083 } 1083 }
1084 1084
1085 void genMonitorExit(Value x, int bci) { 1085 void genMonitorExit(Value x, int bci) {
1086 int lockNumber = curState.totalLocksSize() - 1; 1086 int lockNumber = curState.locksSize() - 1;
1087 if (lockNumber < 0) { 1087 if (lockNumber < 0) {
1088 throw new CiBailout("monitor stack underflow"); 1088 throw new CiBailout("monitor stack underflow");
1089 } 1089 }
1090 MonitorAddress lockAddress = null; 1090 MonitorAddress lockAddress = null;
1091 if (compilation.runtime.sizeOfBasicObjectLock() != 0) { 1091 if (compilation.runtime.sizeOfBasicObjectLock() != 0) {
1102 if (cur.jsrEntryBCI() == dest) { 1102 if (cur.jsrEntryBCI() == dest) {
1103 // the jsr/ret pattern includes a recursive invocation 1103 // the jsr/ret pattern includes a recursive invocation
1104 throw new CiBailout("recursive jsr/ret structure"); 1104 throw new CiBailout("recursive jsr/ret structure");
1105 } 1105 }
1106 } 1106 }
1107 System.err.println("> JSR!");
1107 push(CiKind.Jsr, append(Constant.forJsr(nextBCI()))); 1108 push(CiKind.Jsr, append(Constant.forJsr(nextBCI())));
1108 tryInlineJsr(dest); 1109 tryInlineJsr(dest);
1109 } 1110 }
1110 1111
1111 void genRet(int localIndex) { 1112 void genRet(int localIndex) {
1314 data.setJsrContinuation(jsrCont); 1315 data.setJsrContinuation(jsrCont);
1315 scopeData = data; 1316 scopeData = data;
1316 } 1317 }
1317 1318
1318 MutableFrameState stateAtEntry(RiMethod method) { 1319 MutableFrameState stateAtEntry(RiMethod method) {
1319 MutableFrameState state = new MutableFrameState(method, -1, method.maxLocals(), method.maxStackSize()); 1320 MutableFrameState state = new MutableFrameState(-1, method.maxLocals(), method.maxStackSize());
1320 int index = 0; 1321 int index = 0;
1321 if (!isStatic(method.accessFlags())) { 1322 if (!isStatic(method.accessFlags())) {
1322 // add the receiver and assume it is non null 1323 // add the receiver and assume it is non null
1323 Local local = new Local(method.holder().kind(), index); 1324 Local local = new Local(method.holder().kind(), index);
1324 local.setFlag(Value.Flag.NonNull, true); 1325 local.setFlag(Value.Flag.NonNull, true);
1480 end.setStateAfter(curState.immutableCopy(bci())); 1481 end.setStateAfter(curState.immutableCopy(bci()));
1481 curBlock.setEnd(end); 1482 curBlock.setEnd(end);
1482 // propagate the state 1483 // propagate the state
1483 for (BlockBegin succ : end.successors()) { 1484 for (BlockBegin succ : end.successors()) {
1484 assert succ.predecessors().contains(curBlock); 1485 assert succ.predecessors().contains(curBlock);
1485 succ.mergeOrClone(end.stateAfter()); 1486 succ.mergeOrClone(end.stateAfter(), method());
1486 scopeData.addToWorkList(succ); 1487 scopeData.addToWorkList(succ);
1487 } 1488 }
1488 return end; 1489 return end;
1489 } 1490 }
1490 1491