summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-05-02 20:20:53 +1000
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-02 12:20:53 +0200
commit5c2a2f725dccd0c4616a042e29c5b9e95d004192 (patch)
tree3d22127f800562a9ec8e733fb1614e4252381904
parent0db65ea0c4805cfa501c8300547aef318256dbf9 (diff)
downloadscala-5c2a2f725dccd0c4616a042e29c5b9e95d004192.tar.gz
scala-5c2a2f725dccd0c4616a042e29c5b9e95d004192.tar.bz2
scala-5c2a2f725dccd0c4616a042e29c5b9e95d004192.zip
SD-142 Avoid noisy log output in backend (#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 ```
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala13
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 847c4cb2d1..94a6a0e4e2 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -394,15 +394,18 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
if (settings.debug && (settings.verbose || currentRun.size < 5))
inform("[running phase " + name + " on " + unit + "]")
+ if (!cancelled(unit)) {
+ currentRun.informUnitStarting(this, unit)
+ try withCurrentUnitNoLog(unit)(task)
+ finally currentRun.advanceUnit()
+ }
+ }
+ final def withCurrentUnitNoLog(unit: CompilationUnit)(task: => Unit) {
val unit0 = currentUnit
try {
currentRun.currentUnit = unit
- if (!cancelled(unit)) {
- currentRun.informUnitStarting(this, unit)
- task
- }
- currentRun.advanceUnit()
+ task
} finally {
//assert(currentUnit == unit)
currentRun.currentUnit = unit0
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
index 340fdc849a..3520d57599 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
@@ -135,7 +135,7 @@ abstract class GenBCode extends BCodeSyncAndTry {
return
}
else {
- try { withCurrentUnit(item.cunit)(visit(item)) }
+ try { withCurrentUnitNoLog(item.cunit)(visit(item)) }
catch {
case ex: Throwable =>
ex.printStackTrace()