summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend')
-rw-r--r--src/compiler/scala/tools/nsc/backend/Platform.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodes.scala1
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Members.scala6
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Primitives.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala15
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala173
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala124
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala3
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala143
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala12
13 files changed, 11 insertions, 484 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/Platform.scala b/src/compiler/scala/tools/nsc/backend/Platform.scala
index 3bca16635b..499f8a9290 100644
--- a/src/compiler/scala/tools/nsc/backend/Platform.scala
+++ b/src/compiler/scala/tools/nsc/backend/Platform.scala
@@ -15,10 +15,6 @@ trait Platform {
val symbolTable: symtab.SymbolTable
import symbolTable._
- /** The binary classfile representation type */
- @deprecated("BinaryRepr is not an abstract type anymore. It's an alias that points at AbstractFile. It'll be removed before Scala 2.11 is released.", "2.11.0-M5")
- type BinaryRepr = AbstractFile
-
/** The compiler classpath. */
def classPath: ClassPath[AbstractFile]
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index 26d10d2514..f9551697d2 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -452,10 +452,6 @@ trait BasicBlocks {
if (closed) instrs(instrs.length - 1)
else instructionList.head
- def firstInstruction =
- if (closed) instrs(0)
- else instructionList.last
-
def exceptionSuccessors: List[BasicBlock] =
exceptionSuccessorsForBlock(this)
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
index b9eb8f8aac..bc35a9e7de 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
@@ -105,7 +105,6 @@ abstract class ICodes extends AnyRef
lazy val NullReference: TypeKind = REFERENCE(definitions.NullClass)
lazy val ObjectReference: TypeKind = REFERENCE(definitions.ObjectClass)
lazy val StringReference: TypeKind = REFERENCE(definitions.StringClass)
- lazy val ThrowableReference: TypeKind = REFERENCE(definitions.ThrowableClass)
object icodeReader extends ICodeReader {
lazy val global: ICodes.this.global.type = ICodes.this.global
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
index 91bd39232e..4d1d59cd12 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala
@@ -282,12 +282,6 @@ trait Members {
class Local(val sym: Symbol, val kind: TypeKind, val arg: Boolean) {
var index: Int = -1
- /** Starting PC for this local's visibility range. */
- var start: Int = _
-
- /** PC-based ranges for this local variable's visibility */
- var ranges: List[(Int, Int)] = Nil
-
override def equals(other: Any): Boolean = other match {
case x: Local => sym == x.sym
case _ => false
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
index 4fa717309e..f81c42d836 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Primitives.scala
@@ -80,8 +80,6 @@ trait Primitives { self: ICodes =>
out.print(s)
this
}
-
- def print(o: AnyRef): PrimitivePrinter = print(o.toString())
}
/** This class represents a comparison operation. */
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
index 817546b0f1..3bacc26a3a 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala
@@ -43,8 +43,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
/* ---------------- helper utils for generating methods and code ---------------- */
def emit(opc: Int) { mnode.visitInsn(opc) }
- def emit(i: asm.tree.AbstractInsnNode) { mnode.instructions.add(i) }
- def emit(is: List[asm.tree.AbstractInsnNode]) { for(i <- is) { mnode.instructions.add(i) } }
def emitZeroOf(tk: BType) {
(tk.sort: @switch) match {
@@ -411,7 +409,7 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
/*
* must-single-thread
*/
- private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol = null) {
+ private def fieldOp(field: Symbol, isLoad: Boolean, hostClass: Symbol) {
// LOAD_FIELD.hostClass , CALL_METHOD.hostClass , and #4283
val owner =
if (hostClass == null) internalName(field.owner)
@@ -950,13 +948,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
|| sym.isJavaDefined && sym.isNonBottomSubClass(definitions.ClassfileAnnotationClass)
)
- def isAccessibleFrom(target: Symbol, site: Symbol): Boolean = {
- target.isPublic || target.isProtected && {
- (site.enclClass isSubClass target.enclClass) ||
- (site.enclosingPackage == target.privateWithin)
- }
- }
-
// whether to reference the type of the receiver or
// the type of the method owner
val useMethodOwner = (
@@ -1233,10 +1224,6 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder {
}
}
- /* can-multi-thread */
- def getMaxType(ts: List[Type]): BType = {
- ts map toTypeKind reduceLeft maxType
- }
def genSynchronized(tree: Apply, expectedType: BType): BType
def genLoadTry(tree: Try): BType
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala
index f95ceef678..9dcf263f4f 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala
@@ -119,16 +119,6 @@ abstract class BCodeGlue extends SubComponent {
}
/*
- * @param typeDescriptor a field or method type descriptor.
- *
- * must-single-thread
- */
- def getType(typeDescriptor: String): BType = {
- val n = global.newTypeName(typeDescriptor)
- getType(n.start)
- }
-
- /*
* @param methodDescriptor a method descriptor.
*
* must-single-thread
@@ -177,20 +167,6 @@ abstract class BCodeGlue extends SubComponent {
}
/*
- * Returns the Java types corresponding to the argument types of the given
- * method descriptor.
- *
- * @param methodDescriptor a method descriptor.
- * @return the Java types corresponding to the argument types of the given method descriptor.
- *
- * must-single-thread
- */
- def getArgumentTypes(methodDescriptor: String): Array[BType] = {
- val n = global.newTypeName(methodDescriptor)
- getArgumentTypes(n.start + 1)
- }
-
- /*
* Returns the number of argument types of this method type, whose first argument starts at idx0.
*
* @param idx0 index into chrs of the first argument.
@@ -349,19 +325,6 @@ abstract class BCodeGlue extends SubComponent {
}
/*
- * @return the prefix of the internal name until the last '/' (if '/' present), empty string otherwise.
- *
- * can-multi-thread
- */
- def getRuntimePackage: String = {
- assert(hasObjectSort, s"not of object sort: $toString")
- val iname = getInternalName
- val idx = iname.lastIndexOf('/')
- if (idx == -1) ""
- else iname.substring(0, idx)
- }
-
- /*
* @return the suffix of the internal name until the last '/' (if '/' present), internal name otherwise.
*
* can-multi-thread
@@ -387,18 +350,6 @@ abstract class BCodeGlue extends SubComponent {
}
/*
- * Returns the number of arguments of methods of this type.
- * This method should only be used for method types.
- *
- * @return the number of arguments of methods of this type.
- *
- * can-multi-thread
- */
- def getArgumentCount: Int = {
- BType.getArgumentCount(off + 1)
- }
-
- /*
* Returns the return type of methods of this type.
* This method should only be used for method types.
*
@@ -413,38 +364,6 @@ abstract class BCodeGlue extends SubComponent {
BType.getType(resPos + 1)
}
- /*
- * Given a zero-based formal-param-position, return its corresponding local-var-index,
- * taking into account the JVM-type-sizes of preceding formal params.
- */
- def convertFormalParamPosToLocalVarIdx(paramPos: Int, isInstanceMethod: Boolean): Int = {
- assert(sort == asm.Type.METHOD)
- val paramTypes = getArgumentTypes
- var local = 0
- (0 until paramPos) foreach { argPos => local += paramTypes(argPos).getSize }
-
- local + (if (isInstanceMethod) 1 else 0)
- }
-
- /*
- * Given a local-var-index, return its corresponding zero-based formal-param-position,
- * taking into account the JVM-type-sizes of preceding formal params.
- */
- def convertLocalVarIdxToFormalParamPos(localIdx: Int, isInstanceMethod: Boolean): Int = {
- assert(sort == asm.Type.METHOD)
- val paramTypes = getArgumentTypes
- var remaining = (if (isInstanceMethod) (localIdx - 1) else localIdx)
- assert(remaining >= 0)
- var result = 0
- while (remaining > 0) {
- remaining -= paramTypes(result).getSize
- result += 1
- }
- assert(remaining == 0)
-
- result
- }
-
// ------------------------------------------------------------------------
// Inspector methods
// ------------------------------------------------------------------------
@@ -521,14 +440,6 @@ abstract class BCodeGlue extends SubComponent {
*/
def isWideType = (getSize == 2)
- def isCapturedCellRef: Boolean = {
- this == srBooleanRef || this == srByteRef ||
- this == srCharRef ||
- this == srIntRef ||
- this == srLongRef ||
- this == srFloatRef || this == srDoubleRef
- }
-
/*
* Element vs. Component type of an array:
* Quoting from the JVMS, Sec. 2.4 "Reference Types and Values"
@@ -750,14 +661,6 @@ abstract class BCodeGlue extends SubComponent {
val CT_NOTHING = brefType("scala/Nothing") // TODO needed?
val CT_NULL = brefType("scala/Null") // TODO needed?
- val srBooleanRef = brefType("scala/runtime/BooleanRef")
- val srByteRef = brefType("scala/runtime/ByteRef")
- val srCharRef = brefType("scala/runtime/CharRef")
- val srIntRef = brefType("scala/runtime/IntRef")
- val srLongRef = brefType("scala/runtime/LongRef")
- val srFloatRef = brefType("scala/runtime/FloatRef")
- val srDoubleRef = brefType("scala/runtime/DoubleRef")
-
/* Map from type kinds to the Java reference types.
* Useful when pushing class literals onto the operand stack (ldc instruction taking a class literal).
* @see Predef.classOf
@@ -802,80 +705,4 @@ abstract class BCodeGlue extends SubComponent {
DOUBLE -> MethodNameAndType("unboxToDouble", "(Ljava/lang/Object;)D")
)
}
-
- /*
- * can-multi-thread
- */
- def toBType(t: asm.Type): BType = {
- (t.getSort: @switch) match {
- case asm.Type.VOID => BType.VOID_TYPE
- case asm.Type.BOOLEAN => BType.BOOLEAN_TYPE
- case asm.Type.CHAR => BType.CHAR_TYPE
- case asm.Type.BYTE => BType.BYTE_TYPE
- case asm.Type.SHORT => BType.SHORT_TYPE
- case asm.Type.INT => BType.INT_TYPE
- case asm.Type.FLOAT => BType.FLOAT_TYPE
- case asm.Type.LONG => BType.LONG_TYPE
- case asm.Type.DOUBLE => BType.DOUBLE_TYPE
- case asm.Type.ARRAY |
- asm.Type.OBJECT |
- asm.Type.METHOD =>
- // TODO confirm whether this also takes care of the phantom types.
- val key =
- if (t.getSort == asm.Type.METHOD) t.getDescriptor
- else t.getInternalName
-
- val n = global.lookupTypeName(key.toCharArray)
- new BType(t.getSort, n.start, n.length)
- }
- }
-
- /*
- * ASM trees represent types as strings (internal names, descriptors).
- * Given that we operate instead on BTypes, conversion is needed when visiting MethodNodes outside GenBCode.
- *
- * can-multi-thread
- */
- def descrToBType(typeDescriptor: String): BType = {
- val c: Char = typeDescriptor(0)
- c match {
- case 'V' => BType.VOID_TYPE
- case 'Z' => BType.BOOLEAN_TYPE
- case 'C' => BType.CHAR_TYPE
- case 'B' => BType.BYTE_TYPE
- case 'S' => BType.SHORT_TYPE
- case 'I' => BType.INT_TYPE
- case 'F' => BType.FLOAT_TYPE
- case 'J' => BType.LONG_TYPE
- case 'D' => BType.DOUBLE_TYPE
- case 'L' =>
- val iname = typeDescriptor.substring(1, typeDescriptor.length() - 1)
- val n = global.lookupTypeName(iname.toCharArray)
- new BType(asm.Type.OBJECT, n.start, n.length)
- case _ =>
- val n = global.lookupTypeName(typeDescriptor.toCharArray)
- BType.getType(n.start)
- }
- }
-
- /*
- * Use only to lookup reference types, otherwise use `descrToBType()`
- *
- * can-multi-thread
- */
- def lookupRefBType(iname: String): BType = {
- import global.chrs
- val n = global.lookupTypeName(iname.toCharArray)
- val sort = if (chrs(n.start) == '[') BType.ARRAY else BType.OBJECT;
- new BType(sort, n.start, n.length)
- }
-
- def lookupRefBTypeIfExisting(iname: String): BType = {
- import global.chrs
- val n = global.lookupTypeNameIfExisting(iname.toCharArray, false)
- if (n == null) { return null }
- val sort = if (chrs(n.start) == '[') BType.ARRAY else BType.OBJECT;
- new BType(sort, n.start, n.length)
- }
-
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
index eff7d3211e..c22ced26a5 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -561,9 +561,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
memberCTK
}
-
- exemplar(csym).directMemberClasses = (result ::: lateClosuresBTs)
-
+ exemplar(csym) // side effect city
result
}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala
index eda17c6e32..529295389c 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala
@@ -46,7 +46,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
val ObjectReference = brefType("java/lang/Object")
val AnyRefReference = ObjectReference
- val objArrayReference = arrayOf(ObjectReference)
val JAVA_LANG_OBJECT = ObjectReference
val JAVA_LANG_STRING = brefType("java/lang/String")
@@ -73,11 +72,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
if (xs.isEmpty) { return EMPTY_LABEL_ARRAY }
val a = new Array[asm.Label](xs.size); xs.copyToArray(a); a
}
- /* can-multi-thread */
- final def mkArray(xs: List[Int]): Array[Int] = {
- if (xs.isEmpty) { return EMPTY_INT_ARRAY }
- val a = new Array[Int](xs.size); xs.copyToArray(a); a
- }
/*
* can-multi-thread
@@ -114,23 +108,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
}
/*
- * can-multi-thread
- */
- final def mkArrayReverse(xs: List[asm.Label]): Array[asm.Label] = {
- val len = xs.size
- if (len == 0) { return EMPTY_LABEL_ARRAY }
- val a = new Array[asm.Label](len)
- var i = len - 1
- var rest = xs
- while (!rest.isEmpty) {
- a(i) = rest.head
- rest = rest.tail
- i -= 1
- }
- a
- }
-
- /*
* The type of 1-dimensional arrays of `elem` type.
* The invoker is responsible for tracking (if needed) the inner class given by the elem BType.
*
@@ -141,20 +118,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
brefType("[" + elem.getDescriptor)
}
- /*
- * The type of N-dimensional arrays of `elem` type.
- * The invoker is responsible for tracking (if needed) the inner class given by the elem BType.
- *
- * must-single-thread
- */
- final def arrayN(elem: BType, dims: Int): BType = {
- assert(dims > 0)
- assert(!(elem.isUnitType) && !(elem.isPhantomType),
- "The element type of an array type is necessarily either a primitive type, or a class type, or an interface type.")
- val desc = ("[" * dims) + elem.getDescriptor
- brefType(desc)
- }
-
/* Just a namespace for utilities that encapsulate MethodVisitor idioms.
* In the ASM world, org.objectweb.asm.commons.InstructionAdapter plays a similar role,
* but the methods here allow choosing when to transition from ICode to ASM types
@@ -165,7 +128,7 @@ abstract class BCodeIdiomatic extends BCodeGlue {
def jmethod: asm.MethodVisitor
import asm.Opcodes;
- import icodes.opcodes.{ InvokeStyle, Static, Dynamic, SuperCall }
+ import icodes.opcodes.{ Static, Dynamic, SuperCall }
final def emit(opc: Int) { jmethod.visitInsn(opc) }
@@ -262,23 +225,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
/*
* can-multi-thread
*/
- final def genPrimitiveComparison(op: icodes.ComparisonOp, kind: BType) {
-
- import icodes.{ CMPL, CMP, CMPG }
-
- ((op, kind): @unchecked) match {
- case (CMP, LONG) => emit(Opcodes.LCMP)
- case (CMPL, FLOAT) => emit(Opcodes.FCMPL)
- case (CMPG, FLOAT) => emit(Opcodes.FCMPG)
- case (CMPL, DOUBLE) => emit(Opcodes.DCMPL)
- case (CMPG, DOUBLE) => emit(Opcodes.DCMPL) // http://docs.oracle.com/javase/specs/jvms/se5.0/html/Instructions2.doc3.html
- }
-
- } // end of method genPrimitiveComparison()
-
- /*
- * can-multi-thread
- */
final def genStartConcat {
jmethod.visitTypeInsn(Opcodes.NEW, StringBuilderClassName)
jmethod.visitInsn(Opcodes.DUP)
@@ -379,12 +325,6 @@ abstract class BCodeIdiomatic extends BCodeGlue {
} // end of emitT2T()
// can-multi-thread
- final def aconst(cst: AnyRef) {
- if (cst == null) { emit(Opcodes.ACONST_NULL) }
- else { jmethod.visitLdcInsn(cst) }
- }
-
- // can-multi-thread
final def boolconst(b: Boolean) { iconst(if (b) 1 else 0) }
// can-multi-thread
@@ -768,22 +708,8 @@ abstract class BCodeIdiomatic extends BCodeGlue {
}
}
- implicit class MethodIterClassNode(cnode: asm.tree.ClassNode) {
-
- @inline final def foreachMethod(f: (asm.tree.MethodNode) => Unit) { toMethodList.foreach(f) }
-
- @inline final def toMethodList: List[asm.tree.MethodNode] = { JListWrapper(cnode.methods).toList }
-
- @inline final def toFieldList: List[asm.tree.FieldNode] = { JListWrapper(cnode.fields).toList }
-
- }
-
implicit class InsnIterMethodNode(mnode: asm.tree.MethodNode) {
-
@inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit) { mnode.instructions.foreachInsn(f) }
-
- @inline final def toList: List[asm.tree.AbstractInsnNode] = { mnode.instructions.toList }
-
}
implicit class InsnIterInsnList(lst: asm.tree.InsnList) {
@@ -794,51 +720,5 @@ abstract class BCodeIdiomatic extends BCodeGlue {
f(insnIter.next())
}
}
-
- @inline final def toList: List[asm.tree.AbstractInsnNode] = {
- var result: List[asm.tree.AbstractInsnNode] = Nil
- lst foreachInsn { insn => if (insn != null) { result ::= insn } }
- result.reverse
- }
-
- }
-
- /*
- * Upon finding a name already seen among previous List elements, adds a numeric postfix to make it unique.
- */
- def uniquify(names: List[String]): List[String] = {
- val seen = mutable.Set.empty[String]
-
- @scala.annotation.tailrec def uniquified(current: String, attempt: Int): String = {
- if (seen contains current) {
- val currentBis = (current + "$" + attempt.toString)
- if (seen contains currentBis) {
- uniquified(current, attempt + 1)
- } else currentBis
- } else current
- }
-
- var rest = names
- var result: List[String] = Nil
- while (rest.nonEmpty) {
- val u = uniquified(rest.head.trim, 1)
- seen += u
- result ::= u
- rest = rest.tail
- }
-
- result.reverse
}
-
- def allDifferent[ElemType](xs: Iterable[ElemType]): Boolean = {
- val seen = mutable.Set.empty[ElemType]
- val iter = xs.iterator
- while (iter.hasNext) {
- val nxt = iter.next()
- if (seen contains nxt) { return false }
- seen += nxt
- }
- true
- }
-
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
index 8b6b4ab9ce..5fe03624cf 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSkelBuilder.scala
@@ -23,7 +23,6 @@ import scala.tools.asm
*/
abstract class BCodeSkelBuilder extends BCodeHelpers {
import global._
- import definitions._
/*
* There's a dedicated PlainClassBuilder for each CompilationUnit,
@@ -270,7 +269,6 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
var mnode: asm.tree.MethodNode = null
var jMethodName: String = null
var isMethSymStaticCtor = false
- var isMethSymBridge = false
var returnType: BType = null
var methSymbol: Symbol = null
// in GenASM this is local to genCode(), ie should get false whenever a new method is emitted (including fabricated ones eg addStaticInit())
@@ -553,7 +551,6 @@ abstract class BCodeSkelBuilder extends BCodeHelpers {
jMethodName = methSymbol.javaSimpleName.toString
returnType = asmMethodType(dd.symbol).getReturnType
isMethSymStaticCtor = methSymbol.isStaticConstructor
- isMethSymBridge = methSymbol.isBridge
resetMethodBookkeeping(dd)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala
index 439be77b31..27bcbb82d4 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeSyncAndTry.scala
@@ -386,9 +386,7 @@ abstract class BCodeSyncAndTry extends BCodeBodyBuilder {
/* Does this tree have a try-catch block? */
def mayCleanStack(tree: Tree): Boolean = tree exists { t => t.isInstanceOf[Try] }
- abstract class Cleanup(val value: AnyRef) {
- def contains(x: AnyRef) = value == x
- }
+ abstract class Cleanup(val value: AnyRef) { }
case class MonitorRelease(v: Symbol) extends Cleanup(v) { }
case class Finalizer(f: Tree) extends Cleanup (f) { }
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
index 542a90fa85..39fea9a486 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -24,19 +24,13 @@ abstract class BCodeTypes extends BCodeIdiomatic {
// when compiling the Scala library, some assertions don't hold (e.g., scala.Boolean has null superClass although it's not an interface)
val isCompilingStdLib = !(settings.sourcepath.isDefault)
- val srBoxedUnit = brefType("scala/runtime/BoxedUnit")
-
// special names
var StringReference : BType = null
var ThrowableReference : BType = null
var jlCloneableReference : BType = null // java/lang/Cloneable
- var jlNPEReference : BType = null // java/lang/NullPointerException
var jioSerializableReference : BType = null // java/io/Serializable
- var scalaSerializableReference : BType = null // scala/Serializable
var classCastExceptionReference : BType = null // java/lang/ClassCastException
- var lateClosureInterfaces: Array[Tracked] = null // the only interface a Late-Closure-Class implements is scala.Serializable
-
/* A map from scala primitive type-symbols to BTypes */
var primitiveTypeMap: Map[Symbol, BType] = null
/* A map from scala type-symbols for Nothing and Null to (runtime version) BTypes */
@@ -52,15 +46,12 @@ abstract class BCodeTypes extends BCodeIdiomatic {
var AndroidParcelableInterface: Symbol = null
var AndroidCreatorClass : Symbol = null // this is an inner class, use asmType() to get hold of its BType while tracking in innerClassBufferASM
- var androidCreatorType : BType = null
var BeanInfoAttr: Symbol = null
/* The Object => String overload. */
var String_valueOf: Symbol = null
- var ArrayInterfaces: Set[Tracked] = null
-
// scala.FunctionX and scala.runtim.AbstractFunctionX
val FunctionReference = new Array[Tracked](definitions.MaxFunctionArity + 1)
val AbstractFunctionReference = new Array[Tracked](definitions.MaxFunctionArity + 1)
@@ -75,7 +66,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
* must-single-thread
*/
def initBCodeTypes() {
-
import definitions._
primitiveTypeMap =
@@ -138,19 +128,17 @@ abstract class BCodeTypes extends BCodeIdiomatic {
)
}
- ArrayInterfaces = Set(JavaCloneableClass, JavaSerializableClass) map exemplar
+ exemplar(JavaCloneableClass).c
+ exemplar(JavaSerializableClass).c
+ exemplar(SerializableClass).c
StringReference = exemplar(StringClass).c
StringBuilderReference = exemplar(StringBuilderClass).c
ThrowableReference = exemplar(ThrowableClass).c
jlCloneableReference = exemplar(JavaCloneableClass).c
- jlNPEReference = exemplar(NullPointerExceptionClass).c
jioSerializableReference = exemplar(JavaSerializableClass).c
- scalaSerializableReference = exemplar(SerializableClass).c
classCastExceptionReference = exemplar(ClassCastExceptionClass).c
- lateClosureInterfaces = Array(exemplar(SerializableClass))
-
/*
* The bytecode emitter special-cases String concatenation, in that three methods of `JCodeMethodN`
* ( `genStartConcat()` , `genStringConcat()` , and `genEndConcat()` )
@@ -215,23 +203,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
* All methods of this class can-multi-thread
*/
case class Tracked(c: BType, flags: Int, sc: Tracked, ifaces: Array[Tracked], innersChain: Array[InnerClassEntry]) {
-
- // not a case-field because we initialize it only for JVM classes we emit.
- private var _directMemberClasses: List[BType] = null
-
- def directMemberClasses: List[BType] = {
- assert(_directMemberClasses != null, s"getter directMemberClasses() invoked too early for $c")
- _directMemberClasses
- }
-
- def directMemberClasses_=(bs: List[BType]) {
- if (_directMemberClasses != null) {
- // TODO we enter here when both mirror class and plain class are emitted for the same ModuleClassSymbol.
- assert(_directMemberClasses == bs.sortBy(_.off))
- }
- _directMemberClasses = bs.sortBy(_.off)
- }
-
/* `isCompilingStdLib` saves the day when compiling:
* (1) scala.Nothing (the test `c.isNonSpecial` fails for it)
* (2) scala.Boolean (it has null superClass and is not an interface)
@@ -246,23 +217,13 @@ abstract class BCodeTypes extends BCodeIdiomatic {
import asm.Opcodes._
def hasFlags(mask: Int) = (flags & mask) != 0
- def isPrivate = hasFlags(ACC_PRIVATE)
- def isPublic = hasFlags(ACC_PUBLIC)
- def isAbstract = hasFlags(ACC_ABSTRACT)
def isInterface = hasFlags(ACC_INTERFACE)
def isFinal = hasFlags(ACC_FINAL)
- def isSynthetic = hasFlags(ACC_SYNTHETIC)
- def isSuper = hasFlags(ACC_SUPER)
- def isDeprecated = hasFlags(ACC_DEPRECATED)
def isInnerClass = { innersChain != null }
- def isTraditionalClosureClass = {
- isInnerClass && isFinal && (c.getSimpleName.contains(tpnme.ANON_FUN_NAME.toString)) && isFunctionType(c)
- }
def isLambda = {
// ie isLCC || isTraditionalClosureClass
isFinal && (c.getSimpleName.contains(tpnme.ANON_FUN_NAME.toString)) && isFunctionType(c)
}
- def isSerializable = { isSubtypeOf(jioSerializableReference) }
/* can-multi-thread */
def superClasses: List[Tracked] = {
@@ -370,16 +331,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
minimizeInterfaces(superInterfaces)
}
- final def exemplarIfExisting(iname: String): Tracked = {
- val bt = lookupRefBTypeIfExisting(iname)
- if (bt != null) exemplars.get(bt)
- else null
- }
-
- final def lookupExemplar(iname: String) = {
- exemplars.get(lookupRefBType(iname))
- }
-
/*
* Records the superClass and supportedInterfaces relations,
* so that afterwards queries can be answered without resorting to typer.
@@ -419,10 +370,7 @@ abstract class BCodeTypes extends BCodeIdiomatic {
tr
}
- val EMPTY_TRACKED_SET = Set.empty[Tracked]
-
val EMPTY_TRACKED_ARRAY = Array.empty[Tracked]
- val EMPTY_InnerClassEntry_ARRAY = Array.empty[InnerClassEntry]
/*
* must-single-thread
@@ -461,12 +409,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
Tracked(key, flags, tsc, ifacesArr, innersChain)
}
- /* can-multi-thread */
- final def mkArray(xs: List[Tracked]): Array[Tracked] = {
- if (xs.isEmpty) { return EMPTY_TRACKED_ARRAY }
- val a = new Array[Tracked](xs.size); xs.copyToArray(a); a
- }
-
// ---------------- utilities around interfaces represented by Tracked instances. ----------------
/* Drop redundant interfaces (those which are implemented by some other).
@@ -497,21 +439,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
}
/*
- * Returns the intersection of two sets of interfaces.
- */
- def intersection(ifacesA: Set[Tracked], ifacesB: Set[Tracked]): Set[Tracked] = {
- var acc: Set[Tracked] = Set()
- for(ia <- ifacesA; ib <- ifacesB) {
- val ab = ia.supportedBranches(ib)
- val ba = ib.supportedBranches(ia)
- acc = minimizeInterfaces(acc ++ ab ++ ba)
- }
- checkAllInterfaces(acc)
-
- acc
- }
-
- /*
* Subtype check `a <:< b` on BTypes that takes into account the JVM built-in numeric promotions (e.g. BYTE to INT).
* Its operation can be visualized more easily in terms of the Java bytecode type hierarchy.
* This method used to be called, in the ICode world, TypeKind.<:<()
@@ -650,27 +577,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
}
/*
- * Whether the argument (the signature of a method) takes as argument
- * one ore more Function or PartialFunction (in particular an anonymous closure).
- *
- * can-multi-thread
- */
- final def isHigherOrderMethod(mtype: BType): Boolean = {
- assert(mtype.sort == BType.METHOD)
-
- val ats = mtype.getArgumentTypes
- var idx = 0
- while (idx < ats.length) {
- val t = ats(idx)
- if (isFunctionType(t) || isPartialFunctionType(t)) {
- return true
- }
- idx += 1
- }
- false
- }
-
- /*
* Whether the argument is a subtype of
* scala.PartialFunction[-A, +B] extends (A => B)
* N.B.: this method returns true for a scala.runtime.AbstractPartialFunction
@@ -682,16 +588,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
}
/*
- * Whether the argument is a subtype of
- * scala.runtime.AbstractPartialFunction[-T1, +R] extends Function1[T1, R] with PartialFunction[T1, R]
- *
- * can-multi-thread
- */
- def isAbstractPartialFunctionType(t: BType): Boolean = {
- (t.hasObjectSort) && exemplars.get(t).isSubtypeOf(AbstractPartialFunctionReference)
- }
-
- /*
* Whether the argument is a subtype of scala.FunctionX where 0 <= X <= definitions.MaxFunctionArity
*
* can-multi-thread
@@ -709,39 +605,6 @@ abstract class BCodeTypes extends BCodeIdiomatic {
false
}
- def isClosureClass(bt: BType): Boolean = {
- val tr = exemplars.get(bt); (tr != null && tr.isLambda)
- }
-
- /*
- * Whether the argument is a subtype of scala.runtime.AbstractFunctionX where 0 <= X <= definitions.MaxFunctionArity
- *
- * can-multi-thread
- */
- def isAbstractFunctionType(t: BType): Boolean = {
- if (!t.hasObjectSort) return false
- var idx = 0
- val et: Tracked = exemplars.get(t)
- while (idx <= definitions.MaxFunctionArity) {
- if (et.isSubtypeOf(AbstractFunctionReference(idx).c)) {
- return true
- }
- idx += 1
- }
- false
- }
-
- /*
- * For an argument of exactly one of the types
- * scala.runtime.AbstractFunctionX where 0 <= X <= definitions.MaxFunctionArity
- * returns the function arity, -1 otherwise.
- *
- * can-multi-thread
- */
- def abstractFunctionArity(t: BType): Int = {
- abstractFunctionArityMap.getOrElse(t, -1)
- }
-
/*
* must-single-thread
*/
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 181f4bde4e..fa424584b2 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -443,7 +443,6 @@ abstract class Inliners extends SubComponent {
case DontInlineHere(msg) => warnNoInline(msg)
case NeverSafeToInline => false
case InlineableAtThisCaller => true
- case inl @ FeasibleInline(_, _) if !inl.isSafe => false
case FeasibleInline(required, toPublicize) =>
for (f <- toPublicize) {
inlineLog("access", f, "making public")
@@ -738,16 +737,11 @@ abstract class Inliners extends SubComponent {
* - either log the reason for failure --- case (b) ---,
* - or perform inlining --- case (a) ---.
*/
- sealed abstract class InlineSafetyInfo {
- def isSafe = false
- }
+ sealed abstract class InlineSafetyInfo
case object NeverSafeToInline extends InlineSafetyInfo
- case object InlineableAtThisCaller extends InlineSafetyInfo { override def isSafe = true }
+ case object InlineableAtThisCaller extends InlineSafetyInfo
case class DontInlineHere(msg: String) extends InlineSafetyInfo
- case class FeasibleInline(accessNeeded: NonPublicRefs.Value,
- toBecomePublic: List[Symbol]) extends InlineSafetyInfo {
- override def isSafe = true
- }
+ case class FeasibleInline(accessNeeded: NonPublicRefs.Value, toBecomePublic: List[Symbol]) extends InlineSafetyInfo
case class AccessReq(
accessNeeded: NonPublicRefs.Value,