diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-04 08:07:57 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-09-10 09:55:33 +0200 |
commit | 59070cc385560b48267cbc77e872027dd8304c05 (patch) | |
tree | f2eaf1bd8f1737cf04bfe600a05307f4d220f47b /src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala | |
parent | 01f5435318551ce12787b120440572f169c71463 (diff) | |
download | scala-59070cc385560b48267cbc77e872027dd8304c05.tar.gz scala-59070cc385560b48267cbc77e872027dd8304c05.tar.bz2 scala-59070cc385560b48267cbc77e872027dd8304c05.zip |
Remove stale local variables and exception handlers after DCE
This is required for correctness of the generated bytecode. Exception
handlers and local variable descriptors specify code offset ranges.
These offsets have to exist, not be eliminated.
Diffstat (limited to 'src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala index a788cea532..ba94a9c44c 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala @@ -14,6 +14,7 @@ import scala.annotation.switch import scala.reflect.internal.util.Statistics import scala.tools.asm +import scala.tools.asm.tree.ClassNode /* * Prepare in-memory representations of classfiles using the ASM Tree API, and serialize them to disk. @@ -214,6 +215,14 @@ abstract class GenBCode extends BCodeSyncAndTry { * - converting the plain ClassNode to byte array and placing it on queue-3 */ class Worker2 { + def localOptimizations(classNode: ClassNode): Unit = { + def dce(): Boolean = BackendStats.timed(BackendStats.bcodeDceTimer) { + if (settings.YoptUnreachableCode) opt.LocalOpt.removeUnreachableCode(classNode) + else false + } + + dce() + } def run() { while (true) { @@ -224,9 +233,7 @@ abstract class GenBCode extends BCodeSyncAndTry { } else { try { - val dceStart = Statistics.startTimer(BackendStats.bcodeDceTimer) - if (settings.YoptUnreachableCode) opt.LocalOpt.removeUnreachableCode(item.plain) - Statistics.stopTimer(BackendStats.bcodeDceTimer, dceStart) + localOptimizations(item.plain) addToQ3(item) } catch { case ex: Throwable => |