Skip to content

Commit 7afda82

Browse files
committed
Remove unnecessary cache invalidation
1 parent 12b91f9 commit 7afda82

File tree

2 files changed

+8
-49
lines changed

2 files changed

+8
-49
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ object Denotations {
805805
val transformer = ctx.denotTransformers(nextTransformerId)
806806
//println(s"transforming $this with $transformer")
807807
try {
808-
next = transformer.transform(cur)(ctx.withPhase(transformer)).syncWithParents
808+
next = transformer.transform(cur)(ctx.withPhase(transformer))
809809
} catch {
810810
case ex: CyclicReference =>
811811
println(s"error while transforming $this") // DEBUG

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

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,9 @@ object SymDenotations {
12621262
memberNamesCache = MemberNames.None
12631263
}
12641264

1265+
def invalidateBaseTypeRefCache() =
1266+
baseTypeRefCache = new java.util.HashMap[CachedType, Type]
1267+
12651268
override def copyCaches(from: SymDenotation, phase: Phase)(implicit ctx: Context): this.type = {
12661269
from match {
12671270
case from: ClassDenotation =>
@@ -1348,45 +1351,6 @@ object SymDenotations {
13481351
isCompleted && testFullyCompleted && { setFlag(FullyCompleted); true }
13491352
}
13501353

1351-
// ------ syncing inheritance-related info -----------------------------
1352-
1353-
private var firstRunId: RunId = initRunId
1354-
1355-
/** invalidate caches influenced by parent classes if one of the parents
1356-
* is younger than the denotation itself.
1357-
*/
1358-
override def syncWithParents(implicit ctx: Context): SingleDenotation = {
1359-
def isYounger(tref: TypeRef) = tref.symbol.denot match {
1360-
case denot: ClassDenotation =>
1361-
if (denot.validFor.runId < ctx.runId) denot.current // syncs with its parents in turn
1362-
val result = denot.firstRunId > this.firstRunId
1363-
if (result) incremental.println(s"$denot is younger than $this")
1364-
result
1365-
case _ => false
1366-
}
1367-
val parentIsYounger = (firstRunId < ctx.runId) && {
1368-
infoOrCompleter match {
1369-
case cinfo: ClassInfo => cinfo.classParents exists isYounger
1370-
case _ => false
1371-
}
1372-
}
1373-
if (parentIsYounger) {
1374-
incremental.println(s"parents of $this are invalid; symbol id = ${symbol.id}, copying ...\n")
1375-
invalidateInheritedInfo()
1376-
}
1377-
firstRunId = ctx.runId
1378-
this
1379-
}
1380-
1381-
/** Invalidate all caches and fields that depend on base classes and their contents */
1382-
override def invalidateInheritedInfo(): Unit = {
1383-
myMemberFingerPrint = FingerPrint.unknown
1384-
myMemberCache = null
1385-
myMemberCachePeriod = Nowhere
1386-
invalidateBaseDataCache()
1387-
invalidateMemberNamesCache()
1388-
}
1389-
13901354
// ------ class-specific operations -----------------------------------
13911355

13921356
private[this] var myThisType: Type = null
@@ -1441,9 +1405,6 @@ object SymDenotations {
14411405
baseTypeRefValid = ctx.runId
14421406
}
14431407

1444-
def invalidateBaseTypeRefCache() =
1445-
baseTypeRefCache = new java.util.HashMap[CachedType, Type]
1446-
14471408
def computeBaseData(implicit onBehalf: BaseData, ctx: Context): (List[ClassSymbol], BaseClassSet) = {
14481409
val seen = mutable.SortedSet[Int]()
14491410
def addBaseClasses(bcs: List[ClassSymbol], to: List[ClassSymbol])
@@ -1571,8 +1532,7 @@ object SymDenotations {
15711532

15721533
if (myMemberFingerPrint != FingerPrint.unknown)
15731534
myMemberFingerPrint.include(sym.name)
1574-
if (myMemberCache != null)
1575-
myMemberCache invalidate sym.name
1535+
if (myMemberCache != null) myMemberCache.invalidate(sym.name)
15761536
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
15771537
}
15781538

@@ -1583,8 +1543,7 @@ object SymDenotations {
15831543
def replace(prev: Symbol, replacement: Symbol)(implicit ctx: Context): Unit = {
15841544
require(!(this is Frozen))
15851545
unforcedDecls.openForMutations.replace(prev, replacement)
1586-
if (myMemberCache != null)
1587-
myMemberCache invalidate replacement.name
1546+
if (myMemberCache != null) myMemberCache.invalidate(replacement.name)
15881547
}
15891548

15901549
/** Delete symbol from current scope.
@@ -1595,8 +1554,8 @@ object SymDenotations {
15951554
require(!(this is Frozen))
15961555
info.decls.openForMutations.unlink(sym)
15971556
myMemberFingerPrint = FingerPrint.unknown
1598-
if (myMemberCache != null) myMemberCache invalidate sym.name
1599-
invalidateMemberNamesCache()
1557+
if (myMemberCache != null) myMemberCache.invalidate(sym.name)
1558+
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
16001559
}
16011560

16021561
/** Make sure the type parameters of this class appear in the order given

0 commit comments

Comments
 (0)