Skip to content

Commit b735803

Browse files
authored
Merge pull request #13989 from dotty-staging/use-inline-val-in-compiler
Use `inline val` for inlined `final val`s
2 parents 1eeb4fb + eba5290 commit b735803

30 files changed

+901
-901
lines changed

compiler/src/dotty/tools/backend/ScalaPrimitivesOps.scala

Lines changed: 131 additions & 131 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ object AsmUtils {
1919
/**
2020
* Print the bytecode of classes generated by GenBCode to the standard output.
2121
*/
22-
final val traceClassEnabled = false
23-
final val traceClassPattern = ""
22+
inline val traceClassEnabled = false
23+
inline val traceClassPattern = ""
2424

2525
/**
2626
* Print the bytedcode of classes as they are serialized by the ASM library. The serialization
2727
* performed by `asm.ClassWriter` can change the code generated by GenBCode. For example, it
2828
* introduces stack map frames, it computes the maximal stack sizes, and it replaces dead
2929
* code by NOPs (see also https://github.com/scala/scala/pull/3726#issuecomment-42861780).
3030
*/
31-
final val traceSerializedClassEnabled = false
32-
final val traceSerializedClassPattern = ""
31+
inline val traceSerializedClassEnabled = false
32+
inline val traceSerializedClassPattern = ""
3333

3434
def traceMethod(mnode: MethodNode1): Unit = {
3535
println(s"Bytecode for method ${mnode.name}")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
7070
with BCJGenSigGen {
7171

7272
// Strangely I can't find this in the asm code 255, but reserving 1 for "this"
73-
final val MaximumJvmParameters = 254
73+
inline val MaximumJvmParameters = 254
7474

7575
// current class
7676
var cnode: ClassNode1 = null

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4369,7 +4369,7 @@ class JSCodeGen()(using genCtx: Context) {
43694369
js.LoadJSConstructor(encodeClassName(sym))
43704370
}
43714371

4372-
private final val GenericGlobalObjectInformationMsg = {
4372+
private inline val GenericGlobalObjectInformationMsg = {
43734373
"\n " +
43744374
"See https://www.scala-js.org/doc/interoperability/global-scope.html " +
43754375
"for further information."

compiler/src/dotty/tools/backend/sjs/JSPrimitives.scala

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,42 @@ import scala.collection.mutable
1616

1717
object JSPrimitives {
1818

19-
final val FirstJSPrimitiveCode = 300
19+
inline val FirstJSPrimitiveCode = 300
2020

21-
final val DYNNEW = FirstJSPrimitiveCode + 1 // Instantiate a new JavaScript object
21+
inline val DYNNEW = FirstJSPrimitiveCode + 1 // Instantiate a new JavaScript object
2222

23-
final val ARR_CREATE = DYNNEW + 1 // js.Array.apply (array literal syntax)
23+
inline val ARR_CREATE = DYNNEW + 1 // js.Array.apply (array literal syntax)
2424

25-
final val TYPEOF = ARR_CREATE + 1 // typeof x
26-
final val JS_NATIVE = TYPEOF + 1 // js.native. Marker method. Fails if tried to be emitted.
25+
inline val TYPEOF = ARR_CREATE + 1 // typeof x
26+
inline val JS_NATIVE = TYPEOF + 1 // js.native. Marker method. Fails if tried to be emitted.
2727

28-
final val UNITVAL = JS_NATIVE + 1 // () value, which is undefined
28+
inline val UNITVAL = JS_NATIVE + 1 // () value, which is undefined
2929

30-
final val JS_IMPORT = UNITVAL + 1 // js.import.apply(specifier)
31-
final val JS_IMPORT_META = JS_IMPORT + 1 // js.import.meta
30+
inline val JS_IMPORT = UNITVAL + 1 // js.import.apply(specifier)
31+
inline val JS_IMPORT_META = JS_IMPORT + 1 // js.import.meta
3232

33-
final val CONSTRUCTOROF = JS_IMPORT_META + 1 // runtime.constructorOf(clazz)
34-
final val CREATE_INNER_JS_CLASS = CONSTRUCTOROF + 1 // runtime.createInnerJSClass
35-
final val CREATE_LOCAL_JS_CLASS = CREATE_INNER_JS_CLASS + 1 // runtime.createLocalJSClass
36-
final val WITH_CONTEXTUAL_JS_CLASS_VALUE = CREATE_LOCAL_JS_CLASS + 1 // runtime.withContextualJSClassValue
37-
final val LINKING_INFO = WITH_CONTEXTUAL_JS_CLASS_VALUE + 1 // runtime.linkingInfo
33+
inline val CONSTRUCTOROF = JS_IMPORT_META + 1 // runtime.constructorOf(clazz)
34+
inline val CREATE_INNER_JS_CLASS = CONSTRUCTOROF + 1 // runtime.createInnerJSClass
35+
inline val CREATE_LOCAL_JS_CLASS = CREATE_INNER_JS_CLASS + 1 // runtime.createLocalJSClass
36+
inline val WITH_CONTEXTUAL_JS_CLASS_VALUE = CREATE_LOCAL_JS_CLASS + 1 // runtime.withContextualJSClassValue
37+
inline val LINKING_INFO = WITH_CONTEXTUAL_JS_CLASS_VALUE + 1 // runtime.linkingInfo
3838

39-
final val STRICT_EQ = LINKING_INFO + 1 // js.special.strictEquals
40-
final val IN = STRICT_EQ + 1 // js.special.in
41-
final val INSTANCEOF = IN + 1 // js.special.instanceof
42-
final val DELETE = INSTANCEOF + 1 // js.special.delete
43-
final val FORIN = DELETE + 1 // js.special.forin
44-
final val DEBUGGER = FORIN + 1 // js.special.debugger
39+
inline val STRICT_EQ = LINKING_INFO + 1 // js.special.strictEquals
40+
inline val IN = STRICT_EQ + 1 // js.special.in
41+
inline val INSTANCEOF = IN + 1 // js.special.instanceof
42+
inline val DELETE = INSTANCEOF + 1 // js.special.delete
43+
inline val FORIN = DELETE + 1 // js.special.forin
44+
inline val DEBUGGER = FORIN + 1 // js.special.debugger
4545

46-
final val THROW = DEBUGGER + 1
46+
inline val THROW = DEBUGGER + 1
4747

48-
final val UNION_FROM = THROW + 1 // js.|.from
49-
final val UNION_FROM_TYPE_CONSTRUCTOR = UNION_FROM + 1 // js.|.fromTypeConstructor
48+
inline val UNION_FROM = THROW + 1 // js.|.from
49+
inline val UNION_FROM_TYPE_CONSTRUCTOR = UNION_FROM + 1 // js.|.fromTypeConstructor
5050

51-
final val REFLECT_SELECTABLE_SELECTDYN = UNION_FROM_TYPE_CONSTRUCTOR + 1 // scala.reflect.Selectable.selectDynamic
52-
final val REFLECT_SELECTABLE_APPLYDYN = REFLECT_SELECTABLE_SELECTDYN + 1 // scala.reflect.Selectable.applyDynamic
51+
inline val REFLECT_SELECTABLE_SELECTDYN = UNION_FROM_TYPE_CONSTRUCTOR + 1 // scala.reflect.Selectable.selectDynamic
52+
inline val REFLECT_SELECTABLE_APPLYDYN = REFLECT_SELECTABLE_SELECTDYN + 1 // scala.reflect.Selectable.applyDynamic
5353

54-
final val LastJSPrimitiveCode = REFLECT_SELECTABLE_APPLYDYN
54+
inline val LastJSPrimitiveCode = REFLECT_SELECTABLE_APPLYDYN
5555

5656
def isJSPrimitive(code: Int): Boolean =
5757
code >= FirstJSPrimitiveCode && code <= LastJSPrimitiveCode

compiler/src/dotty/tools/dotc/core/Constants.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import Decorators._
99

1010
object Constants {
1111

12-
final val NoTag = 0
13-
final val UnitTag = 1
14-
final val BooleanTag = 2
15-
final val ByteTag = 3
16-
final val ShortTag = 4
17-
final val CharTag = 5
18-
final val IntTag = 6
19-
final val LongTag = 7
20-
final val FloatTag = 8
21-
final val DoubleTag = 9
22-
final val StringTag = 10
23-
final val NullTag = 11
24-
final val ClazzTag = 12
12+
inline val NoTag = 0
13+
inline val UnitTag = 1
14+
inline val BooleanTag = 2
15+
inline val ByteTag = 3
16+
inline val ShortTag = 4
17+
inline val CharTag = 5
18+
inline val IntTag = 6
19+
inline val LongTag = 7
20+
inline val FloatTag = 8
21+
inline val DoubleTag = 9
22+
inline val StringTag = 10
23+
inline val NullTag = 11
24+
inline val ClazzTag = 12
2525

2626
class Constant(val value: Any, val tag: Int) extends printing.Showable with Product1[Any] {
2727
import java.lang.Double.doubleToRawLongBits

compiler/src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object Decorators {
7474
NoSymbol
7575
}
7676

77-
final val MaxFilterRecursions = 10
77+
inline val MaxFilterRecursions = 10
7878

7979
/** Implements filterConserve, zipWithConserve methods
8080
* on lists that avoid duplication of list nodes where feasible.

compiler/src/dotty/tools/dotc/core/Hashable.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ object Hashable {
1919
/** A hash value indicating that the underlying type is not
2020
* cached in uniques.
2121
*/
22-
final val NotCached = 0
22+
inline val NotCached = 0
2323

2424
/** An alternative value returned from `hash` if the
2525
* computed hashCode would be `NotCached`.
2626
*/
27-
private[core] final val NotCachedAlt = Int.MinValue
27+
private[core] inline val NotCachedAlt = Int.MinValue
2828

2929
/** A value that indicates that the hash code is unknown
3030
*/
31-
private[core] final val HashUnknown = 1234
31+
private[core] inline val HashUnknown = 1234
3232

3333
/** An alternative value if computeHash would otherwise yield HashUnknown
3434
*/
35-
private[core] final val HashUnknownAlt = 4321
35+
private[core] inline val HashUnknownAlt = 4321
3636
}
3737

3838
trait Hashable {

compiler/src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object NameOps {
1717
object compactify {
1818
lazy val md5: MessageDigest = MessageDigest.getInstance("MD5")
1919

20-
final val CLASSFILE_NAME_CHAR_LIMIT = 240
20+
inline val CLASSFILE_NAME_CHAR_LIMIT = 240
2121

2222
/** COMPACTIFY
2323
*

compiler/src/dotty/tools/dotc/core/NameTags.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ import dotty.tools.tasty.TastyFormat
55
/** The possible tags of a NameKind */
66
object NameTags extends TastyFormat.NameTags {
77

8-
final val FLATTENED = 5 // A flat name, generated by Flatten
8+
inline val FLATTENED = 5 // A flat name, generated by Flatten
99

10-
final val TRAITSETTER = 6 // A Scala-2 trait setter, generated by AugmentScala2Traits
10+
inline val TRAITSETTER = 6 // A Scala-2 trait setter, generated by AugmentScala2Traits
1111

12-
final val OUTERSELECT = 13 // A name `<num>_outer`, used by the inliner to indicate an
12+
inline val OUTERSELECT = 13 // A name `<num>_outer`, used by the inliner to indicate an
1313
// outer accessor that will be filled in by ExplicitOuter.
1414
// <num> indicates the number of hops needed to select the outer field.
1515

16-
final val PROTECTEDACCESSOR = 24 // The name of a protected accesor `protected$<name>` created by ProtectedAccessors.
16+
inline val PROTECTEDACCESSOR = 24 // The name of a protected accesor `protected$<name>` created by ProtectedAccessors.
1717

18-
final val INITIALIZER = 26 // A mixin initializer method
18+
inline val INITIALIZER = 26 // A mixin initializer method
1919

20-
final val FIELD = 29 // Used by Memoize to tag the name of a class member field.
20+
inline val FIELD = 29 // Used by Memoize to tag the name of a class member field.
2121

22-
final val EXTMETH = 30 // Used by ExtensionMethods for the name of an extension method
22+
inline val EXTMETH = 30 // Used by ExtensionMethods for the name of an extension method
2323
// implementing a value class method.
2424

25-
final val ADAPTEDCLOSURE = 31 // Used in Erasure to adapt closures over primitive types.
25+
inline val ADAPTEDCLOSURE = 31 // Used in Erasure to adapt closures over primitive types.
2626

27-
final val DIRECT = 32 // Used to define implementations of methods with
27+
inline val DIRECT = 32 // Used to define implementations of methods with
2828
// erased context function results that can override some
2929
// other method.
3030

31-
final val PARAMACC = 33 // Used for a private parameter alias
31+
inline val PARAMACC = 33 // Used for a private parameter alias
3232

33-
final val SETTER = 34 // A synthesized += suffix.
33+
inline val SETTER = 34 // A synthesized += suffix.
3434

3535
def nameTagToString(tag: Int): String = tag match {
3636
case UTF8 => "UTF8"

0 commit comments

Comments
 (0)