Skip to content

Commit be01457

Browse files
authored
Merge pull request #3217 from dotty-staging/try-optimize-2
Some more optimizations
2 parents aee7a4f + f27cd43 commit be01457

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ object Trees {
11141114
abstract class TreeMap(val cpy: TreeCopier = inst.cpy) {
11151115

11161116
def transform(tree: Tree)(implicit ctx: Context): Tree = {
1117+
Stats.record(s"TreeMap.transform $getClass")
1118+
Stats.record("TreeMap.transform total")
11171119
def localCtx =
11181120
if (tree.hasType && tree.symbol.exists) ctx.withOwner(tree.symbol) else ctx
11191121

@@ -1228,6 +1230,8 @@ object Trees {
12281230

12291231
def apply(x: X, trees: Traversable[Tree])(implicit ctx: Context): X = (x /: trees)(apply)
12301232
def foldOver(x: X, tree: Tree)(implicit ctx: Context): X = {
1233+
Stats.record(s"TreeAccumulator.foldOver $getClass")
1234+
Stats.record("TreeAccumulator.foldOver total")
12311235
def localCtx =
12321236
if (tree.hasType && tree.symbol.exists) ctx.withOwner(tree.symbol) else ctx
12331237
tree match {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,6 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
484484
// constructor method should not be semi-erased.
485485
else if (isConstructor && isDerivedValueClass(sym)) eraseNormalClassRef(tp)
486486
else this(tp)
487-
case RefinedType(parent, _, _) if !(parent isRef defn.ArrayClass) => // @!!!
488-
eraseResult(parent)
489487
case AppliedType(tycon, _) if !(tycon isRef defn.ArrayClass) =>
490488
eraseResult(tycon)
491489
case _ =>

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ object Types {
11571157
/** The full parent types, including all type arguments */
11581158
def parents(implicit ctx: Context): List[Type] = this match {
11591159
case tp @ AppliedType(tycon, args) if tycon.typeSymbol.isClass =>
1160-
tycon.parents.map(_.subst(tycon.typeSymbol.typeParams, args)) // @!!! cache?
1160+
tycon.parents.map(_.subst(tycon.typeSymbol.typeParams, args))
11611161
case tp: TypeRef =>
11621162
if (tp.info.isInstanceOf[TempClassInfo]) {
11631163
tp.reloadDenot()
@@ -3720,6 +3720,8 @@ object Types {
37203720

37213721
/** Map this function over given type */
37223722
def mapOver(tp: Type): Type = {
3723+
record(s"mapOver ${getClass}")
3724+
record("mapOver total")
37233725
implicit val ctx = this.ctx
37243726
tp match {
37253727
case tp: NamedType =>
@@ -4095,7 +4097,10 @@ object Types {
40954097
protected final def applyToPrefix(x: T, tp: NamedType) =
40964098
atVariance(variance max 0)(this(x, tp.prefix)) // see remark on NamedType case in TypeMap
40974099

4098-
def foldOver(x: T, tp: Type): T = tp match {
4100+
def foldOver(x: T, tp: Type): T = {
4101+
record(s"foldOver $getClass")
4102+
record(s"foldOver total")
4103+
tp match {
40994104
case tp: TypeRef =>
41004105
if (stopAtStatic && tp.symbol.isStatic) x
41014106
else {
@@ -4184,7 +4189,7 @@ object Types {
41844189
tp.fold(x, this)
41854190

41864191
case _ => x
4187-
}
4192+
}}
41884193

41894194
@tailrec final def foldOver(x: T, ts: List[Type]): T = ts match {
41904195
case t :: ts1 => foldOver(apply(x, t), ts1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class LinkAll extends MiniPhaseTransform {
3636
}
3737

3838
if (ctx.settings.XlinkOptimise.value) super.runOn(allUnits(Set.empty, units.toSet, Set.empty))
39-
else super.runOn(units)
39+
else units
4040
}
4141

4242
/** Collects all class denotations that may need to be loaded. */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,7 @@ object TreeTransforms {
11831183
def transform(tree: Tree, info: TransformerInfo, cur: Int)(implicit ctx: Context): Tree = ctx.traceIndented(s"transforming ${tree.show} at ${ctx.phase}", transforms, show = true) {
11841184
try
11851185
if (cur < info.transformers.length) {
1186+
util.Stats.record("TreeTransform.transform")
11861187
// if cur > 0 then some of the symbols can be created by already performed transformations
11871188
// this means that their denotations could not exists in previous period
11881189
val pctx = ctx.withPhase(info.transformers(cur).treeTransformPhase)

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
16871687
}
16881688

16891689
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ ctx.traceIndented (i"typing $tree", typr, show = true) /*<|<*/ {
1690+
record(s"typed $getClass")
1691+
record("typed total")
16901692
assertPositioned(tree)
16911693
try adapt(typedUnadapted(tree, pt), pt)
16921694
catch {

0 commit comments

Comments
 (0)