Skip to content

Commit 403165e

Browse files
committed
Drop alias detection for HiddenSets
That was needed only to order fresh caps to find the peak of peaks but we don't do that anymore.
1 parent 7a7f747 commit 403165e

File tree

1 file changed

+5
-55
lines changed

1 file changed

+5
-55
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,9 @@ object CaptureSet:
12201220
*/
12211221
class HiddenSet(initialOwner: Symbol, val owningCap: FreshCap)(using @constructorOnly ictx: Context)
12221222
extends Var(initialOwner):
1223+
1224+
// Updated by anchorCaps in CheckCaptures, but owner can be changed only
1225+
// if it was NoSymbol before.
12231226
var givenOwner: Symbol = initialOwner
12241227

12251228
override def owner = givenOwner
@@ -1228,62 +1231,9 @@ object CaptureSet:
12281231

12291232
description = i"of elements subsumed by a fresh cap in $initialOwner"
12301233

1231-
private def aliasRef: FreshCap | Null =
1232-
if myElems.size == 1 then
1233-
myElems.nth(0) match
1234-
case alias: FreshCap if deps.contains(alias.hiddenSet) => alias
1235-
case _ => null
1236-
else null
1237-
1238-
private def aliasSet: HiddenSet =
1239-
if myElems.size == 1 then
1240-
myElems.nth(0) match
1241-
case alias: FreshCap if deps.contains(alias.hiddenSet) => alias.hiddenSet
1242-
case _ => this
1243-
else this
1244-
1245-
def superCaps: List[FreshCap] =
1246-
deps.toList.map(_.asInstanceOf[HiddenSet].owningCap)
1247-
1248-
override def elems: Refs =
1249-
val al = aliasSet
1250-
if al eq this then super.elems else al.elems
1251-
1252-
override def elems_=(refs: Refs) =
1253-
val al = aliasSet
1254-
if al eq this then super.elems_=(refs) else al.elems_=(refs)
1255-
1256-
/** Add element to hidden set. Also add it to all supersets (as indicated by
1257-
* deps of this set). Follow aliases on both hidden set and added element
1258-
* before adding. If the added element is also a Fresh instance with
1259-
* hidden set H which is a superset of this set, then make this set an
1260-
* alias of H.
1261-
*/
1234+
/** Add element to hidden set. */
12621235
def add(elem: Capability)(using ctx: Context, vs: VarState): Unit =
1263-
val alias = aliasSet
1264-
if alias ne this then alias.add(elem)
1265-
else
1266-
def addToElems() =
1267-
assert(!isConst)
1268-
includeElem(elem)
1269-
deps.foreach: dep =>
1270-
assert(dep != this)
1271-
vs.addHidden(dep.asInstanceOf[HiddenSet], elem)
1272-
elem match
1273-
case elem: FreshCap =>
1274-
if this ne elem.hiddenSet then
1275-
val alias = elem.hiddenSet.aliasRef
1276-
if alias != null then
1277-
add(alias)
1278-
else if deps.contains(elem.hiddenSet) then // make this an alias of elem
1279-
capt.println(i"Alias $this to ${elem.hiddenSet}")
1280-
elems = SimpleIdentitySet(elem)
1281-
deps = SimpleIdentitySet(elem.hiddenSet)
1282-
else
1283-
addToElems()
1284-
elem.hiddenSet.includeDep(this)
1285-
case _ =>
1286-
addToElems()
1236+
includeElem(elem)
12871237

12881238
/** Apply function `f` to `elems` while setting `elems` to empty for the
12891239
* duration. This is used to escape infinite recursions if two Freshs

0 commit comments

Comments
 (0)