summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend/icode
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-11-12 23:21:47 -0800
committerPaul Phillips <paulp@improving.org>2012-11-19 11:53:44 -0800
commit645c2676dd6699ac24a57dfe750386bbdb827ee8 (patch)
tree8a7391c27b58da5ef5529ce17ce3b1f3178a21e9 /src/compiler/scala/tools/nsc/backend/icode
parent345f937b3441f248ac9156484758fa17b1a78941 (diff)
downloadscala-645c2676dd6699ac24a57dfe750386bbdb827ee8.tar.gz
scala-645c2676dd6699ac24a57dfe750386bbdb827ee8.tar.bz2
scala-645c2676dd6699ac24a57dfe750386bbdb827ee8.zip
Commenting out unused members.
I want to get this commit into the history because the tests pass here, which demonstrates that every commented out method is not only unnecessary internally but has zero test coverage. Since I know (based on the occasional source code comment, or more often based on knowing something about other source bases) that some of these can't be removed without breaking other things, I want to at least record a snapshot of the identities of all these unused and untested methods. This commit will be reverted; then there will be another commit which removes the subset of these methods which I believe to be removable. The remainder are in great need of tests which exercise the interfaces upon which other repositories depend.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/icode')
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala36
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala10
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala28
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Members.scala50
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Primitives.scala16
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Repository.scala14
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala6
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala20
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala10
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala62
12 files changed, 138 insertions, 138 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index b62d5cb4e4..52fc3d08e1 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -281,12 +281,12 @@ trait BasicBlocks {
}
/** Insert instructions in 'is' immediately after index 'idx'. */
- def insertAfter(idx: Int, is: List[Instruction]) {
- assert(closed, "Instructions can be replaced only after the basic block is closed")
+ // def insertAfter(idx: Int, is: List[Instruction]) {
+ // assert(closed, "Instructions can be replaced only after the basic block is closed")
- instrs = instrs.patch(idx + 1, is, 0)
- code.touched = true
- }
+ // instrs = instrs.patch(idx + 1, is, 0)
+ // code.touched = true
+ // }
/** Removes instructions found at the given positions.
*
@@ -436,10 +436,10 @@ trait BasicBlocks {
ignore = true
}
- def exitIgnoreMode() {
- assert(ignore, "Exit ignore mode when not in ignore mode: " + this)
- ignore = false
- }
+ // def exitIgnoreMode() {
+ // assert(ignore, "Exit ignore mode when not in ignore mode: " + this)
+ // ignore = false
+ // }
/** Return the last instruction of this basic block. */
def lastInstruction =
@@ -498,15 +498,15 @@ trait BasicBlocks {
override def hashCode = label * 41 + code.hashCode
// Instead of it, rather use a printer
- def print() { print(java.lang.System.out) }
-
- def print(out: java.io.PrintStream) {
- out.println("block #"+label+" :")
- foreach(i => out.println(" " + i))
- out.print("Successors: ")
- successors.foreach((x: BasicBlock) => out.print(" "+x.label.toString()))
- out.println()
- }
+ // def print() { print(java.lang.System.out) }
+
+ // def print(out: java.io.PrintStream) {
+ // out.println("block #"+label+" :")
+ // foreach(i => out.println(" " + i))
+ // out.print("Successors: ")
+ // successors.foreach((x: BasicBlock) => out.print(" "+x.label.toString()))
+ // out.println()
+ // }
private def succString = if (successors.isEmpty) "[S: N/A]" else successors.distinct.mkString("[S: ", ", ", "]")
private def predString = if (predecessors.isEmpty) "[P: N/A]" else predecessors.distinct.mkString("[P: ", ", ", "]")
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
index f35996eeb9..e1732d5775 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
@@ -72,9 +72,9 @@ trait ExceptionHandlers {
override def dup: Finalizer = new Finalizer(method, label, pos)
}
- object NoFinalizer extends Finalizer(null, newTermNameCached("<no finalizer>"), NoPosition) {
- override def startBlock: BasicBlock = sys.error("NoFinalizer cannot have a start block.");
- override def setStartBlock(b: BasicBlock): Unit = sys.error("NoFinalizer cannot have a start block.");
- override def dup = this
- }
+ // object NoFinalizer extends Finalizer(null, newTermNameCached("<no finalizer>"), NoPosition) {
+ // override def startBlock: BasicBlock = sys.error("NoFinalizer cannot have a start block.");
+ // override def setStartBlock(b: BasicBlock): Unit = sys.error("NoFinalizer cannot have a start block.");
+ // override def dup = this
+ // }
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 720896d0b3..d521f893d1 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1960,12 +1960,12 @@ abstract class GenICode extends SubComponent {
this
}
- def removeFinalizer(f: Tree): this.type = {
- assert(cleanups.head contains f,
- "Illegal nesting of cleanup operations: " + cleanups + " while exiting finalizer " + f);
- cleanups = cleanups.tail
- this
- }
+ // def removeFinalizer(f: Tree): this.type = {
+ // assert(cleanups.head contains f,
+ // "Illegal nesting of cleanup operations: " + cleanups + " while exiting finalizer " + f);
+ // cleanups = cleanups.tail
+ // this
+ // }
/** Prepare a new context upon entry into a method.
*
@@ -2044,14 +2044,14 @@ abstract class GenICode extends SubComponent {
}
/** Remove the given handler from the list of active exception handlers. */
- def removeActiveHandler(exh: ExceptionHandler): Unit = {
- assert(handlerCount > 0 && handlers.head == exh,
- "Wrong nesting of exception handlers." + this + " for " + exh)
- handlerCount -= 1
- handlers = handlers.tail
- debuglog("removed handler: " + exh);
+ // def removeActiveHandler(exh: ExceptionHandler): Unit = {
+ // assert(handlerCount > 0 && handlers.head == exh,
+ // "Wrong nesting of exception handlers." + this + " for " + exh)
+ // handlerCount -= 1
+ // handlers = handlers.tail
+ // debuglog("removed handler: " + exh);
- }
+ // }
/** Clone the current context */
def dup: Context = new Context(this)
@@ -2339,7 +2339,7 @@ abstract class GenICode extends SubComponent {
val locals: ListBuffer[Local] = new ListBuffer
def add(l: Local) = locals += l
- def remove(l: Local) = locals -= l
+ // def remove(l: Local) = locals -= l
/** Return all locals that are in scope. */
def varsInScope: Buffer[Local] = outer.varsInScope.clone() ++= locals
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
index 07abe9d74f..4192d794f9 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
@@ -126,9 +126,9 @@ trait Members {
override def toString() = symbol.fullName
- def lookupField(s: Symbol) = fields find (_.symbol == s)
+ // def lookupField(s: Symbol) = fields find (_.symbol == s)
def lookupMethod(s: Symbol) = methods find (_.symbol == s)
- def lookupMethod(s: Name) = methods find (_.symbol.name == s)
+ // def lookupMethod(s: Name) = methods find (_.symbol.name == s)
/* returns this methods static ctor if it has one. */
def lookupStaticCtor: Option[IMethod] = methods find (_.symbol.isStaticConstructor)
@@ -159,7 +159,7 @@ trait Members {
def linearizedBlocks(lin: Linearizer = self.linearizer): List[BasicBlock] = lin linearize this
def foreachBlock[U](f: BasicBlock => U): Unit = blocks foreach f
- def foreachInstr[U](f: Instruction => U): Unit = foreachBlock(_.toList foreach f)
+ // def foreachInstr[U](f: Instruction => U): Unit = foreachBlock(_.toList foreach f)
var native = false
@@ -192,7 +192,7 @@ trait Members {
}
def addLocals(ls: List[Local]) = ls foreach addLocal
- def addParams(as: List[Local]) = as foreach addParam
+ // def addParams(as: List[Local]) = as foreach addParam
def lookupLocal(n: Name): Option[Local] = locals find (_.sym.name == n)
def lookupLocal(sym: Symbol): Option[Local] = locals find (_.sym == sym)
@@ -207,28 +207,28 @@ trait Members {
override def toString() = symbol.fullName
- def matchesSignature(other: IMethod) = {
- (symbol.name == other.symbol.name) &&
- (params corresponds other.params)(_.kind == _.kind) &&
- (returnType == other.returnType)
- }
+ // def matchesSignature(other: IMethod) = {
+ // (symbol.name == other.symbol.name) &&
+ // (params corresponds other.params)(_.kind == _.kind) &&
+ // (returnType == other.returnType)
+ // }
import opcodes._
- def checkLocals(): Unit = {
- def localsSet = (code.blocks flatMap { bb =>
- bb.iterator collect {
- case LOAD_LOCAL(l) => l
- case STORE_LOCAL(l) => l
- }
- }).toSet
-
- if (hasCode) {
- log("[checking locals of " + this + "]")
- locals filterNot localsSet foreach { l =>
- log("Local " + l + " is not declared in " + this)
- }
- }
- }
+ // def checkLocals(): Unit = {
+ // def localsSet = (code.blocks flatMap { bb =>
+ // bb.iterator collect {
+ // case LOAD_LOCAL(l) => l
+ // case STORE_LOCAL(l) => l
+ // }
+ // }).toSet
+
+ // if (hasCode) {
+ // log("[checking locals of " + this + "]")
+ // locals filterNot localsSet foreach { l =>
+ // log("Local " + l + " is not declared in " + this)
+ // }
+ // }
+ // }
/** Merge together blocks that have a single successor which has a
* single predecessor. Exception handlers are taken into account (they
@@ -295,7 +295,7 @@ trait Members {
var start: Int = _
/** Ending PC for this local's visibility range. */
- var end: Int = _
+ // var end: Int = _
/** PC-based ranges for this local variable's visibility */
var ranges: List[(Int, Int)] = Nil
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
index 0e7c75de50..6f7db042e6 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
@@ -111,7 +111,7 @@ trait Opcodes { self: ICodes =>
def producedTypes: List[TypeKind] = Nil
/** This method returns the difference of size of the stack when the instruction is used */
- def difference = produced-consumed
+ // def difference = produced-consumed
/** The corresponding position in the source file */
private var _pos: Position = NoPosition
@@ -119,7 +119,7 @@ trait Opcodes { self: ICodes =>
def pos: Position = _pos
/** Used by dead code elimination. */
- var useful: Boolean = false
+ // var useful: Boolean = false
def setPos(p: Position): this.type = {
_pos = p
@@ -133,11 +133,11 @@ trait Opcodes { self: ICodes =>
object opcodes {
- def mayThrow(i: Instruction): Boolean = i match {
- case LOAD_LOCAL(_) | STORE_LOCAL(_) | CONSTANT(_) | THIS(_) | CZJUMP(_, _, _, _)
- | DROP(_) | DUP(_) | RETURN(_) | LOAD_EXCEPTION(_) | JUMP(_) | CJUMP(_, _, _, _) => false
- case _ => true
- }
+ // def mayThrow(i: Instruction): Boolean = i match {
+ // case LOAD_LOCAL(_) | STORE_LOCAL(_) | CONSTANT(_) | THIS(_) | CZJUMP(_, _, _, _)
+ // | DROP(_) | DUP(_) | RETURN(_) | LOAD_EXCEPTION(_) | JUMP(_) | CJUMP(_, _, _, _) => false
+ // case _ => true
+ // }
/** Loads "this" on top of the stack.
* Stack: ...
@@ -714,7 +714,7 @@ trait Opcodes { self: ICodes =>
/** Is this a static method call? */
def isStatic: Boolean = false
- def isSuper: Boolean = false
+ // def isSuper: Boolean = false
/** Is this an instance method call? */
def hasInstance: Boolean = true
@@ -749,7 +749,7 @@ trait Opcodes { self: ICodes =>
* On JVM, translated to `invokespecial`.
*/
case class SuperCall(mix: Name) extends InvokeStyle {
- override def isSuper = true
+ // override def isSuper = true
override def toString(): String = { "super(" + mix + ")" }
}
@@ -814,7 +814,7 @@ trait Opcodes { self: ICodes =>
case class CIL_NEWOBJ(method: Symbol) extends Instruction {
override def toString(): String = "CIL_NEWOBJ " + hostClass.fullName + method.fullName
- var hostClass: Symbol = method.owner;
+ val hostClass: Symbol = method.owner;
override def consumed = method.tpe.paramTypes.length
override def consumedTypes = method.tpe.paramTypes map toTypeKind
override def produced = 1
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
index c8579041ba..ebfb4ad591 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
@@ -84,17 +84,17 @@ trait Primitives { self: ICodes =>
def print(o: AnyRef): PrimitivePrinter = print(o.toString())
- def printPrimitive(prim: Primitive) = prim match {
- case Negation(kind) =>
- print("!")
+ // def printPrimitive(prim: Primitive) = prim match {
+ // case Negation(kind) =>
+ // print("!")
- case Test(op, kind, zero) =>
- print(op).print(kind)
+ // case Test(op, kind, zero) =>
+ // print(op).print(kind)
- case Comparison(op, kind) =>
- print(op).print("(").print(kind)
+ // case Comparison(op, kind) =>
+ // print(op).print("(").print(kind)
- }
+ // }
}
/** This class represents a comparison operation. */
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala
index e73015c4da..c8168cbfa6 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala
@@ -29,13 +29,13 @@ trait Repository {
/** The icode of the given class. If not available, it loads
* its bytecode.
*/
- def icode(sym: Symbol, force: Boolean): IClass =
- icode(sym) getOrElse {
- log("loading " + sym)
- load(sym)
- assert(available(sym))
- loaded(sym)
- }
+ // def icode(sym: Symbol, force: Boolean): IClass =
+ // icode(sym) getOrElse {
+ // log("loading " + sym)
+ // load(sym)
+ // assert(available(sym))
+ // loaded(sym)
+ // }
/** Load bytecode for given symbol. */
def load(sym: Symbol): Boolean = {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
index f96dce9f1c..2df6811fd7 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala
@@ -66,7 +66,7 @@ trait TypeKinds { self: ICodes =>
def isValueType = false
def isBoxedType = false
final def isRefOrArrayType = isReferenceType || isArrayType
- final def isRefArrayOrBoxType = isRefOrArrayType || isBoxedType
+ // final def isRefArrayOrBoxType = isRefOrArrayType || isBoxedType
final def isNothingType = this == NothingReference
final def isNullType = this == NullReference
final def isInterfaceType = this match {
@@ -114,7 +114,7 @@ trait TypeKinds { self: ICodes =>
}
}
- var lubs0 = 0
+ // var lubs0 = 0
/**
* The least upper bound of two typekinds. They have to be either
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala
index c1bf4304ea..c958f20853 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/TypeStacks.scala
@@ -20,7 +20,7 @@ trait TypeStacks {
*/
type Rep = List[TypeKind]
- object NoTypeStack extends TypeStack(Nil) { }
+ // object NoTypeStack extends TypeStack(Nil) { }
class TypeStack(var types: Rep) {
if (types.nonEmpty)
@@ -74,8 +74,8 @@ trait TypeStacks {
* length and each type kind agrees position-wise. Two
* types agree if one is a subtype of the other.
*/
- def agreesWith(other: TypeStack): Boolean =
- (types corresponds other.types)((t1, t2) => t1 <:< t2 || t2 <:< t1)
+ // def agreesWith(other: TypeStack): Boolean =
+ // (types corresponds other.types)((t1, t2) => t1 <:< t2 || t2 <:< t1)
/* This method returns a String representation of the stack */
override def toString() =
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
index 53111d0ade..6534cd83f1 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
@@ -27,10 +27,10 @@ abstract class CopyPropagation {
/** Values that can be on the stack. */
abstract class Value {
- def isRecord = false
+ // def isRecord = false
}
case class Record(cls: Symbol, bindings: mutable.Map[Symbol, Value]) extends Value {
- override def isRecord = true
+ // override def isRecord = true
}
/** The value of some location in memory. */
case class Deref(l: Location) extends Value
@@ -92,14 +92,14 @@ abstract class CopyPropagation {
}
/* Return the binding for the given field of the given record */
- def getBinding(r: Record, f: Symbol): Value = {
- assert(r.bindings contains f, "Record " + r + " does not contain a field " + f)
-
- r.bindings(f) match {
- case Deref(LocalVar(l)) => getBinding(l)
- case target => target
- }
- }
+ // def getBinding(r: Record, f: Symbol): Value = {
+ // assert(r.bindings contains f, "Record " + r + " does not contain a field " + f)
+
+ // r.bindings(f) match {
+ // case Deref(LocalVar(l)) => getBinding(l)
+ // case target => target
+ // }
+ // }
/** Return a local which contains the same value as this field, if any.
* If the field holds a reference to a local, the returned value is the
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
index 04c3eedbad..c232c3692a 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
@@ -37,11 +37,11 @@ trait DataFlowAnalysis[L <: SemiLattice] {
/** Reinitialize, but keep the old solutions. Should be used when reanalyzing the
* same method, after some code transformation.
*/
- def reinit(f: => Unit): Unit = {
- iterations = 0
- worklist.clear; visited.clear;
- f
- }
+ // def reinit(f: => Unit): Unit = {
+ // iterations = 0
+ // worklist.clear; visited.clear;
+ // f
+ // }
def run(): Unit
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index 15755f31ad..6e7ed9d4c4 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -269,34 +269,34 @@ abstract class TypeFlowAnalysis {
} // interpret
- class SimulatedStack {
- private var types: List[InferredType] = Nil
- private var depth = 0
-
- /** Remove and return the topmost element on the stack. If the
- * stack is empty, return a reference to a negative index on the
- * stack, meaning it refers to elements pushed by a predecessor block.
- */
- def pop: InferredType = types match {
- case head :: rest =>
- types = rest
- head
- case _ =>
- depth -= 1
- TypeOfStackPos(depth)
- }
-
- def pop2: (InferredType, InferredType) = {
- (pop, pop)
- }
-
- def push(t: InferredType) {
- depth += 1
- types = types ::: List(t)
- }
-
- def push(k: TypeKind) { push(Const(k)) }
- }
+ // class SimulatedStack {
+ // private var types: List[InferredType] = Nil
+ // private var depth = 0
+
+ // /** Remove and return the topmost element on the stack. If the
+ // * stack is empty, return a reference to a negative index on the
+ // * stack, meaning it refers to elements pushed by a predecessor block.
+ // */
+ // def pop: InferredType = types match {
+ // case head :: rest =>
+ // types = rest
+ // head
+ // case _ =>
+ // depth -= 1
+ // TypeOfStackPos(depth)
+ // }
+
+ // def pop2: (InferredType, InferredType) = {
+ // (pop, pop)
+ // }
+
+ // def push(t: InferredType) {
+ // depth += 1
+ // types = types ::: List(t)
+ // }
+
+ // def push(k: TypeKind) { push(Const(k)) }
+ // }
abstract class InferredType {
/** Return the type kind pointed by this inferred type. */
@@ -737,9 +737,9 @@ abstract class TypeFlowAnalysis {
private var lastStart = 0L
- def reset() {
- millis = 0L
- }
+ // def reset() {
+ // millis = 0L
+ // }
def start() {
lastStart = System.currentTimeMillis