Skip to content

Commit f8cf56f

Browse files
OlivierBlanvillainDarkDimius
authored andcommitted
Split Simplify.scala in 15 files, document and fix bugs.
This is a cherry-picked ordering of following commits: Document optimizations1 Document optimizations2 Add -Yopt-phases, -Yopt-fuel, bisect.sh, update main Simplify loop DropNoEffects: fix first bootstrap bug DropNoEffects: comments and formating DropNoEffects: Remove TypeApply case, this is covered by DropGoodCasts Typo: receiver → receiver Formatting, adressing smarter comments Restructure optimizations. Try to bring performance back.
1 parent 8b814cf commit f8cf56f

25 files changed

+1819
-1493
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
173173

174174
val primitives: Primitives = new Primitives {
175175
val primitives = new DottyPrimitives(ctx)
176-
def getPrimitive(app: Apply, reciever: Type): Int = primitives.getPrimitive(app, reciever)
176+
def getPrimitive(app: Apply, receiver: Type): Int = primitives.getPrimitive(app, receiver)
177177

178178
def getPrimitive(sym: Symbol): Int = primitives.getPrimitive(sym)
179179

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import core.DenotTransformers.DenotTransformer
1717
import core.Denotations.SingleDenotation
1818

1919
import dotty.tools.backend.jvm.{LabelDefs, GenBCode, CollectSuperCalls}
20-
import dotty.tools.dotc.transform.linker.Simplify
20+
import dotty.tools.dotc.transform.localopt.Simplify
2121

2222
/** The central class of the dotc compiler. The job of a compiler is to create
2323
* runs, which process given `phases` in a given `rootContext`.

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ class ScalaSettings extends Settings.SettingGroup {
107107
val YnoInline = BooleanSetting("-Yno-inline", "Suppress inlining.")
108108

109109
/** Linker specific flags */
110-
val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize"
110+
val YoptPhases = PhasesSetting("-Yopt-phases", "Restrict the optimisation phases to execute under -optimise.")
111+
val YoptFuel = IntSetting("-Yopt-fuel", "Maximum number of optimisations performed under -optimise.", -1)
112+
val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying local optimisations to the .program") withAbbreviation "-optimize"
111113

112114
/** Dottydoc specific settings */
113115
val siteRoot = StringSetting(

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,12 @@ class Definitions {
368368

369369
lazy val SeqType: TypeRef = ctx.requiredClassRef("scala.collection.Seq")
370370
def SeqClass(implicit ctx: Context) = SeqType.symbol.asClass
371-
372371
lazy val Seq_applyR = SeqClass.requiredMethodRef(nme.apply)
373372
def Seq_apply(implicit ctx: Context) = Seq_applyR.symbol
374373
lazy val Seq_headR = SeqClass.requiredMethodRef(nme.head)
375374
def Seq_head(implicit ctx: Context) = Seq_headR.symbol
375+
lazy val SeqFactoryType: TypeRef = ctx.requiredClassRef("scala.collection.generic.SeqFactory")
376+
def SeqFactoryClass(implicit ctx: Context) = SeqFactoryType.symbol.asClass
376377

377378
lazy val ArrayType: TypeRef = ctx.requiredClassRef("scala.Array")
378379
def ArrayClass(implicit ctx: Context) = ArrayType.symbol.asClass
@@ -447,6 +448,8 @@ class Definitions {
447448
def Long_* = Long_mulR.symbol
448449
lazy val Long_divR = LongClass.requiredMethodRef(nme.DIV, List(LongType))
449450
def Long_/ = Long_divR.symbol
451+
val CommutativePrimitiveOperations = new PerRun[collection.Set[Symbol]](implicit ctx =>
452+
Set(defn.Boolean_&&, defn.Boolean_||, defn.Int_+, defn.Int_*, defn.Long_+, defn.Long_*))
450453

451454
lazy val FloatType: TypeRef = valueTypeRef("scala.Float", BoxedFloatType, java.lang.Float.TYPE, FloatEnc)
452455
def FloatClass(implicit ctx: Context) = FloatType.symbol.asClass

compiler/src/dotty/tools/dotc/transform/CtxLazy.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dotty.tools.dotc
22
package transform
3+
34
import core.Contexts.Context
45

56
/** Utility class for lazy values whose evaluation depends on a context.
@@ -20,4 +21,4 @@ class CtxLazy[T](expr: Context => T) {
2021
}
2122
myValue
2223
}
23-
}
24+
}

compiler/src/dotty/tools/dotc/transform/linker/Analysis.scala

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)