@@ -17,6 +17,7 @@ import java.lang.Thread.UncaughtExceptionHandler
17
17
import java .nio .file .attribute .FileTime
18
18
import java .nio .file .{Files , Path , Paths }
19
19
import java .time .Instant
20
+ import java .util .concurrent .ConcurrentHashMap
20
21
import java .util .{Collections , Locale }
21
22
import java .util .concurrent .atomic .{AtomicBoolean , AtomicInteger }
22
23
@@ -44,10 +45,13 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
44
45
val root = file.getRoot
45
46
// An empty component on Unix, just the drive letter on Windows
46
47
val validRootPathComponent = root.toString.replaceAllLiterally(" /" , " " ).replaceAllLiterally(" :" , " " )
47
- changeExtension(pickleCache.resolve(validRootPathComponent).resolve(root.relativize(file)).normalize(), newExtension)
48
+ val result = changeExtension(pickleCache.resolve(validRootPathComponent).resolve(root.relativize(file)).normalize(), newExtension)
49
+ if (useJars) Files .createDirectories(result.getParent)
50
+ strippedAndExportedClassPath.put(file.toRealPath().normalize(), result)
51
+ result
48
52
}
49
53
50
- private val strippedAndExportedClassPath = mutable. HashMap [Path , Path ]()
54
+ private val strippedAndExportedClassPath = new ConcurrentHashMap [Path , Path ]().asScala
51
55
52
56
/** Forward errors to the (current) reporter. */
53
57
protected def scalacError (msg : String ): Unit = {
@@ -73,51 +77,6 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
73
77
p.getParent.resolve(changedFileName)
74
78
}
75
79
76
- def registerPickleClassPath [G <: Global ](output : Path , data : mutable.AnyRefMap [G # Symbol , PickleBuffer ]): Unit = {
77
- val jarPath = cachePath(output)
78
- val root = RootPath (jarPath, writable = true )
79
- Files .createDirectories(root.root)
80
-
81
- val dirs = mutable.Map [G # Symbol , Path ]()
82
- def packageDir (packSymbol : G # Symbol ): Path = {
83
- if (packSymbol.isEmptyPackageClass) root.root
84
- else if (dirs.contains(packSymbol)) dirs(packSymbol)
85
- else if (packSymbol.owner.isRoot) {
86
- val subDir = root.root.resolve(packSymbol.encodedName)
87
- Files .createDirectories(subDir)
88
- dirs.put(packSymbol, subDir)
89
- subDir
90
- } else {
91
- val base = packageDir(packSymbol.owner)
92
- val subDir = base.resolve(packSymbol.encodedName)
93
- Files .createDirectories(subDir)
94
- dirs.put(packSymbol, subDir)
95
- subDir
96
- }
97
- }
98
- val written = new java.util.IdentityHashMap [AnyRef , Unit ]()
99
- try {
100
- for ((symbol, pickle) <- data) {
101
- if (! written.containsKey(pickle)) {
102
- val base = packageDir(symbol.owner)
103
- val primary = base.resolve(symbol.encodedName + " .sig" )
104
- val writer = new BufferedOutputStream (Files .newOutputStream(primary))
105
- try {
106
- writer.write(pickle.bytes, 0 , pickle.writeIndex)
107
- } finally {
108
- writer.close()
109
- }
110
- written.put(pickle, ())
111
- }
112
- }
113
- } finally {
114
- root.close()
115
- }
116
- Files .setLastModifiedTime(jarPath, FileTime .from(Instant .now()))
117
- strippedAndExportedClassPath.put(output.toRealPath().normalize(), jarPath)
118
- }
119
-
120
-
121
80
def writeDotFile (logDir : Path , dependsOn : mutable.LinkedHashMap [Task , List [Dependency ]]): Unit = {
122
81
val builder = new java.lang.StringBuilder ()
123
82
builder.append(" digraph projects {\n " )
@@ -375,7 +334,6 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
375
334
if (p.outlineTimer.durationMicros > 0d ) {
376
335
val desc = if (strategy == OutlineTypePipeline ) " outline-type" else " parser-to-pickler"
377
336
events += durationEvent(p.label, desc, p.outlineTimer)
378
- events += durationEvent(p.label, " pickle-export" , p.pickleExportTimer)
379
337
}
380
338
for ((g, ix) <- p.groups.zipWithIndex) {
381
339
if (g.timer.durationMicros > 0d )
@@ -453,7 +411,6 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
453
411
val isGrouped = groups.size > 1
454
412
455
413
val outlineTimer = new Timer ()
456
- val pickleExportTimer = new Timer
457
414
val javaTimer = new Timer ()
458
415
459
416
var outlineCriticalPathMs = 0d
@@ -491,14 +448,11 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
491
448
command.settings.Youtline .value = true
492
449
command.settings.stopAfter.value = List (" pickler" )
493
450
command.settings.Ymacroexpand .value = command.settings.MacroExpand .None
451
+ command.settings.YpickleWrite .value = cachePath(command.settings.outputDirs.getSingleOutput.get.file.toPath).toAbsolutePath.toString
494
452
val run1 = new compiler.Run ()
495
453
run1 compile files
496
454
outlineTimer.stop()
497
455
log(f " scalac outline: done ${outlineTimer.durationMs}%.0f ms " )
498
- pickleExportTimer.start()
499
- registerPickleClassPath(command.settings.outputDirs.getSingleOutput.get.file.toPath, run1.symData)
500
- pickleExportTimer.stop()
501
- log(f " scalac: exported pickles ${pickleExportTimer.durationMs}%.0f ms " )
502
456
reporter.finish()
503
457
if (reporter.hasErrors) {
504
458
log(" scalac outline: failed" )
@@ -518,6 +472,7 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
518
472
command.settings.Youtline .value = false
519
473
command.settings.stopAfter.value = Nil
520
474
command.settings.Ymacroexpand .value = command.settings.MacroExpand .Normal
475
+ command.settings.YpickleWrite .value = " "
521
476
522
477
val groupCount = groups.size
523
478
for ((group, ix) <- groups.zipWithIndex) {
@@ -552,18 +507,14 @@ class PipelineMainClass(argFiles: Seq[Path], pipelineSettings: PipelineMain.Pipe
552
507
assert(groups.size == 1 )
553
508
val group = groups.head
554
509
log(" scalac: start" )
510
+ command.settings.YpickleWrite .value = cachePath(command.settings.outputDirs.getSingleOutput.get.file.toPath).toString
555
511
outlineTimer.start()
556
512
try {
557
513
val run2 = new compiler.Run () {
558
-
559
514
override def advancePhase (): Unit = {
560
515
if (compiler.phase == this .picklerPhase) {
561
516
outlineTimer.stop()
562
517
log(f " scalac outline: done ${outlineTimer.durationMs}%.0f ms " )
563
- pickleExportTimer.start()
564
- registerPickleClassPath(command.settings.outputDirs.getSingleOutput.get.file.toPath, symData)
565
- pickleExportTimer.stop()
566
- log(f " scalac: exported pickles ${pickleExportTimer.durationMs}%.0f ms " )
567
518
outlineDone.complete(Success (()))
568
519
group.timer.start()
569
520
}
0 commit comments