@@ -13,6 +13,8 @@ import Symbols._
1313import Flags .Module
1414import reporting .ThrowingReporter
1515import collection .mutable
16+ import scala .concurrent .{Future , Await , ExecutionContext }
17+ import scala .concurrent .duration .Duration
1618
1719object Pickler {
1820 val name : String = " pickler"
@@ -55,35 +57,37 @@ class Pickler extends Phase {
5557 }
5658 {
5759 val pickler = new TastyPickler (cls)
58- if ( ctx.settings.YtestPickler .value) {
60+ if ctx.settings.YtestPickler .value then
5961 beforePickling(cls) = tree.show
6062 picklers(cls) = pickler
61- }
6263 val treePkl = pickler.treePkl
6364 treePkl.pickle(tree :: Nil )
64- treePkl.compactify()
65- pickler.addrOfTree = treePkl.buf.addrOfTree
66- pickler.addrOfSym = treePkl.addrOfSym
67- if (tree.span.exists)
68- new PositionPickler (pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil )
69-
70- if (! ctx.settings.YdropComments .value)
71- new CommentPickler (pickler, treePkl.buf.addrOfTree).pickleComment(tree)
72-
73- // other pickle sections go here.
74- val pickled = pickler.assembleParts()
75- unit.pickled += (cls -> pickled)
76-
77- def rawBytes = // not needed right now, but useful to print raw format.
78- pickled.iterator.grouped(10 ).toList.zipWithIndex.map {
79- case (row, i) => s " ${i}0: ${row.mkString(" " )}"
80- }
81-
82- // println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
83- if (pickling ne noPrinter) {
84- println(i " **** pickled info of $cls" )
85- println(new TastyPrinter (pickled).printContents())
86- }
65+ val pickledF = Future {
66+ treePkl.compactify()
67+ if tree.span.exists then
68+ new PositionPickler (pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil )
69+
70+ if ! ctx.settings.YdropComments .value then
71+ new CommentPickler (pickler, treePkl.buf.addrOfTree).pickleComment(tree)
72+
73+ val pickled = pickler.assembleParts()
74+
75+ def rawBytes = // not needed right now, but useful to print raw format.
76+ pickled.iterator.grouped(10 ).toList.zipWithIndex.map {
77+ case (row, i) => s " ${i}0: ${row.mkString(" " )}"
78+ }
79+
80+ // println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
81+ if pickling ne noPrinter then
82+ pickling.synchronized {
83+ println(i " **** pickled info of $cls" )
84+ println(new TastyPrinter (pickled).printContents())
85+ }
86+ pickled
87+ }(using ExecutionContext .global)
88+ def force (): Array [Byte ] = Await .result(pickledF, Duration .Inf )
89+ if ctx.settings.YtestPickler .value then force()
90+ unit.pickled += (cls -> force)
8791 }
8892 }
8993
0 commit comments