diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-05-16 22:44:52 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-05-21 22:52:35 +0200 |
commit | 0f2bf1db09455e019b99c21580afc87beab57d44 (patch) | |
tree | 7c6937de0912ffec09a2181de5b4e814f12ee3a0 | |
parent | d190139373ef265b62f6ca499a1bc360b5fc0e8a (diff) | |
download | scala-0f2bf1db09455e019b99c21580afc87beab57d44.tar.gz scala-0f2bf1db09455e019b99c21580afc87beab57d44.tar.bz2 scala-0f2bf1db09455e019b99c21580afc87beab57d44.zip |
More cleanups and commenting in GenBCode
3 files changed, 20 insertions, 35 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala index 880b047905..4eecb48473 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala @@ -653,7 +653,7 @@ abstract class BCodeGlue extends SubComponent { * * can-multi-thread */ - def brefType(iname: TypeName): BType = { BType.getObjectType(iname.start, iname.length) } + def brefType(iname: TypeName): BType = BType.getObjectType(iname.start, iname.length) // due to keyboard economy only val UNIT = BType.VOID_TYPE diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index 3fdb38ce0e..d1684a91e6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -77,11 +77,12 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { */ final class CClassWriter(flags: Int) extends asm.ClassWriter(flags) { - /* - * This method is thread re-entrant because chrs never grows during its operation (that's because all TypeNames being looked up have already been entered). - * To stress this point, rather than using `newTypeName()` we use `lookupTypeName()` + /** + * This method is thread re-entrant because chrs never grows during its operation (that's + * because all TypeNames being looked up have already been entered). + * To stress this point, rather than using `newTypeName()` we use `lookupTypeName()` * - * can-multi-thread + * can-multi-thread */ override def getCommonSuperClass(inameA: String, inameB: String): String = { val a = brefType(lookupTypeName(inameA.toCharArray)) @@ -95,14 +96,15 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { } - /* - * Finding the least upper bound in agreement with the bytecode verifier (given two internal names handed out by ASM) - * Background: - * http://gallium.inria.fr/~xleroy/publi/bytecode-verification-JAR.pdf - * http://comments.gmane.org/gmane.comp.java.vm.languages/2293 - * https://issues.scala-lang.org/browse/SI-3872 + /** + * Finding the least upper bound in agreement with the bytecode verifier (given two internal names + * handed out by ASM) + * Background: + * http://gallium.inria.fr/~xleroy/publi/bytecode-verification-JAR.pdf + * http://comments.gmane.org/gmane.comp.java.vm.languages/2293 + * https://issues.scala-lang.org/browse/SI-3872 * - * can-multi-thread + * can-multi-thread */ def jvmWiseLUB(a: BType, b: BType): BType = { @@ -401,7 +403,7 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters { * * must-single-thread */ - final def internalName(sym: Symbol): String = { asmClassType(sym).getInternalName } + final def internalName(sym: Symbol): String = asmClassType(sym).getInternalName /* * Tracks (if needed) the inner class given by `sym`. diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala index 1eca69936a..a158fdd570 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala @@ -24,8 +24,6 @@ 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 @@ -350,8 +348,8 @@ abstract class BCodeTypes extends BCodeIdiomatic { val superInterfaces0: List[Symbol] = csym.mixinClasses val superInterfaces = existingSymbols(superInterfaces0 ++ csym.annotations.map(newParentForAttr)).distinct - assert(!superInterfaces.contains(NoSymbol), s"found NoSymbol among: ${superInterfaces.mkString}") - assert(superInterfaces.forall(s => s.isInterface || s.isTrait), s"found non-interface among: ${superInterfaces.mkString}") + assert(!superInterfaces.contains(NoSymbol), s"found NoSymbol among: ${superInterfaces.mkString(", ")}") + assert(superInterfaces.forall(s => s.isInterface || s.isTrait), s"found non-interface among: ${superInterfaces.mkString(", ")}") minimizeInterfaces(superInterfaces) } @@ -395,8 +393,6 @@ abstract class BCodeTypes extends BCodeIdiomatic { tr } - val EMPTY_TRACKED_ARRAY = Array.empty[Tracked] - /* * must-single-thread */ @@ -413,14 +409,7 @@ abstract class BCodeTypes extends BCodeIdiomatic { ((sc != NoSymbol) && !sc.isInterface) || isCompilingStdLib, "superClass out of order" ) - val ifaces = getSuperInterfaces(csym) map exemplar; - val ifacesArr = - if (ifaces.isEmpty) EMPTY_TRACKED_ARRAY - else { - val arr = new Array[Tracked](ifaces.size) - ifaces.copyToArray(arr) - arr - } + val ifacesArr = getSuperInterfaces(csym).map(exemplar).toArray val flags = mkFlags( javaFlags(csym), @@ -724,14 +713,8 @@ abstract class BCodeTypes extends BCodeIdiomatic { } } - // now that we have all of `ics` , `csym` , and soon the inner-classes-chain, it's too tempting not to cache. - if (chain.isEmpty) { null } - else { - val arr = new Array[InnerClassEntry](chain.size) - (chain map toInnerClassEntry).copyToArray(arr) - - arr - } + if (chain.isEmpty) null + else chain.map(toInnerClassEntry).toArray } /* |