Skip to content

Commit

Permalink
Workaround changes to runId starting with 1 instead of 2 due to probl…
Browse files Browse the repository at this point in the history
…ems with scala2-library-bootstrapped compilation
  • Loading branch information
WojciechMazur committed Apr 9, 2024
1 parent 32f9342 commit 880e2a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ class Compiler {
List(new GenBCode) :: // Generate JVM bytecode
Nil

// Initially 0, so that the first nextRunId call would return InitialRunId == 1
private var runId: Int = 0
// TODO: Initially 0, so that the first nextRunId call would return InitialRunId == 1
// Changing the initial runId from 1 to 0 makes the scala2-library-bootstrap fail to compile,
// when the underlying issue is fixed, please update dotc.profiler.RealProfiler.chromeTrace logic
private var runId: Int = 1
def nextRunId: Int = {
runId += 1; runId
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ private [profile] class RealProfiler(reporter : ProfileReporter)(using Context)
// Compilation units requiring multi-stage compilation (macros) would create a new profiler instances
// We need to store the traces in the seperate file to prevent overriding its content.
// Alternatives: sharing ChromeTrace instance between all runs / manual concatation after all runs are done
val suffix = if ctx.runId > InitialRunId then s".${ctx.runId}" else ""
// FIXME: The first assigned runId is equal to 2 instead of 1 (InitialRunId).
// Fix me when bug described in Compiler.runId is resolved by removing +/- 1 adjustments
val suffix = if ctx.runId > InitialRunId + 1 then s".${ctx.runId - 1}" else ""
ChromeTrace(Paths.get(s"$filename$suffix"))

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

def completeBackground(threadRange: ProfileRange): Unit =
reporter.reportBackground(this, threadRange)
Expand Down

0 comments on commit 880e2a7

Please sign in to comment.