[cfe] Change computeDelta to return a result object
This prepares for returning more that just the component from an
incremental compilation.
TEST=existing
Change-Id: I3ee269083290097f1a92d77d105b607a6a02f1f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221086
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/command.dart b/pkg/dev_compiler/lib/src/kernel/command.dart
index d8435ca..eccfa92 100644
--- a/pkg/dev_compiler/lib/src/kernel/command.dart
+++ b/pkg/dev_compiler/lib/src/kernel/command.dart
@@ -338,10 +338,13 @@
result = await fe.compile(compilerState, inputs, diagnosticMessageHandler);
} else {
compilerState.options.onDiagnostic = diagnosticMessageHandler;
- var incrementalComponent = await incrementalCompiler.computeDelta(
+ var incrementalCompilerResult = await incrementalCompiler.computeDelta(
entryPoints: inputs, fullComponent: true);
- result = fe.DdcResult(incrementalComponent, cachedSdkInput.component,
- doneAdditionalDills, incrementalCompiler.userCode.loader.hierarchy);
+ result = fe.DdcResult(
+ incrementalCompilerResult.component,
+ cachedSdkInput.component,
+ doneAdditionalDills,
+ incrementalCompiler.userCode.loader.hierarchy);
}
compilerState.options.onDiagnostic = null; // See http://dartbug.com/36983.
diff --git a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
index 1068a8a..864b911 100644
--- a/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
+++ b/pkg/dev_compiler/lib/src/kernel/expression_compiler_worker.dart
@@ -357,8 +357,9 @@
var incrementalCompiler = IncrementalCompiler.forExpressionCompilationOnly(
CompilerContext(_processedOptions), component, /*resetTicker*/ false);
- var finalComponent = await incrementalCompiler
+ var incrementalCompilerResult = await incrementalCompiler
.computeDelta(entryPoints: [libraryUri], fullComponent: true);
+ var finalComponent = incrementalCompilerResult.component;
assert(!duplicateLibrariesReachable(finalComponent.libraries));
assert(_canSerialize(finalComponent));
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
index 7c5152d..46bc90a 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_e2e_suite.dart
@@ -117,7 +117,8 @@
// compilers/components/names per module.
setup.options.packagesFileUri = packages;
var compiler = DevelopmentIncrementalCompiler(setup.options, input);
- var component = await compiler.computeDelta();
+ var compilerResult = await compiler.computeDelta();
+ var component = compilerResult.component;
component.computeCanonicalNames();
// Initialize DDC.
var moduleName = p.basenameWithoutExtension(output.toFilePath());
diff --git a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
index 66db5dd..5f96bcb 100644
--- a/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
+++ b/pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart
@@ -76,7 +76,8 @@
// initialize incremental compiler and create component
setup.options.packagesFileUri = packages;
var compiler = DevelopmentIncrementalCompiler(setup.options, input);
- var component = await compiler.computeDelta();
+ var compilerResult = await compiler.computeDelta();
+ var component = compilerResult.component;
component.computeCanonicalNames();
// initialize ddc
diff --git a/pkg/dev_compiler/test/module_symbols/module_symbols_test_shared.dart b/pkg/dev_compiler/test/module_symbols/module_symbols_test_shared.dart
index 4fb6eb6..a989d55 100644
--- a/pkg/dev_compiler/test/module_symbols/module_symbols_test_shared.dart
+++ b/pkg/dev_compiler/test/module_symbols/module_symbols_test_shared.dart
@@ -21,7 +21,8 @@
// Initialize incremental compiler and create component.
setup.options.packagesFileUri = packages;
var compiler = DevelopmentIncrementalCompiler(setup.options, input);
- var component = await compiler.computeDelta();
+ var compilerResult = await compiler.computeDelta();
+ var component = compilerResult.component;
component.computeCanonicalNames();
var errors = setup.errors.where((e) => e.contains('Error'));
if (errors.isNotEmpty) {
diff --git a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
index d28d71c..dfd05f4 100644
--- a/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
+++ b/pkg/front_end/lib/src/api_prototype/incremental_kernel_generator.dart
@@ -70,9 +70,11 @@
component);
}
- /// Returns a component whose libraries are the recompiled libraries,
- /// or - in the case of [fullComponent] - a full Component.
- Future<Component> computeDelta({List<Uri>? entryPoints, bool fullComponent});
+ /// Returns an [IncrementalCompilerResult] with the component whose libraries
+ /// are the recompiled libraries, or - in the case of [fullComponent] - a full
+ /// Component.
+ Future<IncrementalCompilerResult> computeDelta(
+ {List<Uri>? entryPoints, bool fullComponent});
/// Returns [CoreTypes] used during compilation.
/// Valid after [computeDelta] is called.
@@ -149,3 +151,9 @@
bool isLegalIdentifier(String identifier) {
return StringScanner.isLegalIdentifier(identifier);
}
+
+class IncrementalCompilerResult {
+ final Component component;
+
+ IncrementalCompilerResult(this.component);
+}
diff --git a/pkg/front_end/lib/src/api_unstable/vm.dart b/pkg/front_end/lib/src/api_unstable/vm.dart
index 141014c..b9b4ca7 100644
--- a/pkg/front_end/lib/src/api_unstable/vm.dart
+++ b/pkg/front_end/lib/src/api_unstable/vm.dart
@@ -24,7 +24,11 @@
export '../api_prototype/front_end.dart' show CompilerResult;
export '../api_prototype/incremental_kernel_generator.dart'
- show IncrementalKernelGenerator, IncrementalSerializer, isLegalIdentifier;
+ show
+ IncrementalCompilerResult,
+ IncrementalKernelGenerator,
+ IncrementalSerializer,
+ isLegalIdentifier;
export '../api_prototype/kernel_generator.dart'
show kernelForModule, kernelForProgram;
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index e383ceb..747a3af 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -62,7 +62,10 @@
import '../api_prototype/file_system.dart' show FileSystem, FileSystemEntity;
import '../api_prototype/incremental_kernel_generator.dart'
- show IncrementalKernelGenerator, isLegalIdentifier;
+ show
+ IncrementalCompilerResult,
+ IncrementalKernelGenerator,
+ isLegalIdentifier;
import '../api_prototype/lowering_predicates.dart' show isExtensionThisName;
@@ -242,7 +245,7 @@
}
@override
- Future<Component> computeDelta(
+ Future<IncrementalCompilerResult> computeDelta(
{List<Uri>? entryPoints, bool fullComponent: false}) async {
while (_currentlyCompiling != null) {
await _currentlyCompiling!.future;
@@ -252,7 +255,8 @@
_ticker.reset();
}
entryPoints ??= context.options.inputs;
- return context.runInContext<Component>((CompilerContext c) async {
+ return context
+ .runInContext<IncrementalCompilerResult>((CompilerContext c) async {
if (_computeDeltaRunOnce && _initializedForExpressionCompilationOnly) {
throw new StateError("Initialized for expression compilation: "
"cannot do another general compile.");
@@ -415,7 +419,7 @@
_currentlyCompiling = null;
currentlyCompilingLocal.complete();
- return result;
+ return new IncrementalCompilerResult(result);
});
}
diff --git a/pkg/front_end/test/ast_nodes_has_to_string_test.dart b/pkg/front_end/test/ast_nodes_has_to_string_test.dart
index d9ddaba..de8baa2 100644
--- a/pkg/front_end/test/ast_nodes_has_to_string_test.dart
+++ b/pkg/front_end/test/ast_nodes_has_to_string_test.dart
@@ -5,6 +5,7 @@
import 'dart:io' show File, Platform, stdin, exitCode;
import 'package:front_end/src/api_prototype/compiler_options.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:kernel/ast.dart';
import 'package:kernel/class_hierarchy.dart';
@@ -26,7 +27,8 @@
helper.TestIncrementalCompiler compiler =
new helper.TestIncrementalCompiler(options, input,
/*Uri initializeFrom*/ null, /*bool outlineOnly*/ true);
- c = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ c = compilerResult.component;
classHierarchy = compiler.getClassHierarchy()!;
List<Library> libraries = c.libraries
.where((Library lib) =>
diff --git a/pkg/front_end/test/async_but_no_await_git_test.dart b/pkg/front_end/test/async_but_no_await_git_test.dart
index d83191f..6721ee1 100644
--- a/pkg/front_end/test/async_but_no_await_git_test.dart
+++ b/pkg/front_end/test/async_but_no_await_git_test.dart
@@ -6,6 +6,8 @@
import 'package:_fe_analyzer_shared/src/messages/severity.dart';
import 'package:front_end/src/api_prototype/compiler_options.dart' as api;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
import 'package:front_end/src/base/processed_options.dart';
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
@@ -58,8 +60,8 @@
IncrementalCompiler compiler =
new IncrementalCompiler(new CompilerContext(options));
- Component component = await compiler.computeDelta();
-
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component component = compilerResult.component;
component.accept(new AsyncNoAwaitVisitor());
print("Done in ${stopwatch.elapsedMilliseconds} ms. "
diff --git a/pkg/front_end/test/comments_on_certain_arguments_tool.dart b/pkg/front_end/test/comments_on_certain_arguments_tool.dart
index 49d1ecbe..254ff7d 100644
--- a/pkg/front_end/test/comments_on_certain_arguments_tool.dart
+++ b/pkg/front_end/test/comments_on_certain_arguments_tool.dart
@@ -17,6 +17,8 @@
import 'package:front_end/src/api_prototype/file_system.dart' as api
show FileSystem;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
@@ -81,7 +83,9 @@
CompilerContext context = new CompilerContext(options);
IncrementalCompiler incrementalCompiler =
new TestIncrementalCompiler(context);
- component = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult incrementalCompilerResult =
+ await incrementalCompiler.computeDelta();
+ component = incrementalCompilerResult.component;
for (Library library in component.libraries) {
if (library.importUri.scheme == "dart") continue;
diff --git a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart
index f97de4b..2991e70 100644
--- a/pkg/front_end/test/crashing_test_case_minimizer_impl.dart
+++ b/pkg/front_end/test/crashing_test_case_minimizer_impl.dart
@@ -34,6 +34,9 @@
import 'package:front_end/src/api_prototype/file_system.dart'
show FileSystem, FileSystemEntity, FileSystemException;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
+
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
import 'package:front_end/src/fasta/builder/library_builder.dart';
@@ -1826,7 +1829,9 @@
}
incrementalCompiler.invalidate(_mainUri);
try {
- _latestComponent = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult incrementalCompilerResult =
+ await incrementalCompiler.computeDelta();
+ _latestComponent = incrementalCompilerResult.component;
if (_settings.serialize) {
// We're asked to serialize, probably because it crashes in
// serialization.
@@ -1839,7 +1844,9 @@
for (Uri uri in _settings.invalidate) {
incrementalCompiler.invalidate(uri);
- Component delta = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult deltaResult =
+ await incrementalCompiler.computeDelta();
+ Component delta = deltaResult.component;
if (_settings.serialize) {
// We're asked to serialize, probably because it crashes in
// serialization.
@@ -1926,7 +1933,9 @@
Future<Component> _getInitialComponent() async {
IncrementalCompiler incrementalCompiler =
new IncrementalCompiler(_setupCompilerContext());
- Component originalComponent = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult incrementalCompilerResult =
+ await incrementalCompiler.computeDelta();
+ Component originalComponent = incrementalCompilerResult.component;
return originalComponent;
}
diff --git a/pkg/front_end/test/fasta/expression_suite.dart b/pkg/front_end/test/fasta/expression_suite.dart
index bc3fb8e..371e8ef 100644
--- a/pkg/front_end/test/fasta/expression_suite.dart
+++ b/pkg/front_end/test/fasta/expression_suite.dart
@@ -370,8 +370,9 @@
}
var sourceCompiler = new IncrementalCompiler(context.compilerContext);
- Component component =
+ var sourceCompilerResult =
await sourceCompiler.computeDelta(entryPoints: [test.entryPoint!]);
+ Component component = sourceCompilerResult.component;
var errors = context.takeErrors();
if (!errors.isEmpty) {
return fail(tests, "Couldn't compile entry-point: $errors");
@@ -389,8 +390,9 @@
var dillCompiler =
new IncrementalCompiler(context.compilerContext, dillFileUri);
- component =
+ var dillCompilerResult =
await dillCompiler.computeDelta(entryPoints: [test.entryPoint!]);
+ component = dillCompilerResult.component;
component.computeCanonicalNames();
await dillFile.delete();
diff --git a/pkg/front_end/test/fasta/incremental_dartino_suite.dart b/pkg/front_end/test/fasta/incremental_dartino_suite.dart
index 2f7c9f6..d6483bb 100644
--- a/pkg/front_end/test/fasta/incremental_dartino_suite.dart
+++ b/pkg/front_end/test/fasta/incremental_dartino_suite.dart
@@ -152,8 +152,9 @@
return edits == 0 ? fail(test, "No sources found") : pass(test);
}
var compiler = context.compiler;
- Component component =
+ var compilerResult =
await compiler.computeDelta(entryPoints: [entryPoint]);
+ Component component = compilerResult.component;
List<DiagnosticMessage> errors = context.takeErrors();
if (test.expectations![edits].hasCompileTimeError) {
if (errors.isEmpty) {
diff --git a/pkg/front_end/test/fasta/incremental_hello_test.dart b/pkg/front_end/test/fasta/incremental_hello_test.dart
index ea8e04c..125ef12 100644
--- a/pkg/front_end/test/fasta/incremental_hello_test.dart
+++ b/pkg/front_end/test/fasta/incremental_hello_test.dart
@@ -8,6 +8,9 @@
import 'package:expect/expect.dart' show Expect;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
+
import 'package:kernel/ast.dart' show Component;
import 'package:kernel/target/targets.dart' show TargetFlags;
@@ -58,7 +61,8 @@
IncrementalCompiler compiler =
new IncrementalCompiler(new CompilerContext(options));
- Component component = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component component = compilerResult.component;
if (sdkFromSource) {
// Expect that the new component contains at least the following libraries:
@@ -73,12 +77,14 @@
compiler.invalidate(helloDart);
- component = await compiler.computeDelta(entryPoints: [helloDart]);
+ compilerResult = await compiler.computeDelta(entryPoints: [helloDart]);
+ component = compilerResult.component;
// Expect that the new component contains exactly hello.dart
Expect.isTrue(
component.libraries.length == 1, "${component.libraries.length} != 1");
- component = await compiler.computeDelta(entryPoints: [helloDart]);
+ compilerResult = await compiler.computeDelta(entryPoints: [helloDart]);
+ component = compilerResult.component;
Expect.isTrue(component.libraries.isEmpty);
}
diff --git a/pkg/front_end/test/fasta/testing/suite.dart b/pkg/front_end/test/fasta/testing/suite.dart
index 722b25f..7a4b070 100644
--- a/pkg/front_end/test/fasta/testing/suite.dart
+++ b/pkg/front_end/test/fasta/testing/suite.dart
@@ -40,6 +40,9 @@
import 'package:front_end/src/api_prototype/file_system.dart'
show FileSystem, FileSystemEntity, FileSystemException;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
+
import 'package:front_end/src/api_prototype/standard_file_system.dart'
show StandardFileSystem;
@@ -1207,7 +1210,9 @@
IncrementalCompiler incrementalCompiler =
new IncrementalCompiler.fromComponent(
new CompilerContext(compilationSetup.options), platform);
- final Component component = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult incrementalCompilerResult =
+ await incrementalCompiler.computeDelta();
+ final Component component = incrementalCompilerResult.component;
if (!canSerialize(component)) {
return new Result<ComponentResult>(result, semiFuzzFailure,
"Couldn't serialize initial component for fuzzing");
@@ -1237,8 +1242,9 @@
compilationSetup.errors.clear();
for (Uri importUri in userLibraries) {
incrementalCompiler.invalidate(importUri);
- final Component newComponent =
+ final IncrementalCompilerResult newResult =
await incrementalCompiler.computeDelta(fullComponent: true);
+ final Component newComponent = newResult.component;
if (!canSerialize(newComponent)) {
return new Result<ComponentResult>(
result, semiFuzzFailure, "Couldn't serialize fuzzed component");
@@ -1329,7 +1335,9 @@
IncrementalCompiler incrementalCompiler =
new IncrementalCompiler.fromComponent(
new CompilerContext(compilationSetup.options), platform);
- Component initialComponent = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult initialResult =
+ await incrementalCompiler.computeDelta();
+ Component initialComponent = initialResult.component;
if (!canSerialize(initialComponent)) {
return new Result<ComponentResult>(result, semiFuzzFailure,
"Couldn't serialize initial component for fuzzing");
@@ -1392,7 +1400,9 @@
incrementalCompiler = new IncrementalCompiler.fromComponent(
new CompilerContext(compilationSetup.options), platform);
try {
- Component component = await incrementalCompiler.computeDelta();
+ IncrementalCompilerResult incrementalCompilerResult =
+ await incrementalCompiler.computeDelta();
+ Component component = incrementalCompilerResult.component;
if (!canSerialize(component)) {
return new Result<ComponentResult>(
result, semiFuzzFailure, "Couldn't serialize fuzzed component");
diff --git a/pkg/front_end/test/hot_reload_e2e_test.dart b/pkg/front_end/test/hot_reload_e2e_test.dart
index 105abbc..69069c9 100644
--- a/pkg/front_end/test/hot_reload_e2e_test.dart
+++ b/pkg/front_end/test/hot_reload_e2e_test.dart
@@ -316,7 +316,8 @@
compiler.invalidate(Uri.parse("org-dartlang-test:///a.dart"));
compiler.invalidate(Uri.parse("org-dartlang-test:///b.dart"));
compiler.invalidate(Uri.parse("org-dartlang-test:///c.dart"));
- var component = await compiler.computeDelta();
+ var compilerResult = await compiler.computeDelta();
+ var component = compilerResult.component;
if (!component.libraries.isEmpty) {
await writeProgram(component, outputUri);
return true;
diff --git a/pkg/front_end/test/incremental_bulk_compiler_full.dart b/pkg/front_end/test/incremental_bulk_compiler_full.dart
index ce9a726..9edfd97 100644
--- a/pkg/front_end/test/incremental_bulk_compiler_full.dart
+++ b/pkg/front_end/test/incremental_bulk_compiler_full.dart
@@ -8,7 +8,7 @@
show CompilerOptions, DiagnosticMessage;
import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
- show IncrementalKernelGenerator;
+ show IncrementalCompilerResult, IncrementalKernelGenerator;
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
@@ -77,7 +77,8 @@
try {
IncrementalKernelGenerator compiler =
new IncrementalKernelGenerator(getOptions(), uri);
- oneShotSerialized = util.postProcess(await compiler.computeDelta());
+ oneShotSerialized =
+ util.postProcess((await compiler.computeDelta()).component);
} catch (e) {
oneShotFailed = true;
}
@@ -90,8 +91,9 @@
if (context.compiler == null) {
context.compiler = new IncrementalKernelGenerator(getOptions(), uri);
}
- Component bulkCompiledComponent = await context.compiler!
+ IncrementalCompilerResult compilerResult = await context.compiler!
.computeDelta(entryPoints: [uri], fullComponent: true);
+ Component bulkCompiledComponent = compilerResult.component;
bulkSerialized = util.postProcess(bulkCompiledComponent);
} catch (e) {
bulkFailed = true;
@@ -106,8 +108,9 @@
if (context.compiler == null) {
context.compiler = new IncrementalKernelGenerator(getOptions(), uri);
}
- Component bulkCompiledComponent = await context.compiler!
+ IncrementalCompilerResult compilerResult = await context.compiler!
.computeDelta(entryPoints: [uri], fullComponent: true);
+ Component bulkCompiledComponent = compilerResult.component;
bulkSerialized2 = util.postProcess(bulkCompiledComponent);
} catch (e) {
bulk2Failed = true;
diff --git a/pkg/front_end/test/incremental_dart2js_tester.dart b/pkg/front_end/test/incremental_dart2js_tester.dart
index 9ecdb51..0e6717f 100644
--- a/pkg/front_end/test/incremental_dart2js_tester.dart
+++ b/pkg/front_end/test/incremental_dart2js_tester.dart
@@ -7,6 +7,9 @@
import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:front_end/src/api_prototype/experimental_flags.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
+
import 'package:front_end/src/fasta/kernel/utils.dart';
import 'package:kernel/kernel.dart'
@@ -89,7 +92,9 @@
print("Invalidating $uri ($i)");
compiler.invalidate(uri);
localStopwatch.reset();
- Component c2 = await compiler.computeDelta(fullComponent: true);
+ IncrementalCompilerResult compilerResult =
+ await compiler.computeDelta(fullComponent: true);
+ Component c2 = compilerResult.component;
print("Recompiled in ${localStopwatch.elapsedMilliseconds} ms");
print("invalidatedImportUrisForTesting: "
"${compiler.invalidatedImportUrisForTesting}");
@@ -180,7 +185,8 @@
.alternativeInvalidationStrategy] = useExperimentalInvalidation;
helper.TestIncrementalCompiler compiler =
new helper.TestIncrementalCompiler(options, input);
- Component? c = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component? c = compilerResult.component;
print("Compiled dart2js to Component with ${c.libraries.length} libraries "
"in ${stopwatch.elapsedMilliseconds} ms.");
stopwatch.reset();
diff --git a/pkg/front_end/test/incremental_flutter_tester.dart b/pkg/front_end/test/incremental_flutter_tester.dart
index fc01452..fc572aa3 100644
--- a/pkg/front_end/test/incremental_flutter_tester.dart
+++ b/pkg/front_end/test/incremental_flutter_tester.dart
@@ -7,6 +7,8 @@
import 'package:front_end/src/api_prototype/compiler_options.dart'
show CompilerOptions, DiagnosticMessage;
import 'package:front_end/src/api_prototype/experimental_flags.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
@@ -82,7 +84,8 @@
.alternativeInvalidationStrategy] = useExperimentalInvalidation;
helper.TestIncrementalCompiler compiler =
new helper.TestIncrementalCompiler(options, inputFile.uri);
- Component? c = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component? c = compilerResult.component;
print("Compiled to Component with ${c.libraries.length} "
"libraries in ${stopwatch.elapsedMilliseconds} ms.");
stopwatch.reset();
@@ -132,7 +135,9 @@
print("Invalidating $uri ($i)");
compiler.invalidate(uri);
localStopwatch.reset();
- Component c2 = await compiler.computeDelta(fullComponent: true);
+ IncrementalCompilerResult compilerResult =
+ await compiler.computeDelta(fullComponent: true);
+ Component c2 = compilerResult.component;
print("Recompiled in ${localStopwatch.elapsedMilliseconds} ms");
print("invalidatedImportUrisForTesting: "
"${compiler.invalidatedImportUrisForTesting}");
diff --git a/pkg/front_end/test/incremental_load_from_invalid_dill_test.dart b/pkg/front_end/test/incremental_load_from_invalid_dill_test.dart
index 3d96399..1de80e9 100644
--- a/pkg/front_end/test/incremental_load_from_invalid_dill_test.dart
+++ b/pkg/front_end/test/incremental_load_from_invalid_dill_test.dart
@@ -17,6 +17,9 @@
import 'package:front_end/src/api_prototype/experimental_flags.dart'
show ExperimentalFlag;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
+
import "package:front_end/src/api_prototype/memory_file_system.dart"
show MemoryFileSystem;
@@ -106,7 +109,8 @@
new CompilerContext(
new ProcessedOptions(options: options, inputs: [compileThis])),
initializeFrom);
- Component component = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component component = compilerResult.component;
if (compiler.initializedFromDill != initializedFromDill) {
Expect.fail("Expected initializedFromDill to be $initializedFromDill "
@@ -181,7 +185,9 @@
new ProcessedOptions(options: options, inputs: [entryPoint])),
initializeFrom);
- Component componentGood = await compiler.computeDelta();
+ IncrementalCompilerResult compilerGoodResult =
+ await compiler.computeDelta();
+ Component componentGood = compilerGoodResult.component;
List<int> dataGood = serializeComponent(componentGood);
fs.entityForUri(initializeFrom).writeAsBytesSync(dataGood);
@@ -191,7 +197,9 @@
new CompilerContext(
new ProcessedOptions(options: options, inputs: [helper2File])),
initializeFrom);
- Component componentHelper = await compiler.computeDelta();
+ IncrementalCompilerResult compilerHelperResult =
+ await compiler.computeDelta();
+ Component componentHelper = compilerHelperResult.component;
Library helper2Lib = componentHelper.libraries
.firstWhere((lib) => lib.importUri == helper2File);
helper2Lib.importUri = new Uri(scheme: "dart", path: "foo");
@@ -214,7 +222,8 @@
// Create a partial dill file.
compiler.invalidate(entryPoint);
- component = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ component = compilerResult.component;
if (component.libraries.length != 1) {
Expect.fail("Expected 1 library, got ${component.libraries.length}: "
"${component.libraries}");
@@ -257,7 +266,9 @@
new CompilerContext(
new ProcessedOptions(options: options, inputs: [helper2File])),
null);
- Component c = await compiler.computeDelta();
+
+ IncrementalCompilerResult result = await compiler.computeDelta();
+ Component c = result.component;
c.setMainMethodAndMode(
null, false, NonNullableByDefaultCompiledMode.Weak);
mixedPart1 = serializeComponent(c);
@@ -279,7 +290,8 @@
new CompilerContext(
new ProcessedOptions(options: options, inputs: [helperFile])),
null);
- Component c = await compiler.computeDelta();
+ IncrementalCompilerResult result = await compiler.computeDelta();
+ Component c = result.component;
c.setMainMethodAndMode(
null, false, NonNullableByDefaultCompiledMode.Strong);
mixedPart2 = serializeComponent(c);
diff --git a/pkg/front_end/test/incremental_suite.dart b/pkg/front_end/test/incremental_suite.dart
index 2ce5c81..9c6d54f 100644
--- a/pkg/front_end/test/incremental_suite.dart
+++ b/pkg/front_end/test/incremental_suite.dart
@@ -24,7 +24,8 @@
import 'package:front_end/src/api_prototype/experimental_flags.dart'
show ExperimentalFlag, experimentEnabledVersion;
-
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
import "package:front_end/src/api_prototype/memory_file_system.dart"
show MemoryFileSystem, MemoryFileSystemEntity;
@@ -355,7 +356,9 @@
}
TestIncrementalCompiler compiler = new TestIncrementalCompiler(
options, moduleSources.first, /* initializeFrom = */ null, outlineOnly);
- Component c = await compiler.computeDelta(entryPoints: moduleSources);
+ IncrementalCompilerResult compilerResult =
+ await compiler.computeDelta(entryPoints: moduleSources);
+ Component c = compilerResult.component;
c.computeCanonicalNames();
List<Library> wantedLibs = <Library>[];
for (Library lib in c.libraries) {
@@ -664,11 +667,12 @@
}
Stopwatch stopwatch = new Stopwatch()..start();
- component = await compiler!.computeDelta(
+ IncrementalCompilerResult compilerResult = await compiler!.computeDelta(
entryPoints: entries,
fullComponent:
brandNewWorld ? false : (noFullComponent ? false : true),
simulateTransformer: world["simulateTransformer"]);
+ component = compilerResult.component;
if (outlineOnly && !skipOutlineBodyCheck) {
for (Library lib in component!.libraries) {
for (Class c in lib.classes) {
@@ -934,10 +938,11 @@
if (!noFullComponent) {
clearPrevErrorsEtc();
- component2 = await compiler.computeDelta(
+ IncrementalCompilerResult compilerResult2 = await compiler.computeDelta(
entryPoints: entries,
fullComponent: true,
simulateTransformer: world["simulateTransformer"]);
+ component2 = compilerResult2.component;
Result<TestData>? result = performErrorAndWarningCheck(world, data,
gotError, formattedErrors, gotWarning, formattedWarnings);
if (result != null) return result;
@@ -1047,9 +1052,11 @@
}
Stopwatch stopwatch = new Stopwatch()..start();
- component3 = await compilerFromScratch.computeDelta(
- entryPoints: entries,
- simulateTransformer: world["simulateTransformer"]);
+ IncrementalCompilerResult compilerResult3 =
+ await compilerFromScratch.computeDelta(
+ entryPoints: entries,
+ simulateTransformer: world["simulateTransformer"]);
+ component3 = compilerResult3.component;
compilerFromScratch = null;
Result<TestData>? result = performErrorAndWarningCheck(world, data,
gotError, formattedErrors, gotWarning, formattedWarnings);
@@ -1787,7 +1794,7 @@
{CompilerOptions? options, IncrementalCompiler? compiler}) async {
options ??= getOptions();
compiler ??= new TestIncrementalCompiler(options, input);
- return await compiler.computeDelta();
+ return (await compiler.computeDelta()).component;
}
Future<bool> initializedCompile(
@@ -1799,7 +1806,9 @@
for (Uri invalidateUri in invalidateUris) {
compiler.invalidate(invalidateUri);
}
- Component initializedComponent = await compiler.computeDelta();
+ IncrementalCompilerResult initializedCompilerResult =
+ await compiler.computeDelta();
+ Component initializedComponent = initializedCompilerResult.component;
util.throwOnEmptyMixinBodies(initializedComponent);
await util.throwOnInsufficientUriToSource(initializedComponent);
bool result = compiler.initializedFromDill;
@@ -1814,8 +1823,9 @@
"got $actuallyInvalidatedCount");
}
- Component initializedFullComponent =
+ IncrementalCompilerResult initializedFullCompilerResult =
await compiler.computeDelta(fullComponent: true);
+ Component initializedFullComponent = initializedFullCompilerResult.component;
util.throwOnEmptyMixinBodies(initializedFullComponent);
await util.throwOnInsufficientUriToSource(initializedFullComponent);
Expect.equals(initializedComponent.libraries.length,
@@ -1827,7 +1837,8 @@
compiler.invalidate(invalidateUri);
}
- Component partialComponent = await compiler.computeDelta();
+ IncrementalCompilerResult partialResult = await compiler.computeDelta();
+ Component partialComponent = partialResult.component;
util.throwOnEmptyMixinBodies(partialComponent);
await util.throwOnInsufficientUriToSource(partialComponent);
actuallyInvalidatedCount = (compiler
@@ -1839,7 +1850,8 @@
"got $actuallyInvalidatedCount");
}
- Component emptyComponent = await compiler.computeDelta();
+ IncrementalCompilerResult emptyResult = await compiler.computeDelta();
+ Component emptyComponent = emptyResult.component;
util.throwOnEmptyMixinBodies(emptyComponent);
await util.throwOnInsufficientUriToSource(emptyComponent);
@@ -1933,11 +1945,11 @@
}
@override
- Future<Component> computeDelta(
+ Future<IncrementalCompilerResult> computeDelta(
{List<Uri>? entryPoints,
bool fullComponent = false,
bool? simulateTransformer}) async {
- Component result = await super
+ IncrementalCompilerResult result = await super
.computeDelta(entryPoints: entryPoints, fullComponent: fullComponent);
// We should at least have the SDK builders available. Slight smoke test.
@@ -1949,7 +1961,7 @@
}
if (simulateTransformer == true) {
- doSimulateTransformer(result);
+ doSimulateTransformer(result.component);
}
return result;
}
diff --git a/pkg/front_end/test/multiple_simultaneous_compiles_test.dart b/pkg/front_end/test/multiple_simultaneous_compiles_test.dart
index f2ea8f96..85d1d8c 100644
--- a/pkg/front_end/test/multiple_simultaneous_compiles_test.dart
+++ b/pkg/front_end/test/multiple_simultaneous_compiles_test.dart
@@ -4,6 +4,8 @@
import 'dart:io' show File, Platform;
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart'
+ show IncrementalCompilerResult;
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
@@ -69,7 +71,8 @@
} else {
compiler.invalidateAllSources();
}
- Component result = await compiler.computeDelta();
+ IncrementalCompilerResult compilerResult = await compiler.computeDelta();
+ Component result = compilerResult.component;
print("Now compile is done!");
return result;
}
diff --git a/pkg/front_end/test/test_generator_test.dart b/pkg/front_end/test/test_generator_test.dart
index 73cd4e9..569620a 100644
--- a/pkg/front_end/test/test_generator_test.dart
+++ b/pkg/front_end/test/test_generator_test.dart
@@ -5,6 +5,7 @@
import 'dart:io' show exitCode, File, stdout;
import 'package:front_end/src/api_prototype/compiler_options.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:front_end/src/api_prototype/memory_file_system.dart';
import 'package:front_end/src/compute_platform_binaries_location.dart';
import 'package:front_end/src/fasta/kernel/utils.dart';
@@ -90,7 +91,9 @@
StringBuffer sb = new StringBuffer();
fs.entityForUri(testUri).writeAsStringSync(src);
compiler.invalidate(testUri);
- Component result = await compiler.computeDelta(entryPoints: [testUri]);
+ IncrementalCompilerResult compilerResult =
+ await compiler.computeDelta(entryPoints: [testUri]);
+ Component result = compilerResult.component;
Iterator<Code> codeIterator = formattedWarningsCodes.iterator;
for (String warning in formattedWarnings) {
codeIterator.moveNext();
diff --git a/pkg/front_end/tool/dart_doctest_impl.dart b/pkg/front_end/tool/dart_doctest_impl.dart
index 1e51b84..a3bcdba 100644
--- a/pkg/front_end/tool/dart_doctest_impl.dart
+++ b/pkg/front_end/tool/dart_doctest_impl.dart
@@ -28,6 +28,7 @@
import 'package:front_end/src/api_prototype/compiler_options.dart';
import 'package:front_end/src/api_prototype/file_system.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:front_end/src/api_prototype/memory_file_system.dart';
import 'package:front_end/src/api_prototype/standard_file_system.dart';
import 'package:front_end/src/base/processed_options.dart';
@@ -160,8 +161,9 @@
incrementalCompiler!.invalidate(processedOpts.packagesUri);
Stopwatch stopwatch = new Stopwatch()..start();
- kernel.Component component =
+ IncrementalCompilerResult compilerResult =
await incrementalCompiler!.computeDelta(entryPoints: [uri]);
+ kernel.Component component = compilerResult.component;
if (errors) {
_print("Got errors in ${stopwatch.elapsedMilliseconds} ms.");
return [
@@ -181,8 +183,9 @@
.writeAsStringSync(mainFileContent);
incrementalCompiler!.invalidate(dartDocMainUri);
- kernel.Component componentMain = await incrementalCompiler!
+ IncrementalCompilerResult compilerMainResult = await incrementalCompiler!
.computeDelta(entryPoints: [dartDocMainUri], fullComponent: true);
+ kernel.Component componentMain = compilerMainResult.component;
if (errors) {
_print("Got errors in ${stopwatch.elapsedMilliseconds} ms.");
return [
@@ -806,8 +809,9 @@
_dartDocTestCode = dartDocTestCode;
invalidate(dartDocTestUri);
- kernel.Component result = await computeDelta(
+ IncrementalCompilerResult compilerResult = await computeDelta(
entryPoints: [dartDocTestUri], fullComponent: true);
+ kernel.Component result = compilerResult.component;
_dartDocTestLibraryBuilder = null;
_dartDocTestCode = null;
diff --git a/pkg/front_end/tool/incremental_perf.dart b/pkg/front_end/tool/incremental_perf.dart
index e3dda75..6b91a96 100644
--- a/pkg/front_end/tool/incremental_perf.dart
+++ b/pkg/front_end/tool/incremental_perf.dart
@@ -125,7 +125,8 @@
collector.start("Initial compilation");
var generator = new IncrementalKernelGenerator(compilerOptions, entryUri);
- var component = await generator.computeDelta();
+ var compilerResult = await generator.computeDelta();
+ var component = compilerResult.component;
collector.stop("Initial compilation");
if (verbose) {
print("Libraries changed: ${component.libraries.length}");
@@ -139,7 +140,8 @@
await applyEdits(
changeSet.edits, overlayFs, generator, uriTranslator, verbose);
collector.start(name);
- component = await generator.computeDelta();
+ compilerResult = await generator.computeDelta();
+ component = compilerResult.component;
collector.stop(name);
if (verbose) {
print("Change '${changeSet.name}' - "
diff --git a/pkg/frontend_server/lib/compute_kernel.dart b/pkg/frontend_server/lib/compute_kernel.dart
index 9b60711..9c08de2 100644
--- a/pkg/frontend_server/lib/compute_kernel.dart
+++ b/pkg/frontend_server/lib/compute_kernel.dart
@@ -15,6 +15,7 @@
import 'package:build_integration/file_system/multi_root.dart';
import 'package:compiler/src/kernel/dart2js_target.dart';
import 'package:dev_compiler/src/kernel/target.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
import 'package:front_end/src/api_unstable/bazel_worker.dart' as fe;
import 'package:kernel/ast.dart' show Component, Library, Reference;
import 'package:kernel/target/targets.dart';
@@ -277,8 +278,10 @@
bool wroteUsedDills = false;
if (usingIncrementalCompiler) {
state.options.onDiagnostic = onDiagnostic;
- Component incrementalComponent = await state.incrementalCompiler
+ IncrementalCompilerResult incrementalCompilerResult = await state
+ .incrementalCompiler
.computeDelta(entryPoints: sources, fullComponent: true);
+ Component incrementalComponent = incrementalCompilerResult.component;
if (recordUsedInputs) {
Set<Uri> usedOutlines = {};
diff --git a/pkg/vm/lib/incremental_compiler.dart b/pkg/vm/lib/incremental_compiler.dart
index 3ad1270..2bf3af3 100644
--- a/pkg/vm/lib/incremental_compiler.dart
+++ b/pkg/vm/lib/incremental_compiler.dart
@@ -66,8 +66,9 @@
_entryPoint = entryPoint ?? _entryPoint;
List<Uri>? entryPoints;
if (entryPoint != null) entryPoints = [entryPoint];
- Component component = await _generator.computeDelta(
+ IncrementalCompilerResult compilerResult = await _generator.computeDelta(
entryPoints: entryPoints, fullComponent: fullComponent);
+ Component component = compilerResult.component;
initialized = true;
fullComponent = false;
_pendingDeltas.add(component);