diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2009-10-06 16:22:11 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2009-10-06 16:22:11 +0000 |
commit | fe8658350be10057c5794ab3ccfa32894a46c710 (patch) | |
tree | 50d1e149d0793242a17c975b87aa1181ef259392 /src/compiler | |
parent | 3e417979855b4a5c14db88c9d62f4264cbbcf631 (diff) | |
download | scala-fe8658350be10057c5794ab3ccfa32894a46c710.tar.gz scala-fe8658350be10057c5794ab3ccfa32894a46c710.tar.bz2 scala-fe8658350be10057c5794ab3ccfa32894a46c710.zip |
Fixed stability issues for optimised
Diffstat (limited to 'src/compiler')
4 files changed, 14 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index def5f1060d..a774473167 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -167,7 +167,7 @@ trait BasicBlocks { def replaceInstruction(pos: Int, instr: Instruction): Boolean = { assert(closed, "Instructions can be replaced only after the basic block is closed") - instr.pos = instrs(pos).pos + instr.setPos(instrs(pos).pos) instrs(pos) = instr true } @@ -184,7 +184,7 @@ trait BasicBlocks { var changed = false while (i < instrs.length && !changed) { if (instrs(i) == oldInstr) { - newInstr.pos = oldInstr.pos + newInstr.setPos(oldInstr.pos) instrs(i) = newInstr changed = true } @@ -330,7 +330,7 @@ trait BasicBlocks { if (!ignore) { touched = true - instr.pos = pos + instr.setPos(pos) instructionList = instr :: instructionList _lastInstruction = instr } diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala index 07e9f07454..ca2a0591ed 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala @@ -59,7 +59,7 @@ trait Opcodes { self: ICodes => /** This class represents an instruction of the intermediate code. * Each case subclass will represent a specific operation. */ - abstract class Instruction { + abstract class Instruction extends Cloneable { /** This abstract method returns the number of used elements on the stack */ def consumed : Int = 0 @@ -79,15 +79,21 @@ trait Opcodes { self: ICodes => def difference = produced-consumed /** The corresponding position in the source file */ - var pos: Position = NoPosition + private var _pos: Position = NoPosition + + def pos: Position = _pos /** Used by dead code elimination. */ var useful: Boolean = false def setPos(p: Position): this.type = { - pos = p + _pos = p this } + + /** Clone this instruction. */ + override def clone: Instruction = + super.clone.asInstanceOf[Instruction] } object opcodes { diff --git a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala index 1dd51a3741..f03b84a50e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Printers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Printers.scala @@ -128,8 +128,7 @@ trait Printers { self: ICodes => def printInstruction(i: Instruction) { // if (settings.Xdce.value) // print(if (i.useful) " " else " * "); - if (settings.debug.value) - if (i.pos.isDefined) print(i.pos.line.toString) + if (i.pos.isDefined) print(i.pos.line.toString + "\t") else print("undef\t") println(i.toString()) } } diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index 829052cf6d..487e66fc9e 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -199,7 +199,7 @@ abstract class Inliners extends SubComponent { case CALL_METHOD(meth, Static(true)) if (meth.isClassConstructor) => CALL_METHOD(meth, Static(true)) - case _ => i + case _ => i.clone } // check any pending NEW's if (pending isDefinedAt i) { |