Skip to content

Commit a3b10d1

Browse files
committed
Postpone tree compaction till all phases finish operating TASTY.
Linker adds new sections. Wait for sections to be added and then compact.
1 parent 68ce6e7 commit a3b10d1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/dotty/tools/dotc/core/tasty/TastyPickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import ast.tpd
1313
class TastyPickler {
1414

1515
private val sections = new mutable.ArrayBuffer[(TastyName.NameRef, TastyBuffer)]
16+
val uuid = UUID.randomUUID()
1617

1718
private val headerBuffer = {
1819
val buf = new TastyBuffer(24)
1920
for (ch <- header) buf.writeByte(ch.toByte)
2021
buf.writeNat(MajorVersion)
2122
buf.writeNat(MinorVersion)
22-
val uuid = UUID.randomUUID()
2323
buf.writeUncompressedLong(uuid.getMostSignificantBits)
2424
buf.writeUncompressedLong(uuid.getLeastSignificantBits)
2525
buf
@@ -31,6 +31,7 @@ class TastyPickler {
3131
sections += ((nameBuffer.nameIndex(name), buf))
3232

3333
def assembleParts(): Array[Byte] = {
34+
treePkl.compactify()
3435
def lengthWithLength(buf: TastyBuffer) = {
3536
buf.assemble()
3637
buf.length + natSize(buf.length)

src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,17 @@ class TreePickler(pickler: TastyPickler) {
541541
}
542542

543543
def pickle(trees: List[Tree])(implicit ctx: Context) = {
544+
trees.foreach(tree => if (!tree.isEmpty) pickleTree(tree))
545+
assert(forwardSymRefs.isEmpty, i"unresolved symbols: ${forwardSymRefs.keySet.toList}%, %")
546+
}
547+
548+
def compactify() = {
549+
buf.compactify()
550+
assert(forwardSymRefs.isEmpty, s"unresolved symbols: ${forwardSymRefs.keySet.toList}%, %")
551+
544552
def updateMapWithDeltas[T](mp: collection.mutable.Map[T, Addr]) =
545553
for (key <- mp.keysIterator.toBuffer[T]) mp(key) = adjusted(mp(key))
546554

547-
trees.foreach(tree => if (!tree.isEmpty) pickleTree(tree))
548-
assert(forwardSymRefs.isEmpty, i"unresolved symbols: ${forwardSymRefs.keySet.toList}%, %")
549-
compactify()
550555
updateMapWithDeltas(symRefs)
551556
}
552557
}

0 commit comments

Comments
 (0)