Skip to content

Commit c81e5e7

Browse files
committed
Workaround changes to runId starting with 1 instead of 2 due to problems with scala2-library-bootstrapped compilation
1 parent e9c1f8c commit c81e5e7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: compiler/src/dotty/tools/dotc/Compiler.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ class Compiler {
151151
List(new GenBCode) :: // Generate JVM bytecode
152152
Nil
153153

154-
// Initially 0, so that the first nextRunId call would return InitialRunId == 1
155-
private var runId: Int = 0
154+
// TODO: Initially 0, so that the first nextRunId call would return InitialRunId == 1
155+
// Changing the initial runId from 1 to 0 makes the scala2-library-bootstrap fail to compile,
156+
// when the underlying issue is fixed, please update dotc.profiler.RealProfiler.chromeTrace logic
157+
private var runId: Int = 1
156158
def nextRunId: Int = {
157159
runId += 1; runId
158160
}

Diff for: compiler/src/dotty/tools/dotc/profile/Profiler.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,12 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)
185185
// Compilation units requiring multi-stage compilation (macros) would create a new profiler instances
186186
// We need to store the traces in the seperate file to prevent overriding its content.
187187
// Alternatives: sharing ChromeTrace instance between all runs / manual concatation after all runs are done
188-
val suffix = if ctx.runId > InitialRunId then s".${ctx.runId}" else ""
188+
// FIXME: The first assigned runId is equal to 2 instead of 1 (InitialRunId).
189+
// Fix me when bug described in Compiler.runId is resolved by removing +/- 1 adjustments
190+
val suffix = if ctx.runId > InitialRunId + 1 then s".${ctx.runId - 1}" else ""
189191
ChromeTrace(Paths.get(s"$filename$suffix"))
190192

191-
private val compilerRunEvent: TracedEventId = traceDurationStart(Category.Run, s"stage-${ctx.runId}")
193+
private val compilerRunEvent: TracedEventId = traceDurationStart(Category.Run, s"scalac-$id")
192194

193195
def completeBackground(threadRange: ProfileRange): Unit =
194196
reporter.reportBackground(this, threadRange)

0 commit comments

Comments
 (0)