Skip to content

Commit 97ec2cb

Browse files
committed
Clean up CoreBTypes, consistent names and remove unused entries
1 parent 34261df commit 97ec2cb

8 files changed

+88
-122
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
431431
if (value.tag != UnitTag) (value.tag, expectedType) match {
432432
case (IntTag, LONG ) => bc.lconst(value.longValue); generatedType = LONG
433433
case (FloatTag, DOUBLE) => bc.dconst(value.doubleValue); generatedType = DOUBLE
434-
case (NullTag, _ ) => bc.emit(asm.Opcodes.ACONST_NULL); generatedType = RT_NULL
434+
case (NullTag, _ ) => bc.emit(asm.Opcodes.ACONST_NULL); generatedType = srNullRef
435435
case _ => genConstant(value); generatedType = tpeTK(tree)
436436
}
437437

@@ -490,7 +490,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
490490
val thrownType = expectedType
491491
// `throw null` is valid although scala.Null (as defined in src/libray-aux) isn't a subtype of Throwable.
492492
// Similarly for scala.Nothing (again, as defined in src/libray-aux).
493-
assert(thrownType.isNullType || thrownType.isNothingType || thrownType.asClassBType.isSubtypeOf(ThrowableReference))
493+
assert(thrownType.isNullType || thrownType.isNothingType || thrownType.asClassBType.isSubtypeOf(jlThrowableRef))
494494
emit(asm.Opcodes.ATHROW)
495495
end genAdaptAndSendToDest
496496

@@ -674,8 +674,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
674674
else if (l.isPrimitive) {
675675
bc drop l
676676
if (cast) {
677-
mnode.visitTypeInsn(asm.Opcodes.NEW, classCastExceptionReference.internalName)
678-
bc dup ObjectReference
677+
mnode.visitTypeInsn(asm.Opcodes.NEW, jlClassCastExceptionRef.internalName)
678+
bc dup ObjectRef
679679
emit(asm.Opcodes.ATHROW)
680680
} else {
681681
bc boolconst false
@@ -777,15 +777,15 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
777777
val nativeKind = tpeTK(expr)
778778
genLoad(expr, nativeKind)
779779
val MethodNameAndType(mname, methodType) = asmBoxTo(nativeKind)
780-
bc.invokestatic(BoxesRunTime.internalName, mname, methodType.descriptor, itf = false)
780+
bc.invokestatic(srBoxesRuntimeRef.internalName, mname, methodType.descriptor, itf = false)
781781
generatedType = boxResultType(fun.symbol) // was toTypeKind(fun.symbol.tpe.resultType)
782782

783783
case Apply(fun, List(expr)) if Erasure.Boxing.isUnbox(fun.symbol) && fun.symbol.denot.owner != defn.UnitModuleClass =>
784784
genLoad(expr)
785785
val boxType = unboxResultType(fun.symbol) // was toTypeKind(fun.symbol.owner.linkedClassOfClass.tpe)
786786
generatedType = boxType
787787
val MethodNameAndType(mname, methodType) = asmUnboxTo(boxType)
788-
bc.invokestatic(BoxesRunTime.internalName, mname, methodType.descriptor, itf = false)
788+
bc.invokestatic(srBoxesRuntimeRef.internalName, mname, methodType.descriptor, itf = false)
789789

790790
case app @ Apply(fun, args) =>
791791
val sym = fun.symbol
@@ -1237,7 +1237,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
12371237
liftStringConcat(tree) match {
12381238
// Optimization for expressions of the form "" + x
12391239
case List(Literal(Constant("")), arg) =>
1240-
genLoad(arg, ObjectReference)
1240+
genLoad(arg, ObjectRef)
12411241
genCallMethod(defn.String_valueOf_Object, InvokeStyle.Static)
12421242

12431243
case concatenations =>
@@ -1409,7 +1409,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
14091409

14101410
/* Generate the scala ## method. */
14111411
def genScalaHash(tree: Tree): BType = {
1412-
genLoad(tree, ObjectReference)
1412+
genLoad(tree, ObjectRef)
14131413
genCallMethod(NoSymbol, InvokeStyle.Static) // used to dispatch ## on primitives to ScalaRuntime.hash. Should be implemented by a miniphase
14141414
}
14151415

@@ -1508,8 +1508,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
15081508
val nonNullSide = if (ScalaPrimitivesOps.isReferenceEqualityOp(code)) ifOneIsNull(l, r) else null
15091509
if (nonNullSide != null) {
15101510
// special-case reference (in)equality test for null (null eq x, x eq null)
1511-
genLoad(nonNullSide, ObjectReference)
1512-
genCZJUMP(success, failure, op, ObjectReference, targetIfNoJump)
1511+
genLoad(nonNullSide, ObjectRef)
1512+
genCZJUMP(success, failure, op, ObjectRef, targetIfNoJump)
15131513
} else {
15141514
val tk = tpeTK(l).maxType(tpeTK(r))
15151515
genLoad(l, tk)
@@ -1627,42 +1627,42 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
16271627
} else defn.BoxesRunTimeModule_externalEquals
16281628
}
16291629

1630-
genLoad(l, ObjectReference)
1631-
genLoad(r, ObjectReference)
1630+
genLoad(l, ObjectRef)
1631+
genLoad(r, ObjectRef)
16321632
genCallMethod(equalsMethod, InvokeStyle.Static)
16331633
genCZJUMP(success, failure, Primitives.NE, BOOL, targetIfNoJump)
16341634
}
16351635
else {
16361636
if (isNull(l)) {
16371637
// null == expr -> expr eq null
1638-
genLoad(r, ObjectReference)
1639-
genCZJUMP(success, failure, Primitives.EQ, ObjectReference, targetIfNoJump)
1638+
genLoad(r, ObjectRef)
1639+
genCZJUMP(success, failure, Primitives.EQ, ObjectRef, targetIfNoJump)
16401640
} else if (isNull(r)) {
16411641
// expr == null -> expr eq null
1642-
genLoad(l, ObjectReference)
1643-
genCZJUMP(success, failure, Primitives.EQ, ObjectReference, targetIfNoJump)
1642+
genLoad(l, ObjectRef)
1643+
genCZJUMP(success, failure, Primitives.EQ, ObjectRef, targetIfNoJump)
16441644
} else if (isNonNullExpr(l)) {
16451645
// SI-7852 Avoid null check if L is statically non-null.
1646-
genLoad(l, ObjectReference)
1647-
genLoad(r, ObjectReference)
1646+
genLoad(l, ObjectRef)
1647+
genLoad(r, ObjectRef)
16481648
genCallMethod(defn.Any_equals, InvokeStyle.Virtual)
16491649
genCZJUMP(success, failure, Primitives.NE, BOOL, targetIfNoJump)
16501650
} else {
16511651
// l == r -> if (l eq null) r eq null else l.equals(r)
1652-
val eqEqTempLocal = locals.makeLocal(ObjectReference, nme.EQEQ_LOCAL_VAR.mangledString, defn.ObjectType, r.span)
1652+
val eqEqTempLocal = locals.makeLocal(ObjectRef, nme.EQEQ_LOCAL_VAR.mangledString, defn.ObjectType, r.span)
16531653
val lNull = new asm.Label
16541654
val lNonNull = new asm.Label
16551655

1656-
genLoad(l, ObjectReference)
1657-
genLoad(r, ObjectReference)
1656+
genLoad(l, ObjectRef)
1657+
genLoad(r, ObjectRef)
16581658
locals.store(eqEqTempLocal)
1659-
bc dup ObjectReference
1660-
genCZJUMP(lNull, lNonNull, Primitives.EQ, ObjectReference, targetIfNoJump = lNull)
1659+
bc dup ObjectRef
1660+
genCZJUMP(lNull, lNonNull, Primitives.EQ, ObjectRef, targetIfNoJump = lNull)
16611661

16621662
markProgramPoint(lNull)
1663-
bc drop ObjectReference
1663+
bc drop ObjectRef
16641664
locals.load(eqEqTempLocal)
1665-
genCZJUMP(success, failure, Primitives.EQ, ObjectReference, targetIfNoJump = lNonNull)
1665+
genCZJUMP(success, failure, Primitives.EQ, ObjectRef, targetIfNoJump = lNonNull)
16661666

16671667
markProgramPoint(lNonNull)
16681668
locals.load(eqEqTempLocal)

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
267267
final def getClassBTypeAndRegisterInnerClass(sym: Symbol): ClassBType = {
268268
assertClassNotArrayNotPrimitive(sym)
269269

270-
if (sym == defn.NothingClass) RT_NOTHING
271-
else if (sym == defn.NullClass) RT_NULL
270+
if (sym == defn.NothingClass) srNothingRef
271+
else if (sym == defn.NullClass) srNullRef
272272
else {
273273
val r = classBTypeFromSymbol(sym)
274274
if (r.isNestedClass) innerClassBufferASM += r
@@ -703,7 +703,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
703703
flags,
704704
mirrorName,
705705
null /* no java-generic-signature */,
706-
ObjectReference.internalName,
706+
ObjectRef.internalName,
707707
EMPTY_STRING_ARRAY
708708
)
709709

@@ -828,7 +828,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
828828
*/
829829
def nonClassTypeRefToBType(sym: Symbol): ClassBType = {
830830
assert(sym.isType && compilingArray, sym)
831-
ObjectReference.asInstanceOf[ct.bTypes.ClassBType]
831+
ObjectRef.asInstanceOf[ct.bTypes.ClassBType]
832832
}
833833

834834
tp.widenDealias match {
@@ -861,7 +861,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
861861
"If possible, please file a bug on https://github.com/lampepfl/dotty/issues")
862862

863863
tp match {
864-
case tp: ThisType if tp.cls == defn.ArrayClass => ObjectReference.asInstanceOf[ct.bTypes.ClassBType] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
864+
case tp: ThisType if tp.cls == defn.ArrayClass => ObjectRef.asInstanceOf[ct.bTypes.ClassBType] // was introduced in 9b17332f11 to fix SI-999, but this code is not reached in its test, or any other test
865865
case tp: ThisType => storage.getClassBTypeAndRegisterInnerClass(tp.cls)
866866
// case t: SingletonType => primitiveOrClassToBType(t.classSymbol)
867867
case t: SingletonType => typeToTypeKind(t.underlying)(ct)(storage)

compiler/src/dotty/tools/backend/jvm/BCodeIdiomatic.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ trait BCodeIdiomatic {
254254
case ct: ClassBType if ct.isSubtypeOf(jlCharSequenceRef) => jlCharSequenceRef
255255
// Don't match for `ArrayBType(CHAR)`, even though StringBuilder has such an overload:
256256
// `"a" + Array('b')` should NOT be "ab", but "a[C@...".
257-
case _: RefBType => ObjectReference
257+
case _: RefBType => ObjectRef
258258
// jlStringBuilder does not have overloads for byte and short, but we can just use the int version
259259
case BYTE | SHORT => INT
260260
case pt: PrimitiveBType => pt

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
255255
private def initJClass(jclass: asm.ClassVisitor): Unit = {
256256

257257
val ps = claszSymbol.info.parents
258-
val superClass: String = if (ps.isEmpty) ObjectReference.internalName else internalName(ps.head.typeSymbol)
258+
val superClass: String = if (ps.isEmpty) ObjectRef.internalName else internalName(ps.head.typeSymbol)
259259
val interfaceNames0 = classBTypeFromSymbol(claszSymbol).info.interfaces map {
260260
case classBType =>
261261
if (classBType.isNestedClass) { innerClassBufferASM += classBType }

compiler/src/dotty/tools/backend/jvm/BCodeSyncAndTry.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
3030

3131
def genSynchronized(tree: Apply, expectedType: BType): BType = (tree: @unchecked) match {
3232
case Apply(TypeApply(fun, _), args) =>
33-
val monitor = locals.makeLocal(ObjectReference, "monitor", defn.ObjectType, tree.span)
33+
val monitor = locals.makeLocal(ObjectRef, "monitor", defn.ObjectType, tree.span)
3434
val monCleanup = new asm.Label
3535

3636
// if the synchronized block returns a result, store it in a local variable.
@@ -40,7 +40,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
4040

4141
/* ------ (1) pushing and entering the monitor, also keeping a reference to it in a local var. ------ */
4242
genLoadQualifier(fun)
43-
bc dup ObjectReference
43+
bc dup ObjectRef
4444
locals.store(monitor)
4545
emit(asm.Opcodes.MONITORENTER)
4646

@@ -185,7 +185,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
185185
for (CaseDef(pat, _, caseBody) <- catches) yield {
186186
pat match {
187187
case Typed(Ident(nme.WILDCARD), tpt) => NamelessEH(tpeTK(tpt).asClassBType, caseBody)
188-
case Ident(nme.WILDCARD) => NamelessEH(ThrowableReference, caseBody)
188+
case Ident(nme.WILDCARD) => NamelessEH(jlThrowableRef, caseBody)
189189
case Bind(_, _) => BoundEH (pat.symbol, caseBody)
190190
}
191191
}
@@ -324,7 +324,7 @@ trait BCodeSyncAndTry extends BCodeBodyBuilder {
324324
nopIfNeeded(startTryBody)
325325
val finalHandler = currProgramPoint() // version of the finally-clause reached via unhandled exception.
326326
protect(startTryBody, finalHandler, finalHandler, null)
327-
val Local(eTK, _, eIdx, _) = locals(locals.makeLocal(ThrowableReference, "exc", defn.ThrowableType, finalizer.span))
327+
val Local(eTK, _, eIdx, _) = locals(locals.makeLocal(jlThrowableRef, "exc", defn.ThrowableType, finalizer.span))
328328
bc.store(eIdx, eTK)
329329
emitFinalizer(finalizer, null, isDuplicate = true)
330330
bc.load(eIdx, eTK)

compiler/src/dotty/tools/backend/jvm/BTypes.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ abstract class BTypes {
8989

9090
final def isNonVoidPrimitiveType = isPrimitive && this != UNIT
9191

92-
final def isNullType = this == RT_NULL
93-
final def isNothingType = this == RT_NOTHING
92+
final def isNullType = this == srNullRef
93+
final def isNothingType = this == srNothingRef
9494

9595
final def isBoxed = this.isClass && boxedClasses(this.asClassBType)
9696

@@ -113,7 +113,7 @@ abstract class BTypes {
113113

114114
this match {
115115
case ArrayBType(component) =>
116-
if (other == ObjectReference || other == jlCloneableReference || other == jioSerializableReference) true
116+
if (other == ObjectRef || other == jlCloneableRef || other == jiSerializableRef) true
117117
else other match {
118118
case ArrayBType(otherComponoent) => component.conformsTo(otherComponoent)
119119
case _ => false
@@ -122,7 +122,7 @@ abstract class BTypes {
122122
case classType: ClassBType =>
123123
if (isBoxed) {
124124
if (other.isBoxed) this == other
125-
else if (other == ObjectReference) true
125+
else if (other == ObjectRef) true
126126
else other match {
127127
case otherClassType: ClassBType => classType.isSubtypeOf(otherClassType) // e.g., java/lang/Double conforms to java/lang/Number
128128
case _ => false
@@ -165,7 +165,7 @@ abstract class BTypes {
165165

166166
assert(other.isRef, s"Cannot compute maxType: $this, $other")
167167
// Approximate `lub`. The common type of two references is always ObjectReference.
168-
ObjectReference
168+
ObjectRef
169169
}
170170

171171
/**
@@ -668,7 +668,7 @@ abstract class BTypes {
668668
if (this == other) return true
669669

670670
if (isInterface) {
671-
if (other == ObjectReference) return true // interfaces conform to Object
671+
if (other == ObjectRef) return true // interfaces conform to Object
672672
if (!other.isInterface) return false // this is an interface, the other is some class other than object. interfaces cannot extend classes, so the result is false.
673673
// else: this and other are both interfaces. continue to (*)
674674
} else {
@@ -698,13 +698,13 @@ abstract class BTypes {
698698
// exercised by test/files/run/t4761.scala
699699
if (other.isSubtypeOf(this)) this
700700
else if (this.isSubtypeOf(other)) other
701-
else ObjectReference
701+
else ObjectRef
702702

703703
case (true, false) =>
704-
if (other.isSubtypeOf(this)) this else ObjectReference
704+
if (other.isSubtypeOf(this)) this else ObjectRef
705705

706706
case (false, true) =>
707-
if (this.isSubtypeOf(other)) other else ObjectReference
707+
if (this.isSubtypeOf(other)) other else ObjectRef
708708

709709
case _ =>
710710
// TODO @lry I don't really understand the reasoning here.

0 commit comments

Comments
 (0)