Skip to content

Commit 5c2a2f7

Browse files
retronymlrytz
authored andcommitted
SD-142 Avoid noisy log output in backend (scala#5134)
`withCurrentUnit` is designed to be called once per compilation unit as it side effects by logging and updating progress counters. `GenBCode` was calling it more frequently (once per `ClassDef`.) This is due to the somewhat convoluted internal architecture of that phase, which is designed to support paralellism in the future. This commit factors out the internal part of `withCompilationUnit` that modifies `currentUnit`, and calls that instead in the loop over classes. After this change: ``` % qscala -Ydebug ... [running phase jvm on <console>] // only once ```
1 parent 0db65ea commit 5c2a2f7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,18 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
394394

395395
if (settings.debug && (settings.verbose || currentRun.size < 5))
396396
inform("[running phase " + name + " on " + unit + "]")
397+
if (!cancelled(unit)) {
398+
currentRun.informUnitStarting(this, unit)
399+
try withCurrentUnitNoLog(unit)(task)
400+
finally currentRun.advanceUnit()
401+
}
402+
}
397403

404+
final def withCurrentUnitNoLog(unit: CompilationUnit)(task: => Unit) {
398405
val unit0 = currentUnit
399406
try {
400407
currentRun.currentUnit = unit
401-
if (!cancelled(unit)) {
402-
currentRun.informUnitStarting(this, unit)
403-
task
404-
}
405-
currentRun.advanceUnit()
408+
task
406409
} finally {
407410
//assert(currentUnit == unit)
408411
currentRun.currentUnit = unit0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ abstract class GenBCode extends BCodeSyncAndTry {
135135
return
136136
}
137137
else {
138-
try { withCurrentUnit(item.cunit)(visit(item)) }
138+
try { withCurrentUnitNoLog(item.cunit)(visit(item)) }
139139
catch {
140140
case ex: Throwable =>
141141
ex.printStackTrace()

0 commit comments

Comments
 (0)