Skip to content

Commit 4f7f3a7

Browse files
committed
Change Yspecialize behaviour
Changes type from `StringSetting` to `IntSetting`. Value x passed to the setting is the maximum number of parameters to specialize. Any method with type parameters will see the x first (or all if there are not enough) of them specialized. Conflicts: src/dotty/tools/dotc/config/ScalaSettings.scala
1 parent ce2b561 commit 4f7f3a7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class ScalaSettings extends Settings.SettingGroup {
152152
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
153153
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
154154
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
155-
val Yspecialize = StringSetting("-Yspecialize","","Specialize all methods.", "")
155+
val Yspecialize = IntSetting("-Yspecialize","Specialize methods with maximum this amount of polymorphic types.", 0, 0 to 10)
156156

157157
def stop = YstopAfter
158158

src/dotty/tools/dotc/transform/TypeSpecializer.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,16 @@ class TypeSpecializer extends MiniPhaseTransform with InfoTransformer {
7777
poly.paramNames.zipWithIndex.map{case(name, i) => (i, requested.getOrElse(i, Nil))}
7878
}
7979
else {
80-
if (ctx.settings.Yspecialize.value == "all") {
80+
if (ctx.settings.Yspecialize.value > 0) {
8181
val filteredPrims = primitiveTypes.filter(tpe => poly.paramBounds.forall(_.contains(tpe)))
82-
List.range(0, poly.paramNames.length).map(i => (i, filteredPrims))
82+
List.range(0, Math.min(poly.paramNames.length, ctx.settings.Yspecialize.value)).map(i => (i, filteredPrims))
8383
}
8484
else Nil
8585
}
8686
}
8787

8888
def requestedSpecialization(decl: Symbol)(implicit ctx: Context): Boolean =
89-
specializationRequests.contains(decl) ||
90-
(ctx.settings.Yspecialize.value != "" && decl.name.contains(ctx.settings.Yspecialize.value)) ||
91-
ctx.settings.Yspecialize.value == "all"
89+
ctx.settings.Yspecialize.value != 0 || specializationRequests.contains(decl)
9290

9391
def registerSpecializationRequest(method: Symbols.Symbol)(index: Int, arguments: List[Type])(implicit ctx: Context) = {
9492
if (ctx.phaseId > this.treeTransformPhase.id)

0 commit comments

Comments
 (0)