diff options
author | James Iry <jamesiry@gmail.com> | 2013-03-07 15:05:35 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-03-07 16:19:31 -0800 |
commit | 69109c0ace5e3ac831c3b0a5635f25317d3b28bf (patch) | |
tree | 191edbde9b7b0ae80dfc3860ff449598c8df5a60 /src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | |
parent | 5967a664ab1129e28687c591bd94c0e482cb305f (diff) | |
download | scala-69109c0ace5e3ac831c3b0a5635f25317d3b28bf.tar.gz scala-69109c0ace5e3ac831c3b0a5635f25317d3b28bf.tar.bz2 scala-69109c0ace5e3ac831c3b0a5635f25317d3b28bf.zip |
Analyze constants to remove unnecessary branches
This commit adds analysis and optimization of constants to remove
unnecessary branches. It uses abstract interpretation to determine
what constant(s) a particular stack slot or variable might or might not
hold at a given spot and uses that knowledge to eliminate branches that
cannot be taken. Its primary goal is null check removal, but it also
works for other constants.
Several tests are modified to include the new optimization phase.
Two new tests are added. One verifies that branching still works as
expected. The other verifies that branches are removed.
Diffstat (limited to 'src/compiler/scala/tools/nsc/settings/ScalaSettings.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 702071f906..757303e335 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -38,7 +38,7 @@ trait ScalaSettings extends AbsScalaSettings protected def futureSettings = List[BooleanSetting]() /** Enabled under -optimise. */ - protected def optimiseSettings = List[BooleanSetting](inline, inlineHandlers, Xcloselim, Xdce) + protected def optimiseSettings = List[BooleanSetting](inline, inlineHandlers, Xcloselim, Xdce, YconstOptimization) /** Internal use - syntax enhancements. */ private class EnableSettings[T <: BooleanSetting](val s: T) { @@ -128,6 +128,7 @@ trait ScalaSettings extends AbsScalaSettings val check = PhasesSetting ("-Ycheck", "Check the tree at the end of") val Yshow = PhasesSetting ("-Yshow", "(Requires -Xshow-class or -Xshow-object) Show after") val Xcloselim = BooleanSetting ("-Yclosure-elim", "Perform closure elimination.") + val YconstOptimization = BooleanSetting ("-Yconst-opt", "Perform optimization with constant values.") val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees.") val noCompletion = BooleanSetting ("-Yno-completion", "Disable tab-completion in the REPL.") val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination.") |