Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/ir/ComputeLinearScanOrder.java @ 2723:173067211acb
Removed two more BlockBegin flags.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Thu, 19 May 2011 16:44:05 +0200 |
parents | 23d0bcfa3c84 |
children | 03b80fb10ae9 |
comparison
equal
deleted
inserted
replaced
2722:23d0bcfa3c84 | 2723:173067211acb |
---|---|
141 TTY.println("backward branch"); | 141 TTY.println("backward branch"); |
142 } | 142 } |
143 assert isVisited(cur) : "block must be visited when block is active"; | 143 assert isVisited(cur) : "block must be visited when block is active"; |
144 assert parent != null : "must have parent"; | 144 assert parent != null : "must have parent"; |
145 | 145 |
146 cur.setBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader); | 146 //cur.setBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader); |
147 | 147 |
148 parent.setBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd); | 148 //parent.setBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd); |
149 | 149 |
150 loopEndBlocks.add(parent); | 150 loopEndBlocks.add(parent); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
188 // limit loop-depth to 15 bit (only for security reason, it will never be so big) | 188 // limit loop-depth to 15 bit (only for security reason, it will never be so big) |
189 int loopDepth = 0; // TODO(tw): Assign loop depth | 189 int loopDepth = 0; // TODO(tw): Assign loop depth |
190 int weight = (loopDepth & 0x7FFF) << 16; | 190 int weight = (loopDepth & 0x7FFF) << 16; |
191 | 191 |
192 int curBit = 15; | 192 int curBit = 15; |
193 | |
194 // this is necessary for the (very rare) case that two successive blocks have | |
195 // the same loop depth, but a different loop index (can happen for endless loops | |
196 // with exception handlers) | |
197 if (!cur.isLinearScanLoopHeader()) { | |
198 weight |= (1 << curBit); | |
199 } | |
200 curBit--; | |
201 | |
202 // loop end blocks (blocks that end with a backward branch) are added | |
203 // after all other blocks of the loop. | |
204 if (!cur.isLinearScanLoopEnd()) { | |
205 weight |= (1 << curBit); | |
206 } | |
207 curBit--; | |
208 | 193 |
209 // exceptions should not be thrown in normal control flow, so these blocks | 194 // exceptions should not be thrown in normal control flow, so these blocks |
210 // are added as late as possible | 195 // are added as late as possible |
211 if (!(cur.end() instanceof Throw) && (singleSux == null || !(singleSux.end() instanceof Throw))) { | 196 if (!(cur.end() instanceof Throw) && (singleSux == null || !(singleSux.end() instanceof Throw))) { |
212 weight |= (1 << curBit); | 197 weight |= (1 << curBit); |
316 }); | 301 }); |
317 } while (workList.size() > 0); | 302 } while (workList.size() > 0); |
318 } | 303 } |
319 | 304 |
320 public void printBlocks() { | 305 public void printBlocks() { |
321 if (C1XOptions.TraceLinearScanLevel >= 2) { | |
322 TTY.println("----- loop information:"); | |
323 for (BlockBegin cur : linearScanOrder) { | |
324 TTY.print(String.format("%4d: B%02d: ", cur.linearScanNumber(), cur.blockID)); | |
325 // for (int loopIdx = 0; loopIdx < numLoops; loopIdx++) { | |
326 // TTY.print(String.format("%d = %b ", loopIdx, isBlockInLoop(loopIdx, cur))); | |
327 // } | |
328 TTY.println(String.format(" . loopIndex: %2d, loopDepth: %2d", -1, -1)); | |
329 } | |
330 } | |
331 | |
332 if (C1XOptions.TraceLinearScanLevel >= 1) { | 306 if (C1XOptions.TraceLinearScanLevel >= 1) { |
333 TTY.println("----- linear-scan block order:"); | 307 TTY.println("----- linear-scan block order:"); |
334 for (BlockBegin cur : linearScanOrder) { | 308 for (BlockBegin cur : linearScanOrder) { |
335 TTY.print(String.format("%4d: B%02d loop: %2d depth: %2d", cur.linearScanNumber(), cur.blockID, -1, -1)); | 309 TTY.print(String.format("%4d: B%02d loop: %2d depth: %2d", cur.linearScanNumber(), cur.blockID, -1, -1)); |
336 | |
337 TTY.print(cur.isLinearScanLoopHeader() ? " lh" : " "); | |
338 TTY.print(cur.isLinearScanLoopEnd() ? " le" : " "); | |
339 | 310 |
340 if (cur.numberOfPreds() > 0) { | 311 if (cur.numberOfPreds() > 0) { |
341 TTY.print(" preds: "); | 312 TTY.print(" preds: "); |
342 for (int j = 0; j < cur.numberOfPreds(); j++) { | 313 for (int j = 0; j < cur.numberOfPreds(); j++) { |
343 BlockBegin pred = cur.predAt(j).block(); | 314 BlockBegin pred = cur.predAt(j).block(); |
374 assert cur.linearScanNumber() == i : "incorrect linearScanNumber"; | 345 assert cur.linearScanNumber() == i : "incorrect linearScanNumber"; |
375 assert cur.linearScanNumber() >= 0 && cur.linearScanNumber() == linearScanOrder.indexOf(cur) : "incorrect linearScanNumber"; | 346 assert cur.linearScanNumber() >= 0 && cur.linearScanNumber() == linearScanOrder.indexOf(cur) : "incorrect linearScanNumber"; |
376 | 347 |
377 for (BlockBegin sux : cur.end().blockSuccessors()) { | 348 for (BlockBegin sux : cur.end().blockSuccessors()) { |
378 assert sux.linearScanNumber() >= 0 && sux.linearScanNumber() == linearScanOrder.indexOf(sux) : "incorrect linearScanNumber"; | 349 assert sux.linearScanNumber() >= 0 && sux.linearScanNumber() == linearScanOrder.indexOf(sux) : "incorrect linearScanNumber"; |
379 if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopEnd)) { | |
380 assert cur.linearScanNumber() < sux.linearScanNumber() : "invalid order"; | |
381 } | |
382 } | 350 } |
383 | 351 |
384 for (Instruction pred : cur.blockPredecessors()) { | 352 for (Instruction pred : cur.blockPredecessors()) { |
385 BlockBegin begin = pred.block(); | 353 BlockBegin begin = pred.block(); |
386 assert begin.linearScanNumber() >= 0 && begin.linearScanNumber() == linearScanOrder.indexOf(begin) : "incorrect linearScanNumber"; | 354 assert begin.linearScanNumber() >= 0 && begin.linearScanNumber() == linearScanOrder.indexOf(begin) : "incorrect linearScanNumber"; |
387 if (!cur.checkBlockFlag(BlockBegin.BlockFlag.LinearScanLoopHeader)) { | |
388 assert cur.linearScanNumber() > begin.linearScanNumber() : "invalid order"; | |
389 } | |
390 } | 355 } |
391 } | 356 } |
392 | 357 |
393 return true; | 358 return true; |
394 } | 359 } |