Mercurial > hg > truffle
comparison graal/GraalCompiler/src/com/sun/c1x/graph/GraphBuilder.java @ 2695:785e9ecdcc69
Removed the instruction substitutor.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 18 May 2011 15:03:45 +0200 |
parents | ed36daed4c43 |
children | d06cff53b77e |
comparison
equal
deleted
inserted
replaced
2694:773189811d10 | 2695:785e9ecdcc69 |
---|---|
145 | 145 |
146 if (rootMethod.noSafepoints()) { | 146 if (rootMethod.noSafepoints()) { |
147 flags |= Flag.NoSafepoints.mask; | 147 flags |= Flag.NoSafepoints.mask; |
148 } | 148 } |
149 | 149 |
150 // 1. create the start block | |
151 ir.startBlock = new BlockBegin(0, ir.nextBlockNumber(), graph); | |
152 BlockBegin startBlock = ir.startBlock; | |
153 graph.root().setStart(startBlock); | |
154 | |
155 // 2. compute the block map, setup exception handlers and get the entrypoint(s) | 150 // 2. compute the block map, setup exception handlers and get the entrypoint(s) |
156 BlockMap blockMap = compilation.getBlockMap(rootMethod); | 151 BlockMap blockMap = compilation.getBlockMap(rootMethod); |
157 | 152 |
158 blockList = new BlockBegin[rootMethod.code().length]; | 153 blockList = new BlockBegin[rootMethod.code().length]; |
159 for (int i = 0; i < blockMap.blocks.size(); i++) { | 154 for (int i = 0; i < blockMap.blocks.size(); i++) { |
167 } | 162 } |
168 blockBegin.setDepthFirstNumber(blockBegin.blockID); | 163 blockBegin.setDepthFirstNumber(blockBegin.blockID); |
169 blockList[block.startBci] = blockBegin; | 164 blockList[block.startBci] = blockBegin; |
170 } | 165 } |
171 | 166 |
172 BlockBegin stdEntry = blockList[0]; | 167 |
168 // 1. create the start block | |
169 ir.startBlock = new BlockBegin(0, ir.nextBlockNumber(), graph); | |
170 BlockBegin startBlock = ir.startBlock; | |
171 graph.root().setStart(startBlock); | |
173 curBlock = startBlock; | 172 curBlock = startBlock; |
174 | 173 |
175 RiExceptionHandler[] handlers = rootMethod.exceptionHandlers(); | 174 RiExceptionHandler[] handlers = rootMethod.exceptionHandlers(); |
176 if (handlers != null && handlers.length > 0) { | 175 if (handlers != null && handlers.length > 0) { |
177 exceptionHandlers = new ArrayList<ExceptionHandler>(handlers.length); | 176 exceptionHandlers = new ArrayList<ExceptionHandler>(handlers.length); |
193 // 3. setup internal state for appending instructions | 192 // 3. setup internal state for appending instructions |
194 curBlock = startBlock; | 193 curBlock = startBlock; |
195 lastInstr = startBlock; | 194 lastInstr = startBlock; |
196 lastInstr.appendNext(null, -1); | 195 lastInstr.appendNext(null, -1); |
197 | 196 |
197 BlockBegin entryBlock = blockList[0]; | |
198 if (isSynchronized(rootMethod.accessFlags())) { | 198 if (isSynchronized(rootMethod.accessFlags())) { |
199 // 4A.1 add a monitor enter to the start block | 199 // 4A.1 add a monitor enter to the start block |
200 rootMethodSynchronizedObject = synchronizedObject(frameState, compilation.method); | 200 rootMethodSynchronizedObject = synchronizedObject(frameState, compilation.method); |
201 genMonitorEnter(rootMethodSynchronizedObject, Instruction.SYNCHRONIZATION_ENTRY_BCI); | 201 genMonitorEnter(rootMethodSynchronizedObject, Instruction.SYNCHRONIZATION_ENTRY_BCI); |
202 // 4A.2 finish the start block | 202 // 4A.2 finish the start block |
203 finishStartBlock(startBlock, stdEntry); | 203 finishStartBlock(startBlock, entryBlock); |
204 | 204 |
205 // 4A.3 setup an exception handler to unlock the root method synchronized object | 205 // 4A.3 setup an exception handler to unlock the root method synchronized object |
206 syncHandler = new BlockBegin(Instruction.SYNCHRONIZATION_ENTRY_BCI, ir.nextBlockNumber(), graph); | 206 syncHandler = new BlockBegin(Instruction.SYNCHRONIZATION_ENTRY_BCI, ir.nextBlockNumber(), graph); |
207 syncHandler.setExceptionEntry(); | 207 syncHandler.setExceptionEntry(); |
208 syncHandler.setBlockFlag(BlockBegin.BlockFlag.IsOnWorkList); | 208 syncHandler.setBlockFlag(BlockBegin.BlockFlag.IsOnWorkList); |
211 ExceptionHandler h = new ExceptionHandler(new CiExceptionHandler(0, rootMethod.code().length, -1, 0, null)); | 211 ExceptionHandler h = new ExceptionHandler(new CiExceptionHandler(0, rootMethod.code().length, -1, 0, null)); |
212 h.setEntryBlock(syncHandler); | 212 h.setEntryBlock(syncHandler); |
213 addExceptionHandler(h); | 213 addExceptionHandler(h); |
214 } else { | 214 } else { |
215 // 4B.1 simply finish the start block | 215 // 4B.1 simply finish the start block |
216 finishStartBlock(startBlock, stdEntry); | 216 finishStartBlock(startBlock, entryBlock); |
217 } | 217 } |
218 | 218 |
219 // 5. SKIPPED: look for intrinsics | 219 // 5. SKIPPED: look for intrinsics |
220 | 220 |
221 // 6B.1 do the normal parsing | 221 // 6B.1 do the normal parsing |
222 addToWorkList(stdEntry); | 222 addToWorkList(entryBlock); |
223 iterateAllBlocks(); | 223 iterateAllBlocks(); |
224 | 224 |
225 if (syncHandler != null && syncHandler.stateBefore() != null) { | 225 if (syncHandler != null && syncHandler.stateBefore() != null) { |
226 // generate unlocking code if the exception handler is reachable | 226 // generate unlocking code if the exception handler is reachable |
227 fillSyncHandler(rootMethodSynchronizedObject, syncHandler); | 227 fillSyncHandler(rootMethodSynchronizedObject, syncHandler); |