diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-10-13 14:34:24 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-11-04 14:11:21 +0100 |
commit | d39525ac06c8d319b43d3388d624fb2c1dcbd601 (patch) | |
tree | ba1f889e9df2382d9717aa7bfb895bcf7d683bd9 /src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | |
parent | be82759d7f56f1d78b4123fec0706f4f4565133e (diff) | |
download | scala-d39525ac06c8d319b43d3388d624fb2c1dcbd601.tar.gz scala-d39525ac06c8d319b43d3388d624fb2c1dcbd601.tar.bz2 scala-d39525ac06c8d319b43d3388d624fb2c1dcbd601.zip |
GenBCode: Compact local variable slots
After eliminating unreachable code, there may be unused local varaible
slots. Such gaps increase the method's frame size unnecessarily.
The optimization does not attempt to re-use the same local variable
slot for non-overlapping locals (proper register allocation):
def f(b: Boolean) = if (b) { val x = e; x } else { val y = e; y }
x and y will not use the same slot, even though they could.
This was originally implemented by Miguel in
https://github.com/lrytz/scala/commit/09c40359338f8770e4f99d045999af062112973e
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/ScalaSettings.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 2406b9e66b..2c9d101106 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -215,20 +215,21 @@ trait ScalaSettings extends AbsScalaSettings val recurseUnreachableJumps = Choice("recurse-unreachable-jumps", "Recursively apply unreachable-code and simplify-jumps (if enabled) until reaching a fixpoint.") val emptyLineNumbers = Choice("empty-line-numbers", "Eliminate unnecessary line number information.") val emptyLabels = Choice("empty-labels", "Eliminate and collapse redundant labels in the bytecode.") + val compactLocals = Choice("compact-locals", "Eliminate empty slots in the sequence of local variables.") val lNone = Choice("l:none", "Don't enable any optimizations.") private val defaultChoices = List(unreachableCode) - val lDefault = Choice("l:default", "Enable default optimizations: "+ defaultChoices.mkString(","), expandsTo = defaultChoices) + val lDefault = Choice("l:default", "Enable default optimizations: "+ defaultChoices.mkString(","), expandsTo = defaultChoices) - private val methodChoices = List(unreachableCode, simplifyJumps, recurseUnreachableJumps, emptyLineNumbers, emptyLabels) - val lMethod = Choice("l:method", "Enable intra-method optimizations: "+ methodChoices.mkString(","), expandsTo = methodChoices) + private val methodChoices = List(unreachableCode, simplifyJumps, recurseUnreachableJumps, emptyLineNumbers, emptyLabels, compactLocals) + val lMethod = Choice("l:method", "Enable intra-method optimizations: "+ methodChoices.mkString(","), expandsTo = methodChoices) private val projectChoices = List(lMethod) - val lProject = Choice("l:project", "Enable cross-method optimizations within the current project: "+ projectChoices.mkString(","), expandsTo = projectChoices) + val lProject = Choice("l:project", "Enable cross-method optimizations within the current project: "+ projectChoices.mkString(","), expandsTo = projectChoices) private val classpathChoices = List(lProject) - val lClasspath = Choice("l:classpath", "Enable cross-method optmizations across the entire classpath: "+ classpathChoices.mkString(","), expandsTo = classpathChoices) + val lClasspath = Choice("l:classpath", "Enable cross-method optimizations across the entire classpath: "+ classpathChoices.mkString(","), expandsTo = classpathChoices) } val Yopt = MultiChoiceSetting( @@ -242,6 +243,7 @@ trait ScalaSettings extends AbsScalaSettings def YoptRecurseUnreachableJumps = Yopt.contains(YoptChoices.recurseUnreachableJumps) def YoptEmptyLineNumbers = Yopt.contains(YoptChoices.emptyLineNumbers) def YoptEmptyLabels = Yopt.contains(YoptChoices.emptyLabels) + def YoptCompactLocals = Yopt.contains(YoptChoices.compactLocals) private def removalIn212 = "This flag is scheduled for removal in 2.12. If you have a case where you need this flag then please report a bug." |