From 3fb317560c7e1220cd51c7f8408cf3db6a84b290 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 19 May 2013 03:42:03 -0700 Subject: SI-7427 stop crashing under -Ydebug. Change "dumpClassesAndAbort" to "devWarning". You can witness it happen like so. % scalac test/files/pos/t7427.scala -Ydebug -Xdev ... [running phase cleanup on t7427.scala] [running phase icode on t7427.scala] warning: !!! PJUMP(method matchEnd4)/scala.tools.nsc.backend.icode.GenICode$PJUMP is not a control flow instruction warning: !!! PJUMP(method case6)/scala.tools.nsc.backend.icode.GenICode$PJUMP is not a control flow instruction [running phase inliner on t7427.scala] [running phase inlinehandlers on t7427.scala] Having now lived with this for months, I have no ambition to unravel the actual problem, I just want it to stop crashing. --- .../tools/nsc/backend/icode/BasicBlocks.scala | 33 +++++++++++----------- .../scala/tools/nsc/backend/icode/GenICode.scala | 3 +- test/files/pos/t7427.flags | 1 + test/files/pos/t7427.scala | 4 +++ 4 files changed, 22 insertions(+), 19 deletions(-) create mode 100644 test/files/pos/t7427.flags create mode 100644 test/files/pos/t7427.scala diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 16ee40280c..26d10d2514 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -8,8 +8,7 @@ package backend package icode import scala.collection.{ mutable, immutable } -import mutable.{ ListBuffer, ArrayBuffer } -import scala.reflect.internal.util.{ Position, NoPosition } +import mutable.ListBuffer import backend.icode.analysis.ProgramPoint import scala.language.postfixOps @@ -17,8 +16,7 @@ trait BasicBlocks { self: ICodes => import opcodes._ - import global.{ settings, debuglog, log, nme } - import nme.isExceptionResultName + import global._ /** Override Array creation for efficiency (to not go through reflection). */ private implicit val instructionTag: scala.reflect.ClassTag[Instruction] = new scala.reflect.ClassTag[Instruction] { @@ -336,9 +334,9 @@ trait BasicBlocks { * put into ignore mode so we hear about it if there's a problem. */ instr match { - case JUMP(_) | RETURN(_) | THROW(_) | SCOPE_EXIT(_) => // ok - case STORE_LOCAL(local) if isExceptionResultName(local.sym.name) => // ok - case x => log("Ignoring instruction, possibly at our peril, at " + pos + ": " + x) + case JUMP(_) | RETURN(_) | THROW(_) | SCOPE_EXIT(_) => // ok + case STORE_LOCAL(local) if nme.isExceptionResultName(local.sym.name) => // ok + case x => log("Ignoring instruction, possibly at our peril, at " + pos + ": " + x) } } } @@ -416,7 +414,7 @@ trait BasicBlocks { enterIgnoreMode() } } - + /** * Same as killIf but with the logic of the condition reversed */ @@ -477,16 +475,17 @@ trait BasicBlocks { def directSuccessors: List[BasicBlock] = if (isEmpty) Nil else lastInstruction match { - case JUMP(whereto) => whereto :: Nil - case CJUMP(succ, fail, _, _) => fail :: succ :: Nil - case CZJUMP(succ, fail, _, _) => fail :: succ :: Nil - case SWITCH(_, labels) => labels - case RETURN(_) => Nil - case THROW(_) => Nil - case _ => + case JUMP(whereto) => whereto :: Nil + case CJUMP(succ, fail, _, _) => fail :: succ :: Nil + case CZJUMP(succ, fail, _, _) => fail :: succ :: Nil + case SWITCH(_, labels) => labels + case RETURN(_) => Nil + case THROW(_) => Nil + case _ => if (closed) - dumpClassesAndAbort("The last instruction is not a control flow instruction: " + lastInstruction) - else Nil + devWarning(s"$lastInstruction/${lastInstruction.getClass.getName} is not a control flow instruction") + + Nil } /** Returns the predecessors of this block. */ diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 9c9c001f02..cc4d97253f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -2165,8 +2165,7 @@ abstract class GenICode extends SubComponent { * by a real JUMP instruction when all labels are resolved. */ abstract class PseudoJUMP(label: Label) extends Instruction { - override def toString(): String = "PJUMP " + label.symbol - + override def toString = s"PJUMP(${label.symbol})" override def consumed = 0 override def produced = 0 diff --git a/test/files/pos/t7427.flags b/test/files/pos/t7427.flags new file mode 100644 index 0000000000..9c7d6400fc --- /dev/null +++ b/test/files/pos/t7427.flags @@ -0,0 +1 @@ +-Ydebug diff --git a/test/files/pos/t7427.scala b/test/files/pos/t7427.scala new file mode 100644 index 0000000000..cca52950d1 --- /dev/null +++ b/test/files/pos/t7427.scala @@ -0,0 +1,4 @@ +// Compiles with no options +// Compiles with -Ydebug -Ydisable-unreachable-prevention +// Crashes with -Ydebug +trait Bippy { 3 match { case 3 => } } -- cgit v1.2.3