mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[bazel/kernel_worker] Only workers use incremental compiler; require digest
Change-Id: Iff4b45ffba79a05ce829ed73d952937ae55624d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101282 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com>
This commit is contained in:
parent
099af47a69
commit
6b730e8203
|
@ -55,7 +55,10 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
Target target,
|
||||
FileSystem fileSystem,
|
||||
bool outlineOnly) async {
|
||||
List<int> sdkDigest = workerInputDigests[sdkSummary];
|
||||
final List<int> sdkDigest = workerInputDigests[sdkSummary];
|
||||
if (sdkDigest == null) {
|
||||
throw new StateError("Expected to get digest for $sdkSummary");
|
||||
}
|
||||
IncrementalCompiler incrementalCompiler;
|
||||
CompilerOptions options;
|
||||
ProcessedOptions processedOpts;
|
||||
|
@ -73,7 +76,7 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
// We do have a previous state.
|
||||
cachedSdkInput = workerInputCache[sdkSummary];
|
||||
if (cachedSdkInput == null ||
|
||||
!digestsEqual(cachedSdkInput.digest, workerInputDigests[sdkSummary])) {
|
||||
!digestsEqual(cachedSdkInput.digest, sdkDigest)) {
|
||||
// The sdk is out of date.
|
||||
startOver = true;
|
||||
}
|
||||
|
@ -102,7 +105,6 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
} else {
|
||||
options = oldState.options;
|
||||
processedOpts = oldState.processedOpts;
|
||||
|
||||
var sdkComponent = cachedSdkInput.component;
|
||||
// Reset the state of the component.
|
||||
for (var lib in sdkComponent.libraries) {
|
||||
|
@ -127,6 +129,9 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
for (Uri summary in summaryInputs) {
|
||||
var cachedInput = workerInputCache[summary];
|
||||
var summaryDigest = workerInputDigests[summary];
|
||||
if (summaryDigest == null) {
|
||||
throw new StateError("Expected to get digest for $summary");
|
||||
}
|
||||
if (cachedInput == null ||
|
||||
cachedInput.component.root != nameRoot ||
|
||||
!digestsEqual(cachedInput.digest, summaryDigest)) {
|
||||
|
@ -145,7 +150,10 @@ Future<InitializedCompilerState> initializeIncrementalCompiler(
|
|||
|
||||
for (int i = 0; i < loadFromDill.length; i++) {
|
||||
Uri summary = loadFromDill[i];
|
||||
var summaryDigest = workerInputDigests[summary];
|
||||
List<int> summaryDigest = workerInputDigests[summary];
|
||||
if (summaryDigest == null) {
|
||||
throw new StateError("Expected to get digest for $summary");
|
||||
}
|
||||
WorkerInputComponent cachedInput = WorkerInputComponent(
|
||||
summaryDigest,
|
||||
await processedOpts.loadComponent(
|
||||
|
@ -193,7 +201,7 @@ Future<InitializedCompilerState> initializeCompiler(
|
|||
|
||||
Future<CompilerResult> _compile(InitializedCompilerState compilerState,
|
||||
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
|
||||
{bool summaryOnly}) {
|
||||
{bool summaryOnly, bool includeOffsets: true}) {
|
||||
summaryOnly ??= true;
|
||||
CompilerOptions options = compilerState.options;
|
||||
options..onDiagnostic = diagnosticMessageHandler;
|
||||
|
@ -203,13 +211,16 @@ Future<CompilerResult> _compile(InitializedCompilerState compilerState,
|
|||
processedOpts.inputs.addAll(inputs);
|
||||
|
||||
return generateKernel(processedOpts,
|
||||
buildSummary: summaryOnly, buildComponent: !summaryOnly);
|
||||
buildSummary: summaryOnly,
|
||||
buildComponent: !summaryOnly,
|
||||
includeOffsets: includeOffsets);
|
||||
}
|
||||
|
||||
Future<List<int>> compileSummary(InitializedCompilerState compilerState,
|
||||
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler) async {
|
||||
List<Uri> inputs, DiagnosticMessageHandler diagnosticMessageHandler,
|
||||
{bool includeOffsets: false}) async {
|
||||
var result = await _compile(compilerState, inputs, diagnosticMessageHandler,
|
||||
summaryOnly: true);
|
||||
summaryOnly: true, includeOffsets: includeOffsets);
|
||||
return result?.summary;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,19 +35,22 @@ import 'fasta/uri_translator.dart' show UriTranslator;
|
|||
Future<CompilerResult> generateKernel(ProcessedOptions options,
|
||||
{bool buildSummary: false,
|
||||
bool buildComponent: true,
|
||||
bool truncateSummary: false}) async {
|
||||
bool truncateSummary: false,
|
||||
bool includeOffsets: true}) async {
|
||||
return await CompilerContext.runWithOptions(options, (_) async {
|
||||
return await generateKernelInternal(
|
||||
buildSummary: buildSummary,
|
||||
buildComponent: buildComponent,
|
||||
truncateSummary: truncateSummary);
|
||||
truncateSummary: truncateSummary,
|
||||
includeOffsets: includeOffsets);
|
||||
});
|
||||
}
|
||||
|
||||
Future<CompilerResult> generateKernelInternal(
|
||||
{bool buildSummary: false,
|
||||
bool buildComponent: true,
|
||||
bool truncateSummary: false}) async {
|
||||
bool truncateSummary: false,
|
||||
bool includeOffsets: true}) async {
|
||||
var options = CompilerContext.current.options;
|
||||
var fs = options.fileSystem;
|
||||
|
||||
|
@ -138,8 +141,8 @@ Future<CompilerResult> generateKernelInternal(
|
|||
options.ticker.logMs("Transformed outline");
|
||||
}
|
||||
// Don't include source (but do add it above to include importUris).
|
||||
summary =
|
||||
serializeComponent(trimmedSummaryComponent, includeSources: false);
|
||||
summary = serializeComponent(trimmedSummaryComponent,
|
||||
includeSources: false, includeOffsets: includeOffsets);
|
||||
options.ticker.logMs("Generated outline");
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,9 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
|
||||
fe.InitializedCompilerState state;
|
||||
bool usingIncrementalCompiler = false;
|
||||
if (parsedArgs['use-incremental-compiler'] && linkedInputs.isEmpty) {
|
||||
if (parsedArgs['use-incremental-compiler'] &&
|
||||
linkedInputs.isEmpty &&
|
||||
isWorker) {
|
||||
usingIncrementalCompiler = true;
|
||||
|
||||
/// Build a map of uris to digests.
|
||||
|
@ -298,12 +300,14 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
return Future.value(fe.serializeComponent(incrementalComponent));
|
||||
});
|
||||
} else if (summaryOnly) {
|
||||
kernel = await fe.compileSummary(state, sources, onDiagnostic);
|
||||
kernel = await fe.compileSummary(state, sources, onDiagnostic,
|
||||
includeOffsets: false);
|
||||
} else {
|
||||
Component component =
|
||||
await fe.compileComponent(state, sources, onDiagnostic);
|
||||
kernel = fe.serializeComponent(component,
|
||||
filter: (library) => sources.contains(library.importUri));
|
||||
filter: (library) => sources.contains(library.importUri),
|
||||
includeOffsets: true);
|
||||
}
|
||||
|
||||
if (kernel != null) {
|
||||
|
|
Loading…
Reference in a new issue