summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-08-12 16:12:15 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-08-19 17:50:02 +0200
commitf73f026bf250e6eb3c22c2b1975d4fdc2f23eab6 (patch)
treeb1d49a853c90740c6e4b15b0c8365c72b702970d /src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
parentbdc3ff97e7f869b393de7e4deb53535a93738ad1 (diff)
downloadscala-f73f026bf250e6eb3c22c2b1975d4fdc2f23eab6.tar.gz
scala-f73f026bf250e6eb3c22c2b1975d4fdc2f23eab6.tar.bz2
scala-f73f026bf250e6eb3c22c2b1975d4fdc2f23eab6.zip
Remove Tracked, add type information to ClassBType
Before this change, a ClassBType was just a name. The `exemplars` map stored a Tracked instance for every ClassBType. Tracked stored type information that is required later in the backend when things may run concurrently. In particular: superclass, interfaces, flags and information for emitting the InnerClass attribute. Now we put all the information stored in Tracked directly in the ClassBType. There is still one hash map: `classBTypeFromInternalNameMap` maps a JVM internal class name (e.g. "scala/Predef$") to the corresponding ClassBType. This map is used during bytecode generation, when the ASM framework computes stack map frames. In order to compute stack map frames, the ASM framework needs to be able to get the LUB of two types. The default implementation uses reflection to get type information, however that doesn't work in our case: the classes we compile are not on the classpath. So instead, the backend overwrites the method `getCommonSuperClass` of the ClassWriter. This method receives two class internal names and computes their LUB. This is done by looking up the ClassBTypes in the `classBTypeFromInternalNameMap` and invoking `jvmWiseLUB`. This commit was reviwed in https://github.com/scala/scala/pull/3855. It consists of all commits labelled [squash-after-review], squashed into one.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
index 5494a827f4..480767f407 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
@@ -46,6 +46,8 @@ import scala.tools.asm
abstract class GenBCode extends BCodeSyncAndTry {
import global._
+ import bTypes._
+
val phaseName = "jvm"
override def newPhase(prev: Phase) = new BCodePhase(prev)
@@ -272,7 +274,7 @@ abstract class GenBCode extends BCodeSyncAndTry {
arrivalPos = 0 // just in case
scalaPrimitives.init()
- initBCodeTypes()
+ bTypes.intializeCoreBTypes()
// initBytecodeWriter invokes fullName, thus we have to run it before the typer-dependent thread is activated.
bytecodeWriter = initBytecodeWriter(cleanup.getEntryPoints)
@@ -297,9 +299,6 @@ abstract class GenBCode extends BCodeSyncAndTry {
* (2) if requested, check-java-signatures, over and beyond the syntactic checks in `getGenericSignature()`
*
*/
-
- // clearing maps
- clearBCodeTypes()
}
/*
@@ -385,3 +384,10 @@ abstract class GenBCode extends BCodeSyncAndTry {
} // end of class BCodePhase
} // end of class GenBCode
+
+object GenBCode {
+ def mkFlags(args: Int*) = args.foldLeft(0)(_ | _)
+
+ final val PublicStatic = asm.Opcodes.ACC_PUBLIC | asm.Opcodes.ACC_STATIC
+ final val PublicStaticFinal = asm.Opcodes.ACC_PUBLIC | asm.Opcodes.ACC_STATIC | asm.Opcodes.ACC_FINAL
+}