summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2014-08-22 23:10:48 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2014-09-09 23:56:52 +0200
commitd3cfbb1db68dab3308edfa66bbdb497c5d3f0cb2 (patch)
tree1b28ad30fda3bc28728b0556af7f5ce95a07186f /src/compiler
parent90781e874adb1af44a43d3e64d403230970b423d (diff)
downloadscala-d3cfbb1db68dab3308edfa66bbdb497c5d3f0cb2.tar.gz
scala-d3cfbb1db68dab3308edfa66bbdb497c5d3f0cb2.tar.bz2
scala-d3cfbb1db68dab3308edfa66bbdb497c5d3f0cb2.zip
-Yopt mulit-choice flag
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala2
-rw-r--r--src/compiler/scala/tools/nsc/settings/ScalaSettings.scala26
2 files changed, 27 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
index a7cc1f69cf..a788cea532 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala
@@ -225,7 +225,7 @@ abstract class GenBCode extends BCodeSyncAndTry {
else {
try {
val dceStart = Statistics.startTimer(BackendStats.bcodeDceTimer)
- opt.LocalOpt.removeUnreachableCode(item.plain)
+ if (settings.YoptUnreachableCode) opt.LocalOpt.removeUnreachableCode(item.plain)
Statistics.stopTimer(BackendStats.bcodeDceTimer, dceStart)
addToQ3(item)
} catch {
diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
index 98eb831a9d..466e397dd7 100644
--- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -209,6 +209,32 @@ trait ScalaSettings extends AbsScalaSettings
// the current standard is "inline" but we are moving towards "method"
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "inline")
+ object YoptChoices extends MultiChoiceEnumeration {
+ val unreachableCode = Choice("unreachable-code", "Eliminate unreachable code")
+
+ 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)
+
+ private val methodChoices = List(lDefault)
+ val lMethod = Choice("l:method", "Intra-method optimizations: "+ methodChoices.mkString(","), expandsTo = methodChoices)
+
+ private val projectChoices = List(lMethod)
+ val lProject = Choice("l:project", "Cross-method optimizations within the current project: "+ projectChoices.mkString(","), expandsTo = projectChoices)
+
+ private val classpathChoices = List(lProject)
+ val lClasspath = Choice("l:classpath", "Cross-method optmizations across the entire classpath: "+ classpathChoices.mkString(","), expandsTo = classpathChoices)
+ }
+
+ val Yopt = MultiChoiceSetting(
+ name = "-Yopt",
+ helpArg = "optimization",
+ descr = "Enable optimizations",
+ domain = YoptChoices)
+
+ def YoptUnreachableCode: Boolean = !Yopt.isSetByUser || Yopt.contains(YoptChoices.unreachableCode)
+
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."
object YstatisticsPhases extends MultiChoiceEnumeration { val parser, typer, patmat, erasure, cleanup, jvm = Value }