Skip to content

Commit 498abf9

Browse files
committed
Remove fingerprinting
Trying the dotc bootstrap revealed that Frozen logic can lead to assertion errors. So we want to remove it, but then taking fingerprints would no longer be cost-effective. Note: In local checking removing fingerprinting did cost some performance: junit test time went from 590s to 604s. We should watch the checkin benchmarks to see whether this gets confirmed.
1 parent daf736c commit 498abf9

File tree

2 files changed

+24
-69
lines changed

2 files changed

+24
-69
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ object Config {
44

55
final val cacheMembersNamed = true
66
final val cacheAsSeenFrom = true
7-
final val useFingerPrints = true // note: it currently seems to be slightly faster not to use them! my junit test: 548s without, 560s with.
87
final val cacheMemberNames = true
98
final val cacheImplicitScopes = true
109

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

Lines changed: 24 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,6 @@ object SymDenotations {
12991299
override def invalidateInheritedInfo(): Unit = {
13001300
myBaseClasses = null
13011301
mySuperClassBits = null
1302-
myMemberFingerPrint = FingerPrint.unknown
13031302
myMemberCache = null
13041303
myMemberCachePeriod = Nowhere
13051304
memberNamesCache = SimpleMap.Empty
@@ -1418,42 +1417,6 @@ object SymDenotations {
14181417

14191418
final override def typeParamCreationFlags = ClassTypeParamCreationFlags
14201419

1421-
private[this] var myMemberFingerPrint: FingerPrint = FingerPrint.unknown
1422-
1423-
private def computeMemberFingerPrint(implicit ctx: Context): FingerPrint = {
1424-
var fp = FingerPrint()
1425-
var e = info.decls.lastEntry
1426-
while (e != null) {
1427-
fp.include(e.name)
1428-
e = e.prev
1429-
}
1430-
var ps = classParents
1431-
while (ps.nonEmpty) {
1432-
val parent = ps.head.typeSymbol
1433-
parent.denot match {
1434-
case parentDenot: ClassDenotation =>
1435-
fp.include(parentDenot.memberFingerPrint)
1436-
if (parentDenot.isFullyCompleted) parentDenot.setFlag(Frozen)
1437-
case _ =>
1438-
}
1439-
ps = ps.tail
1440-
}
1441-
fp
1442-
}
1443-
1444-
/** A bloom filter for the names of all members in this class.
1445-
* Makes sense only for parent classes, and should definitely
1446-
* not be used for package classes because cache never
1447-
* gets invalidated.
1448-
*/
1449-
def memberFingerPrint(implicit ctx: Context): FingerPrint =
1450-
if (myMemberFingerPrint != FingerPrint.unknown) myMemberFingerPrint
1451-
else {
1452-
val fp = computeMemberFingerPrint
1453-
if (isFullyCompleted) myMemberFingerPrint = fp
1454-
fp
1455-
}
1456-
14571420
private[this] var myMemberCache: LRUCache[Name, PreDenotation] = null
14581421
private[this] var myMemberCachePeriod: Period = Nowhere
14591422

@@ -1499,13 +1462,12 @@ object SymDenotations {
14991462

15001463
/** Enter a symbol in given `scope` without potentially replacing the old copy. */
15011464
def enterNoReplace(sym: Symbol, scope: MutableScope)(implicit ctx: Context): Unit = {
1502-
require((sym.denot.flagsUNSAFE is Private) || !(this is Frozen) || (scope ne this.unforcedDecls))
1465+
require((sym.denot.flagsUNSAFE is Private) ||
1466+
!(this is Frozen) ||
1467+
(scope ne this.unforcedDecls))
15031468
scope.enter(sym)
15041469

1505-
if (myMemberFingerPrint != FingerPrint.unknown)
1506-
myMemberFingerPrint.include(sym.name)
1507-
if (myMemberCache != null)
1508-
myMemberCache invalidate sym.name
1470+
if (myMemberCache != null) myMemberCache invalidate sym.name
15091471
}
15101472

15111473
/** Replace symbol `prev` (if defined in current class) by symbol `replacement`.
@@ -1526,7 +1488,6 @@ object SymDenotations {
15261488
def delete(sym: Symbol)(implicit ctx: Context) = {
15271489
require(!(this is Frozen))
15281490
info.decls.openForMutations.unlink(sym)
1529-
myMemberFingerPrint = FingerPrint.unknown
15301491
if (myMemberCache != null) myMemberCache invalidate sym.name
15311492
}
15321493

@@ -1574,31 +1535,26 @@ object SymDenotations {
15741535
}
15751536

15761537
private[core] def computeNPMembersNamed(name: Name, inherited: Boolean)(implicit ctx: Context): PreDenotation = /*>|>*/ Stats.track("computeNPMembersNamed") /*<|<*/ {
1577-
if (!inherited ||
1578-
!Config.useFingerPrints ||
1579-
(memberFingerPrint contains name)) {
1580-
Stats.record("computeNPMembersNamed after fingerprint")
1581-
ensureCompleted()
1582-
val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
1583-
if (debugTrace) // DEBUG
1584-
println(s"$this.member($name), ownDenots = $ownDenots")
1585-
def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match {
1586-
case p :: ps =>
1587-
val denots1 = collect(denots, ps)
1588-
p.symbol.denot match {
1589-
case parentd: ClassDenotation =>
1590-
denots1 union
1591-
parentd.nonPrivateMembersNamed(name, inherited = true)
1592-
.mapInherited(ownDenots, denots1, thisType)
1593-
case _ =>
1594-
denots1
1595-
}
1596-
case nil =>
1597-
denots
1598-
}
1599-
if (name.isConstructorName) ownDenots
1600-
else collect(ownDenots, classParents)
1601-
} else NoDenotation
1538+
Stats.record("computeNPMembersNamed after fingerprint")
1539+
ensureCompleted()
1540+
val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
1541+
if (debugTrace) // DEBUG
1542+
println(s"$this.member($name), ownDenots = $ownDenots")
1543+
def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match {
1544+
case p :: ps =>
1545+
val denots1 = collect(denots, ps)
1546+
p.symbol.denot match {
1547+
case parentd: ClassDenotation =>
1548+
denots1 union
1549+
parentd.nonPrivateMembersNamed(name, inherited = true)
1550+
.mapInherited(ownDenots, denots1, thisType)
1551+
case _ =>
1552+
denots1
1553+
}
1554+
case nil =>
1555+
denots
1556+
}
1557+
if (name.isConstructorName) ownDenots else collect(ownDenots, classParents)
16021558
}
16031559

16041560
override final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation = {

0 commit comments

Comments
 (0)