Skip to content

Commit 32a5fa0

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
Allow incremental compiler to just create outline
Change-Id: I996787821f01f21bb41be837e6d4c25a2114e017 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95384 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Peter von der Ahé <[email protected]>
1 parent 83e6e9f commit 32a5fa0

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

pkg/front_end/lib/src/fasta/incremental_compiler.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,14 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
293293
userCode.loader.builders[entryPoints.first] != null) {
294294
userCode.loader.first = userCode.loader.builders[entryPoints.first];
295295
}
296-
await userCode.buildOutlines();
296+
Component componentWithDill = await userCode.buildOutlines();
297297

298298
// This is not the full component. It is the component including all
299299
// libraries loaded from .dill files.
300-
Component componentWithDill =
301-
await userCode.buildComponent(verify: c.options.verify);
300+
if (!outlineOnly) {
301+
componentWithDill =
302+
await userCode.buildComponent(verify: c.options.verify);
303+
}
302304
if (componentWithDill != null) {
303305
this.invalidatedUris.clear();
304306
hasToCheckPackageUris = false;

pkg/front_end/test/incremental_load_from_dill_test.dart

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import 'package:front_end/src/fasta/severity.dart' show Severity;
3333
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;
3434

3535
import 'package:kernel/kernel.dart'
36-
show Class, Component, Field, Library, Procedure;
36+
show Class, Component, EmptyStatement, Field, Library, Procedure;
3737

3838
import 'package:kernel/target/targets.dart' show TargetFlags;
3939

@@ -405,13 +405,14 @@ Future<Null> newWorldTest(
405405
entries.add(base.resolve(entry));
406406
}
407407
}
408+
bool outlineOnly = world["outlineOnly"] == true;
408409
if (brandNewWorld) {
409410
if (world["fromComponent"] == true) {
410411
compiler = new TestIncrementalCompiler.fromComponent(
411-
options, entries.first, newestWholeComponent);
412+
options, entries.first, newestWholeComponent, outlineOnly);
412413
} else {
413-
compiler =
414-
new TestIncrementalCompiler(options, entries.first, initializeFrom);
414+
compiler = new TestIncrementalCompiler(
415+
options, entries.first, initializeFrom, outlineOnly);
415416
}
416417
}
417418

@@ -434,6 +435,18 @@ Future<Null> newWorldTest(
434435
entryPoints: entries,
435436
fullComponent:
436437
brandNewWorld ? false : (noFullComponent ? false : true));
438+
if (outlineOnly) {
439+
for (Library lib in component.libraries) {
440+
for (Class c in lib.classes) {
441+
for (Procedure p in c.procedures) {
442+
if (p.function.body is! EmptyStatement) throw "Got body";
443+
}
444+
}
445+
for (Procedure p in lib.procedures) {
446+
if (p.function.body is! EmptyStatement) throw "Got body";
447+
}
448+
}
449+
}
437450
performErrorAndWarningCheck(
438451
world, gotError, formattedErrors, gotWarning, formattedWarnings);
439452
util.throwOnEmptyMixinBodies(component);
@@ -808,18 +821,20 @@ class TestIncrementalCompiler extends IncrementalCompiler {
808821
}
809822

810823
TestIncrementalCompiler(CompilerOptions options, this.entryPoint,
811-
[Uri initializeFrom])
824+
[Uri initializeFrom, bool outlineOnly])
812825
: super(
813826
new CompilerContext(
814827
new ProcessedOptions(options: options, inputs: [entryPoint])),
815-
initializeFrom);
828+
initializeFrom,
829+
outlineOnly);
816830

817831
TestIncrementalCompiler.fromComponent(CompilerOptions options,
818-
this.entryPoint, Component componentToInitializeFrom)
832+
this.entryPoint, Component componentToInitializeFrom, [bool outlineOnly])
819833
: super.fromComponent(
820834
new CompilerContext(
821835
new ProcessedOptions(options: options, inputs: [entryPoint])),
822-
componentToInitializeFrom);
836+
componentToInitializeFrom,
837+
outlineOnly);
823838

824839
@override
825840
void recordInvalidatedImportUrisForTesting(List<Uri> uris) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE.md file.
4+
5+
# Compile an application with the option of only getting an outline.
6+
7+
type: newworld
8+
strong: true
9+
worlds:
10+
- entry: main.dart
11+
sources:
12+
main.dart: |
13+
main() {
14+
print("hello");
15+
b();
16+
}
17+
outlineOnly: true

0 commit comments

Comments
 (0)