mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[CFE/bazel/DDC] Match 'tags' to reuse compiler state
This CL introduces 'tags' as a way to distinguish different setups and be able to throw away previous state when it cannot be used. These tags are - for now - basically filled up with the roots used for the multi root filesystem, the idea being, that if they have changed we cannot reuse the old state. Change-Id: I19e069513ce3836f5bc6abf047e4359836fc7e09 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114945 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
parent
a024685f3a
commit
8a670d773b
|
@ -275,6 +275,11 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
doneInputSummaries = List<Component>(summaryModules.length);
|
||||
compilerState = await fe.initializeIncrementalCompiler(
|
||||
oldCompilerState,
|
||||
{
|
||||
"trackWidgetCreation=$trackWidgetCreation",
|
||||
"multiRootScheme=${fileSystem.markerScheme}",
|
||||
"multiRootRoots=${fileSystem.roots}",
|
||||
},
|
||||
doneInputSummaries,
|
||||
compileSdk,
|
||||
sourcePathToUri(getSdkPath()),
|
||||
|
|
|
@ -48,7 +48,7 @@ export '../fasta/severity.dart' show Severity;
|
|||
|
||||
export 'compiler_state.dart' show InitializedCompilerState;
|
||||
|
||||
import 'util.dart' show equalMaps;
|
||||
import 'util.dart' show equalMaps, equalSets;
|
||||
|
||||
/// Initializes the compiler for a modular build.
|
||||
///
|
||||
|
@ -56,6 +56,7 @@ import 'util.dart' show equalMaps;
|
|||
/// as necessary based on [workerInputDigests].
|
||||
Future<InitializedCompilerState> initializeIncrementalCompiler(
|
||||
InitializedCompilerState oldState,
|
||||
Set<String> tags,
|
||||
Uri sdkSummary,
|
||||
Uri packagesFile,
|
||||
Uri librariesSpecificationUri,
|
||||
|
@ -84,7 +85,8 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
if (oldState == null ||
|
||||
oldState.incrementalCompiler == null ||
|
||||
oldState.incrementalCompiler.outlineOnly != outlineOnly ||
|
||||
!equalMaps(oldState.options.experimentalFlags, experimentalFlags)) {
|
||||
!equalMaps(oldState.options.experimentalFlags, experimentalFlags) ||
|
||||
!equalSets(oldState.tags, tags)) {
|
||||
// No - or immediately not correct - previous state.
|
||||
startOver = true;
|
||||
|
||||
|
@ -212,6 +214,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
return new InitializedCompilerState(options, processedOpts,
|
||||
workerInputCache: workerInputCache,
|
||||
incrementalCompiler: incrementalCompiler,
|
||||
tags: tags,
|
||||
libraryToInputDill: libraryToInputDill);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,13 @@ class InitializedCompilerState {
|
|||
final ProcessedOptions processedOpts;
|
||||
final Map<Uri, WorkerInputComponent> workerInputCache;
|
||||
final IncrementalCompiler incrementalCompiler;
|
||||
final Set<String> tags;
|
||||
final Map<Uri, Uri> libraryToInputDill;
|
||||
|
||||
InitializedCompilerState(this.options, this.processedOpts,
|
||||
{this.workerInputCache,
|
||||
this.incrementalCompiler,
|
||||
this.tags,
|
||||
this.libraryToInputDill});
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import '../kernel_generator_impl.dart' show generateKernel;
|
|||
import 'compiler_state.dart'
|
||||
show InitializedCompilerState, WorkerInputComponent, digestsEqual;
|
||||
|
||||
import 'util.dart' show equalLists, equalMaps;
|
||||
import 'util.dart' show equalLists, equalMaps, equalSets;
|
||||
|
||||
export '../api_prototype/compiler_options.dart'
|
||||
show CompilerOptions, parseExperimentalFlags, parseExperimentalArguments;
|
||||
|
@ -134,6 +134,7 @@ Future<InitializedCompilerState> initializeCompiler(
|
|||
|
||||
Future<InitializedCompilerState> initializeIncrementalCompiler(
|
||||
InitializedCompilerState oldState,
|
||||
Set<String> tags,
|
||||
List<Component> doneInputSummaries,
|
||||
bool compileSdk,
|
||||
Uri sdkRoot,
|
||||
|
@ -169,8 +170,9 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
cachedSdkInput == null ||
|
||||
!digestsEqual(cachedSdkInput.digest, sdkDigest) ||
|
||||
!equalMaps(oldState.options.experimentalFlags, experiments) ||
|
||||
!equalMaps(oldState.options.environmentDefines, environmentDefines)) {
|
||||
// No previous state.
|
||||
!equalMaps(oldState.options.environmentDefines, environmentDefines) ||
|
||||
!equalSets(oldState.tags, tags)) {
|
||||
// No - or immediately not correct - previous state.
|
||||
options = new CompilerOptions()
|
||||
..compileSdk = compileSdk
|
||||
..sdkRoot = sdkRoot
|
||||
|
@ -283,6 +285,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
return new InitializedCompilerState(options, processedOpts,
|
||||
workerInputCache: workerInputCache,
|
||||
incrementalCompiler: incrementalCompiler,
|
||||
tags: tags,
|
||||
libraryToInputDill: libraryToInputDill);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,16 @@ bool equalLists<T>(List<T> a, List<T> b) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool equalSets<K>(Set<K> a, Set<K> b) {
|
||||
if (identical(a, b)) return true;
|
||||
if (a == null || b == null) return false;
|
||||
if (a.length != b.length) return false;
|
||||
for (K entry in a) {
|
||||
if (!b.contains(entry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool equalMaps<K, V>(Map<K, V> a, Map<K, V> b) {
|
||||
if (identical(a, b)) return true;
|
||||
if (a == null || b == null) return false;
|
||||
|
|
|
@ -272,6 +272,12 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
// TODO(sigmund): add support for experiments with the incremental compiler.
|
||||
state = await fe.initializeIncrementalCompiler(
|
||||
previousState,
|
||||
{
|
||||
"target=$targetName",
|
||||
"trackWidgetCreation=$trackWidgetCreation",
|
||||
"multiRootScheme=${fileSystem.markerScheme}",
|
||||
"multiRootRoots=${fileSystem.roots}",
|
||||
},
|
||||
_toUri(parsedArgs['dart-sdk-summary']),
|
||||
_toUri(parsedArgs['packages-file']),
|
||||
_toUri(parsedArgs['libraries-file']),
|
||||
|
|
Loading…
Reference in a new issue