Skip to content

Commit b1c40b7

Browse files
author
David Ungar
committed
integrator
1 parent 660ab9f commit b1c40b7

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ extension ModuleDependencyGraph {
2323
// Shorthands
2424
/*@_spi(Testing)*/ public typealias Graph = ModuleDependencyGraph
2525

26-
/*@_spi(Testing)*/
27-
public struct Results {
28-
var allInvalidatedNodes = Set<Node>()
29-
var nodesInvalidatedByUsingSomeExternal = Set<Node>()
30-
31-
mutating func addNodesInvalidatedByUsingSomeExternal(_ invalidated: Set<Node>)
32-
{
33-
allInvalidatedNodes.formUnion(invalidated)
34-
nodesInvalidatedByUsingSomeExternal.formUnion(invalidated)
35-
}
36-
}
3726
public private(set) var results = Results()
3827

3928
/// the graph to be integrated
@@ -60,6 +49,10 @@ extension ModuleDependencyGraph {
6049
.findNodes(for: sourceGraph.dependencySource)
6150
?? [:]
6251
}
52+
53+
var reporter: IncrementalCompilationState.Reporter? {
54+
destination.info.reporter
55+
}
6356
}
6457
}
6558
// MARK: - integrate a graph
@@ -97,7 +90,7 @@ extension ModuleDependencyGraph.Integrator {
9790
}
9891
private mutating func handleDisappearedNodes() {
9992
for (_, node) in disappearedNodes {
100-
results.allInvalidatedNodes.insert(node)
93+
results.addDisappeared(node)
10194
destination.nodeFinder.remove(node)
10295
}
10396
}
@@ -136,7 +129,8 @@ extension ModuleDependencyGraph.Integrator {
136129
disappearedNodes.removeValue(forKey: matchHere.key)
137130
if matchHere.fingerprint != integrand.fingerprint {
138131
matchHere.setFingerprint(integrand.fingerprint)
139-
results.allInvalidatedNodes.insert(matchHere)
132+
results.addChanged(matchHere)
133+
reporter?.report("Fingerprint changed for \(matchHere)")
140134
}
141135
return matchHere
142136
}
@@ -156,7 +150,10 @@ extension ModuleDependencyGraph.Integrator {
156150
.replace(expat,
157151
newDependencySource: sourceGraph.dependencySource,
158152
newFingerprint: integrand.fingerprint)
159-
results.allInvalidatedNodes.insert(integratedNode)
153+
if destination.phase.isUpdating {
154+
reporter?.report("Discovered a definition for \(integratedNode)")
155+
}
156+
results.addPatriated(integratedNode)
160157
return integratedNode
161158
}
162159

@@ -171,7 +168,10 @@ extension ModuleDependencyGraph.Integrator {
171168
dependencySource: sourceGraph.dependencySource)
172169
let oldNode = destination.nodeFinder.insert(newNode)
173170
assert(oldNode == nil, "Should be new!")
174-
results.allInvalidatedNodes.insert(newNode)
171+
if destination.phase.isUpdating {
172+
reporter?.report("New definition: \(newNode)")
173+
}
174+
results.addNew(newNode)
175175
return newNode
176176
}
177177

@@ -211,6 +211,34 @@ extension ModuleDependencyGraph.Integrator {
211211
}
212212
}
213213

214+
// MARK: - Results {
215+
extension ModuleDependencyGraph.Integrator {
216+
/*@_spi(Testing)*/
217+
public struct Results {
218+
typealias Node = ModuleDependencyGraph.Node
219+
220+
private(set) var allInvalidatedNodes = Set<Node>()
221+
private(set) var nodesInvalidatedByUsingSomeExternal = Set<Node>()
222+
223+
mutating func addNodesInvalidatedByUsingSomeExternal(_ invalidated: Set<Node>)
224+
{
225+
allInvalidatedNodes.formUnion(invalidated)
226+
nodesInvalidatedByUsingSomeExternal.formUnion(invalidated)
227+
}
228+
mutating func addDisappeared(_ node: Node) {
229+
allInvalidatedNodes.insert(node)
230+
}
231+
mutating func addChanged(_ node: Node) {
232+
allInvalidatedNodes.insert(node)
233+
}
234+
mutating func addPatriated(_ node: Node) {
235+
allInvalidatedNodes.insert(node)
236+
}
237+
mutating func addNew(_ node: Node) {
238+
allInvalidatedNodes.insert(node)
239+
}
240+
}
241+
}
214242

215243
// MARK: - verification
216244
extension ModuleDependencyGraph.Integrator {

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ final class IncrementalCompilationTests: XCTestCase {
651651
"Forming batch job from 1 constituents: main.swift",
652652
"Starting Compiling main.swift",
653653
"Finished Compiling main.swift",
654+
"Incremental compilation: Fingerprint changed for interface of source file main.swiftdeps in main.swiftdeps",
655+
"Incremental compilation: Fingerprint changed for implementation of source file main.swiftdeps in main.swiftdeps",
654656
"Incremental compilation: Traced: interface of source file main.swiftdeps in main.swift -> interface of top-level name 'foo' in main.swift -> implementation of source file other.swiftdeps in other.swift",
655657
"Incremental compilation: Queuing because of dependencies discovered later: {compile: other.o <= other.swift}",
656658
"Incremental compilation: Scheduling invalidated {compile: other.o <= other.swift}",

0 commit comments

Comments
 (0)