Skip to content
Browse files

there's a reason for this code in GenBCode

aced32d removed unused code,
along with code that populates a cache with entries needed
in some program runs. I'm re-adding the latter.
  • Loading branch information...
1 parent 7ee1a83 commit 6eed8d00a5e8624635e0e9a4c71890a5bf41aca2 @magarciaEPFL magarciaEPFL committed Dec 3, 2013
View
8 src/compiler/scala/tools/nsc/backend/jvm/BCodeGlue.scala
@@ -661,6 +661,14 @@ 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
View
4 src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala
@@ -561,7 +561,9 @@ abstract class BCodeHelpers extends BCodeTypes with BytecodeWriters {
memberCTK
}
- exemplar(csym) // side effect city
+
+ exemplar(csym).directMemberClasses = result
+
result
}
View
1 src/compiler/scala/tools/nsc/backend/jvm/BCodeIdiomatic.scala
@@ -46,6 +46,7 @@ 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")
View
31 src/compiler/scala/tools/nsc/backend/jvm/BCodeTypes.scala
@@ -24,11 +24,15 @@ 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
/* A map from scala primitive type-symbols to BTypes */
@@ -52,6 +56,8 @@ abstract class BCodeTypes extends BCodeIdiomatic {
/* 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)
@@ -128,15 +134,17 @@ abstract class BCodeTypes extends BCodeIdiomatic {
)
}
- exemplar(JavaCloneableClass).c
- exemplar(JavaSerializableClass).c
- exemplar(SerializableClass).c
+ exemplar(JavaCloneableClass)
+ exemplar(JavaSerializableClass)
+ exemplar(SerializableClass)
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
/*
@@ -203,6 +211,23 @@ 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)

0 comments on commit 6eed8d0

Please sign in to comment.
Something went wrong with that request. Please try again.