aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/config/Printers.scala1
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala2
-rw-r--r--src/dotty/tools/dotc/core/Names.scala1
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala52
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala18
-rw-r--r--src/dotty/tools/dotc/core/Types.scala12
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala4
-rw-r--r--src/dotty/tools/dotc/util/Stats.scala10
8 files changed, 68 insertions, 32 deletions
diff --git a/src/dotty/tools/dotc/config/Printers.scala b/src/dotty/tools/dotc/config/Printers.scala
index cdba156b2..d9f6e3a90 100644
--- a/src/dotty/tools/dotc/config/Printers.scala
+++ b/src/dotty/tools/dotc/config/Printers.scala
@@ -16,6 +16,7 @@ object Printers {
val constr: Printer = noPrinter
val overload: Printer = noPrinter
val implicits: Printer = noPrinter
+ val implicits2: Printer = noPrinter
val subtyping: Printer = noPrinter
val unapp: Printer = noPrinter
val completions = noPrinter
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index f74cd9445..8c2e0fbb3 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -427,6 +427,8 @@ object Contexts {
override def hash(x: Type): Int = x.hash
}
+ private[dotc] def uniquesSize = uniques.size
+
/** The number of recursive invocation of underlying on a NamedType
* during a controlled operation.
*/
diff --git a/src/dotty/tools/dotc/core/Names.scala b/src/dotty/tools/dotc/core/Names.scala
index 65cbf6b99..30f82e05e 100644
--- a/src/dotty/tools/dotc/core/Names.scala
+++ b/src/dotty/tools/dotc/core/Names.scala
@@ -269,6 +269,7 @@ object Names {
* Assume they are already encoded.
*/
def termName(cs: Array[Char], offset: Int, len: Int): TermName = {
+ util.Stats.record("termName")
val h = hashValue(cs, offset, len) & (table.size - 1)
synchronized {
val next = table(h)
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 7c3421eef..886024325 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -11,6 +11,7 @@ import scala.reflect.io.AbstractFile
import Decorators.SymbolIteratorDecorator
import annotation.tailrec
import util.SimpleMap
+import util.Stats
import config.Config
import config.Printers._
@@ -967,7 +968,8 @@ object SymDenotations {
* The elements of the returned pre-denotation all
* have existing symbols.
*/
- final def nonPrivateMembersNamed(name: Name)(implicit ctx: Context): PreDenotation =
+ final def nonPrivateMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = {
+ Stats.record("nonPrivateMembersNamed")
if (Config.cacheMembersNamed) {
var denots: PreDenotation = memberCache lookup name
if (denots == null) {
@@ -979,11 +981,13 @@ object SymDenotations {
}
denots
} else computeNPMembersNamed(name)
+ }
- private def computeNPMembersNamed(name: Name)(implicit ctx: Context): PreDenotation =
+ private def computeNPMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = /*>|>*/ Stats.track("computeNPMembersNamed") /*<|<*/ {
if (!classSymbol.hasChildren ||
!Config.useFingerPrints ||
(memberFingerPrint contains name)) {
+ Stats.record("computeNPMembersNamed after fingerprint")
ensureCompleted()
val ownDenots = decls.denotsNamed(name, selectNonPrivate)
if (debugTrace) // DEBUG
@@ -1005,6 +1009,7 @@ object SymDenotations {
if (name.isConstructorName) ownDenots
else collect(ownDenots, classParents)
} else NoDenotation
+ }
override final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation = {
val raw = if (excluded is Private) nonPrivateMembersNamed(name) else membersNamed(name)
@@ -1022,26 +1027,29 @@ object SymDenotations {
case _ => bt
}
- def computeBaseTypeOf(tp: Type): Type = tp match {
- case tp: TypeRef =>
- val subcls = tp.symbol
- if (subcls eq symbol)
- tp
- else subcls.denot match {
- case cdenot: ClassDenotation =>
- if (cdenot.superClassBits contains symbol.superId) foldGlb(NoType, tp.parents)
- else NoType
- case _ =>
- baseTypeOf(tp.underlying)
- }
- case tp: TypeProxy =>
- baseTypeOf(tp.underlying)
- case AndType(tp1, tp2) =>
- baseTypeOf(tp1) & baseTypeOf(tp2)
- case OrType(tp1, tp2) =>
- baseTypeOf(tp1) | baseTypeOf(tp2)
- case _ =>
- NoType
+ def computeBaseTypeOf(tp: Type): Type = {
+ Stats.record("computeBaseTypeOf")
+ tp match {
+ case tp: TypeRef =>
+ val subcls = tp.symbol
+ if (subcls eq symbol)
+ tp
+ else subcls.denot match {
+ case cdenot: ClassDenotation =>
+ if (cdenot.superClassBits contains symbol.superId) foldGlb(NoType, tp.parents)
+ else NoType
+ case _ =>
+ baseTypeOf(tp.underlying)
+ }
+ case tp: TypeProxy =>
+ baseTypeOf(tp.underlying)
+ case AndType(tp1, tp2) =>
+ baseTypeOf(tp1) & baseTypeOf(tp2)
+ case OrType(tp1, tp2) =>
+ baseTypeOf(tp1) | baseTypeOf(tp2)
+ case _ =>
+ NoType
+ }
}
/*>|>*/ ctx.debugTraceIndented(s"$tp.baseType($this)") /*<|<*/ {
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index dfa0180d1..87c6881b0 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -9,6 +9,7 @@ import StdNames.{nme, tpnme}
import collection.mutable
import printing.Disambiguation.disambiguated
import util.SimpleMap
+import util.Stats
import config.Config
import config.Printers._
@@ -50,6 +51,9 @@ class TypeComparer(initctx: Context) extends DotClass {
result
}
+ /** For stastics: count how many isSubTypes are part of succesful comparisons */
+ private var successCount = 0
+
private var myAnyClass: ClassSymbol = null
private var myNothingClass: ClassSymbol = null
private var myNullClass: ClassSymbol = null
@@ -190,6 +194,7 @@ class TypeComparer(initctx: Context) extends DotClass {
else if (tp1 eq tp2) true
else {
val saved = constraint
+ val savedCount = successCount
try {
recCount += 1
/* !!! DEBUG
@@ -203,9 +208,17 @@ class TypeComparer(initctx: Context) extends DotClass {
if (recCount < LogPendingSubTypesThreshold)
if (oldCompare) firstTry(tp1, tp2) else compare(tp1, tp2)
else monitoredIsSubType(tp1, tp2)
+ successCount += 1
recCount -= 1
- if (!result) constraint = saved
- else if (recCount == 0 && needsGc) ctx.typerState.gc()
+ if (!result) {
+ constraint = saved
+ successCount = savedCount
+ }
+ else if (recCount == 0) {
+ if (needsGc) ctx.typerState.gc()
+ Stats.record("successful-<:<", successCount)
+ successCount = 0
+ }
result
} catch {
case ex: Throwable =>
@@ -222,6 +235,7 @@ class TypeComparer(initctx: Context) extends DotClass {
}
recCount -= 1
constraint = saved
+ successCount = savedCount
throw ex
}
}
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 0627608cd..197c1ec97 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -16,7 +16,7 @@ import Decorators._
import Denotations._
import Periods._
import util.Positions.Position
-import util.Stats.track
+import util.Stats._
import util.SimpleMap
import ast.tpd._, printing.Texts._
import ast.untpd
@@ -956,8 +956,14 @@ object Types {
trait CachedType extends Type
def unique[T <: Type](tp: T)(implicit ctx: Context): T = {
- if (tp.hash == NotCached) tp
- else ctx.uniques.findEntryOrUpdate(tp).asInstanceOf[T]
+ if (tp.hash == NotCached) {
+ record("uncached-types")
+ tp
+ }
+ else {
+ record("cached-types")
+ ctx.uniques.findEntryOrUpdate(tp).asInstanceOf[T]
+ }
} /* !!! DEBUG
ensuring (
result => tp.toString == result.toString || {
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 3f3899752..2f5d1522b 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1024,7 +1024,7 @@ class Typer extends Namer with Applications with Implicits {
}
}
- def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = ctx.traceIndented (s"typing ${tree.show}", show = true) {
+ def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = ctx.traceIndented (s"typing ${tree.show}", typr, show = true) {
if (!tree.isEmpty && ctx.typerState.isGlobalCommittable) assert(tree.pos.exists, tree)
try adapt(typedUnadapted(tree, pt), pt)
catch {
@@ -1091,7 +1091,7 @@ class Typer extends Namer with Applications with Implicits {
}
def adapt(tree: Tree, pt: Type)(implicit ctx: Context) = track("adapt") {
- ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", show = true) {
+ ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) {
interpolateUndetVars(tree)
tree overwriteType tree.tpe.simplified
adaptInterpolated(tree, pt)
diff --git a/src/dotty/tools/dotc/util/Stats.scala b/src/dotty/tools/dotc/util/Stats.scala
index 894c1eb04..efae6be34 100644
--- a/src/dotty/tools/dotc/util/Stats.scala
+++ b/src/dotty/tools/dotc/util/Stats.scala
@@ -17,9 +17,11 @@ object Stats {
override def default(key: String): Int = 0
}
- def record(fn: String) = {
- val name = if (fn.startsWith("member-")) "member" else fn
- hits(name) += 1
+ def record(fn: String, n: Int = 1) = {
+ if (monitored) {
+ val name = if (fn.startsWith("member-")) "member" else fn
+ hits(name) += n
+ }
}
private var monitored = false
@@ -59,7 +61,9 @@ object Stats {
try op
finally {
hb.continue = false
+ println()
println(hits.toList.sortBy(_._2).map{ case (x, y) => s"$x -> $y" } mkString "\n")
+ println(s"unique types: ${ctx.base.uniquesSize}")
}
} else op
}