diff options
author | Paul Phillips <paulp@improving.org> | 2011-08-03 01:20:37 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-08-03 01:20:37 +0000 |
commit | 39ebbf6743d0b861096051286d7608ffc9736888 (patch) | |
tree | 4b538f0302203ac2eb4466cec98dfc0eaa5bca8e /src/compiler/scala/tools/nsc/backend/icode/ICodes.scala | |
parent | 254ad276ca07c20a2782678a234c75ea1e7b9e83 (diff) | |
download | scala-39ebbf6743d0b861096051286d7608ffc9736888.tar.gz scala-39ebbf6743d0b861096051286d7608ffc9736888.tar.bz2 scala-39ebbf6743d0b861096051286d7608ffc9736888.zip |
Finished up some backend cleanups I'd had lying...
Finished up some backend cleanups I'd had lying around since scala days.
No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode/ICodes.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/ICodes.scala | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala index 06c3ee2a9e..7a0017944b 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala @@ -53,6 +53,9 @@ abstract class ICodes extends AnyRef case x => global.abort("Unknown linearizer: " + x) } + def newTextPrinter() = + new TextPrinter(new PrintWriter(Console.out, true), new DumpLinearizer) + /** Have to be careful because dump calls around, possibly * re-entering methods which initiated the dump (like foreach * in BasicBlocks) which leads to the icode output olympics. @@ -61,20 +64,27 @@ abstract class ICodes extends AnyRef /** Print all classes and basic blocks. Used for debugging. */ - def dump() { - if (alreadyDumping) return + def dumpClassesAndAbort(msg: String): Nothing = { + if (alreadyDumping) global.abort(msg) else alreadyDumping = true - val printer = new TextPrinter(new PrintWriter(Console.out, true), - new DumpLinearizer) - + Console.println(msg) + val printer = newTextPrinter() classes.values foreach printer.printClass + global.abort(msg) + } + + def dumpMethodAndAbort(m: IMethod, msg: String): Nothing = { + Console.println("Fatal bug in inlinerwhile traversing " + m + ": " + msg) + m.dump() + global.abort("" + m) } + def dumpMethodAndAbort(m: IMethod, b: BasicBlock): Nothing = + dumpMethodAndAbort(m, "found open block " + b + " " + b.flagsString) def checkValid(m: IMethod) { - // always dicey to iterate over mutable structures + // always slightly dicey to iterate over mutable structures val bs = m.code.blocks.toList - for (b <- bs ; if !b.closed) { // Something is leaving open/empty blocks around (see SI-4840) so // let's not kill the deal unless it's nonempty. @@ -82,11 +92,7 @@ abstract class ICodes extends AnyRef log("!!! Found open but empty block while inlining " + m + ": removing from block list.") m.code removeBlock b } - else { - Console.println("Fatal bug in inliner: found open block when inlining " + m) - m.dump - global.abort("Open block was: " + b + " " + b.flagsString) - } + else dumpMethodAndAbort(m, b) } } |