Skip to content

Commit b0cfccc

Browse files
committed
Generate DottyPrimitives only once
1 parent 84f7a77 commit b0cfccc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
3939
import coreBTypes._
4040
import BCodeBodyBuilder._
4141

42-
private val primitives = new DottyPrimitives(ctx)
42+
protected val primitives: DottyPrimitives
4343

4444
/*
4545
* Functionality to build the body of ASM MethodNode, except for `synchronized` and `try` expressions.

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ class GenBCode extends Phase {
5050
myOutput
5151
}
5252

53+
private var myPrimitives: DottyPrimitives = null
54+
5355
def run(using Context): Unit =
54-
GenBCodePipeline(
55-
DottyBackendInterface(outputDir, superCallsMap)
56+
if myPrimitives == null then myPrimitives = new DottyPrimitives(ctx)
57+
new GenBCodePipeline(
58+
DottyBackendInterface(outputDir, superCallsMap),
59+
myPrimitives
5660
).run(ctx.compilationUnit.tpdTree)
5761

5862

@@ -74,7 +78,7 @@ object GenBCode {
7478
val name: String = "genBCode"
7579
}
7680

77-
class GenBCodePipeline(val int: DottyBackendInterface)(using Context) extends BCodeSyncAndTry {
81+
class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrimitives)(using Context) extends BCodeSyncAndTry {
7882
import DottyBackendInterface.symExtensions
7983

8084
private var tree: Tree = _

0 commit comments

Comments
 (0)