@@ -13,6 +13,8 @@ import Symbols._
13
13
import Flags .Module
14
14
import reporting .ThrowingReporter
15
15
import collection .mutable
16
+ import scala .concurrent .{Future , Await , ExecutionContext }
17
+ import scala .concurrent .duration .Duration
16
18
17
19
object Pickler {
18
20
val name : String = " pickler"
@@ -55,35 +57,37 @@ class Pickler extends Phase {
55
57
}
56
58
{
57
59
val pickler = new TastyPickler (cls)
58
- if ( ctx.settings.YtestPickler .value) {
60
+ if ctx.settings.YtestPickler .value then
59
61
beforePickling(cls) = tree.show
60
62
picklers(cls) = pickler
61
- }
62
63
val treePkl = pickler.treePkl
63
64
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)
87
91
}
88
92
}
89
93
0 commit comments