Skip to content

Commit ddbf8f7

Browse files
committed
Remove FingerPrints
1 parent 7afda82 commit ddbf8f7

File tree

2 files changed

+22
-98
lines changed

2 files changed

+22
-98
lines changed

compiler/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

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

Lines changed: 22 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,42 +1452,6 @@ object SymDenotations {
14521452

14531453
final override def typeParamCreationFlags = ClassTypeParamCreationFlags
14541454

1455-
private[this] var myMemberFingerPrint: FingerPrint = FingerPrint.unknown
1456-
1457-
private def computeMemberFingerPrint(implicit ctx: Context): FingerPrint = {
1458-
var fp = FingerPrint()
1459-
var e = info.decls.lastEntry
1460-
while (e != null) {
1461-
fp.include(e.name)
1462-
e = e.prev
1463-
}
1464-
var ps = classParents
1465-
while (ps.nonEmpty) {
1466-
val parent = ps.head.typeSymbol
1467-
parent.denot match {
1468-
case parentDenot: ClassDenotation =>
1469-
fp.include(parentDenot.memberFingerPrint)
1470-
if (parentDenot.isFullyCompleted) parentDenot.setFlag(Frozen)
1471-
case _ =>
1472-
}
1473-
ps = ps.tail
1474-
}
1475-
fp
1476-
}
1477-
1478-
/** A bloom filter for the names of all members in this class.
1479-
* Makes sense only for parent classes, and should definitely
1480-
* not be used for package classes because cache never
1481-
* gets invalidated.
1482-
*/
1483-
def memberFingerPrint(implicit ctx: Context): FingerPrint =
1484-
if (myMemberFingerPrint != FingerPrint.unknown) myMemberFingerPrint
1485-
else {
1486-
val fp = computeMemberFingerPrint
1487-
if (isFullyCompleted) myMemberFingerPrint = fp
1488-
fp
1489-
}
1490-
14911455
/** Hook to do a pre-enter test. Overridden in PackageDenotation */
14921456
protected def proceedWithEnter(sym: Symbol, mscope: MutableScope)(implicit ctx: Context): Boolean = true
14931457

@@ -1530,8 +1494,6 @@ object SymDenotations {
15301494

15311495
scope.enter(sym)
15321496

1533-
if (myMemberFingerPrint != FingerPrint.unknown)
1534-
myMemberFingerPrint.include(sym.name)
15351497
if (myMemberCache != null) myMemberCache.invalidate(sym.name)
15361498
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
15371499
}
@@ -1553,7 +1515,6 @@ object SymDenotations {
15531515
def delete(sym: Symbol)(implicit ctx: Context) = {
15541516
require(!(this is Frozen))
15551517
info.decls.openForMutations.unlink(sym)
1556-
myMemberFingerPrint = FingerPrint.unknown
15571518
if (myMemberCache != null) myMemberCache.invalidate(sym.name)
15581519
if (!sym.flagsUNSAFE.is(Private)) invalidateMemberNamesCache()
15591520
}
@@ -1603,31 +1564,27 @@ object SymDenotations {
16031564
}
16041565

16051566
private[core] def computeNPMembersNamed(name: Name, inherited: Boolean)(implicit ctx: Context): PreDenotation = /*>|>*/ Stats.track("computeNPMembersNamed") /*<|<*/ {
1606-
if (!inherited ||
1607-
!Config.useFingerPrints ||
1608-
(memberFingerPrint contains name)) {
1609-
Stats.record("computeNPMembersNamed after fingerprint")
1610-
ensureCompleted()
1611-
val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
1612-
if (debugTrace) // DEBUG
1613-
println(s"$this.member($name), ownDenots = $ownDenots")
1614-
def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match {
1615-
case p :: ps =>
1616-
val denots1 = collect(denots, ps)
1617-
p.symbol.denot match {
1618-
case parentd: ClassDenotation =>
1619-
denots1 union
1620-
parentd.nonPrivateMembersNamed(name, inherited = true)
1621-
.mapInherited(ownDenots, denots1, thisType)
1622-
case _ =>
1623-
denots1
1624-
}
1625-
case nil =>
1626-
denots
1627-
}
1628-
if (name.isConstructorName) ownDenots
1629-
else collect(ownDenots, classParents)
1630-
} else NoDenotation
1567+
Stats.record("computeNPMembersNamed after fingerprint")
1568+
ensureCompleted()
1569+
val ownDenots = info.decls.denotsNamed(name, selectNonPrivate)
1570+
if (debugTrace) // DEBUG
1571+
println(s"$this.member($name), ownDenots = $ownDenots")
1572+
def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match {
1573+
case p :: ps =>
1574+
val denots1 = collect(denots, ps)
1575+
p.symbol.denot match {
1576+
case parentd: ClassDenotation =>
1577+
denots1 union
1578+
parentd.nonPrivateMembersNamed(name, inherited = true)
1579+
.mapInherited(ownDenots, denots1, thisType)
1580+
case _ =>
1581+
denots1
1582+
}
1583+
case nil =>
1584+
denots
1585+
}
1586+
if (name.isConstructorName) ownDenots
1587+
else collect(ownDenots, classParents)
16311588
}
16321589

16331590
override final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation = {
@@ -1981,30 +1938,7 @@ object SymDenotations {
19811938
}
19821939
}
19831940

1984-
// ---- Fingerprints -----------------------------------------------------
1985-
1986-
/** A fingerprint is a bitset that acts as a bloom filter for sets
1987-
* of names.
1988-
*/
1989-
class FingerPrint(val bits: Array[Long]) extends AnyVal {
1990-
import FingerPrint._
1991-
1992-
/** Include some bits of name's hashcode in set */
1993-
def include(name: Name): Unit = {
1994-
val hash = name.hashCode & Mask
1995-
bits(hash >> WordSizeLog) |= (1L << hash)
1996-
}
1997-
1998-
/** Include all bits of `that` fingerprint in set */
1999-
def include(that: FingerPrint): Unit =
2000-
for (i <- 0 until NumWords) bits(i) |= that.bits(i)
2001-
2002-
/** Does set contain hash bits of given name? */
2003-
def contains(name: Name): Boolean = {
2004-
val hash = name.hashCode & Mask
2005-
(bits(hash >> WordSizeLog) & (1L << hash)) != 0
2006-
}
2007-
}
1941+
// ---- Caches for inherited info -----------------------------------------
20081942

20091943
trait InheritedCache {
20101944
def isValid(implicit ctx: Context): Boolean
@@ -2147,15 +2081,6 @@ object SymDenotations {
21472081
def sameGroup(p1: Phase, p2: Phase) = p1.parentsGroup == p2.parentsGroup
21482082
}
21492083

2150-
object FingerPrint {
2151-
def apply() = new FingerPrint(new Array[Long](NumWords))
2152-
val unknown = new FingerPrint(null)
2153-
private final val WordSizeLog = 6
2154-
private final val NumWords = 32
2155-
private final val NumBits = NumWords << WordSizeLog
2156-
private final val Mask = NumBits - 1
2157-
}
2158-
21592084
class BaseClassSet(val classIds: Array[Int]) extends AnyVal {
21602085
def contains(sym: Symbol): Boolean = {
21612086
val id = sym.id

0 commit comments

Comments
 (0)