Skip to content

Commit 3e8389a

Browse files
committed
Better stats about recorded basetype cache entries
1 parent e2608cf commit 3e8389a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,13 @@ object SymDenotations {
16231623
final def baseTypeOf(tp: Type)(implicit ctx: Context): Type = {
16241624
val btrCache = baseTypeCache
16251625
def inCache(tp: Type) = btrCache.get(tp) != null
1626+
def record(tp: CachedType, baseTp: Type) = {
1627+
if (Stats.monitored) {
1628+
Stats.record("basetype cache entries")
1629+
if (!baseTp.exists) Stats.record("basetype cache NoTypes")
1630+
}
1631+
btrCache.put(tp, baseTp)
1632+
}
16261633

16271634
def ensureAcyclic(baseTp: Type) = {
16281635
if (baseTp `eq` NoPrefix) throw CyclicReference(this)
@@ -1667,13 +1674,13 @@ object SymDenotations {
16671674
else NoType
16681675
else
16691676
recur(clsd.typeRef).asSeenFrom(prefix, clsd.owner)
1670-
if (baseTp.exists) btrCache.put(tp, baseTp) else btrCache.remove(tp)
1677+
if (baseTp.exists) record(tp, baseTp) else btrCache.remove(tp)
16711678
baseTp
16721679
case _ =>
16731680
val superTp = tp.superType
16741681
val baseTp = recur(superTp)
16751682
if (baseTp.exists && inCache(superTp) && tp.symbol.maybeOwner.isType)
1676-
btrCache.put(tp, baseTp) // typeref cannot be a GADT, so cache is stable
1683+
record(tp, baseTp) // typeref cannot be a GADT, so cache is stable
16771684
else
16781685
btrCache.remove(tp)
16791686
baseTp
@@ -1693,7 +1700,7 @@ object SymDenotations {
16931700
case tparams: List[Symbol @unchecked] =>
16941701
recur(tycon).subst(tparams, args)
16951702
}
1696-
if (baseTp.exists) btrCache.put(tp, baseTp) else btrCache.remove(tp)
1703+
if (baseTp.exists) record(tp, baseTp) else btrCache.remove(tp)
16971704
baseTp
16981705
}
16991706
computeApplied
@@ -1709,7 +1716,7 @@ object SymDenotations {
17091716
case tp: CachedType if baseTp.exists && inCache(superTp) =>
17101717
// Note: This also works for TypeVars: If they are not instantiated, their supertype
17111718
// is a TypeParamRef, which is never cached. So uninstantiated TypeVars are not cached either.
1712-
btrCache.put(tp, baseTp)
1719+
record(tp, baseTp)
17131720
case _ =>
17141721
}
17151722
baseTp
@@ -1734,7 +1741,7 @@ object SymDenotations {
17341741
case _ => combined
17351742
}
17361743
}
1737-
if (baseTp.exists && inCache(tp1) && inCache(tp2)) btrCache.put(tp, baseTp)
1744+
if (baseTp.exists && inCache(tp1) && inCache(tp2)) record(tp, baseTp)
17381745
baseTp
17391746
}
17401747
computeAndOrType

0 commit comments

Comments
 (0)