Skip to content

Commit

Permalink
Allow incremental compiler to just create outline
Browse files Browse the repository at this point in the history
Change-Id: I996787821f01f21bb41be837e6d4c25a2114e017
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95384
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
  • Loading branch information
jensjoha authored and commit-bot@chromium.org committed Mar 28, 2019
1 parent 83e6e9f commit 32a5fa0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 11 deletions.
8 changes: 5 additions & 3 deletions pkg/front_end/lib/src/fasta/incremental_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,14 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
userCode.loader.builders[entryPoints.first] != null) {
userCode.loader.first = userCode.loader.builders[entryPoints.first];
}
await userCode.buildOutlines();
Component componentWithDill = await userCode.buildOutlines();

// This is not the full component. It is the component including all
// libraries loaded from .dill files.
Component componentWithDill =
await userCode.buildComponent(verify: c.options.verify);
if (!outlineOnly) {
componentWithDill =
await userCode.buildComponent(verify: c.options.verify);
}
if (componentWithDill != null) {
this.invalidatedUris.clear();
hasToCheckPackageUris = false;
Expand Down
31 changes: 23 additions & 8 deletions pkg/front_end/test/incremental_load_from_dill_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import 'package:front_end/src/fasta/severity.dart' show Severity;
import 'package:kernel/binary/ast_from_binary.dart' show BinaryBuilder;

import 'package:kernel/kernel.dart'
show Class, Component, Field, Library, Procedure;
show Class, Component, EmptyStatement, Field, Library, Procedure;

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

Expand Down Expand Up @@ -405,13 +405,14 @@ Future<Null> newWorldTest(
entries.add(base.resolve(entry));
}
}
bool outlineOnly = world["outlineOnly"] == true;
if (brandNewWorld) {
if (world["fromComponent"] == true) {
compiler = new TestIncrementalCompiler.fromComponent(
options, entries.first, newestWholeComponent);
options, entries.first, newestWholeComponent, outlineOnly);
} else {
compiler =
new TestIncrementalCompiler(options, entries.first, initializeFrom);
compiler = new TestIncrementalCompiler(
options, entries.first, initializeFrom, outlineOnly);
}
}

Expand All @@ -434,6 +435,18 @@ Future<Null> newWorldTest(
entryPoints: entries,
fullComponent:
brandNewWorld ? false : (noFullComponent ? false : true));
if (outlineOnly) {
for (Library lib in component.libraries) {
for (Class c in lib.classes) {
for (Procedure p in c.procedures) {
if (p.function.body is! EmptyStatement) throw "Got body";
}
}
for (Procedure p in lib.procedures) {
if (p.function.body is! EmptyStatement) throw "Got body";
}
}
}
performErrorAndWarningCheck(
world, gotError, formattedErrors, gotWarning, formattedWarnings);
util.throwOnEmptyMixinBodies(component);
Expand Down Expand Up @@ -808,18 +821,20 @@ class TestIncrementalCompiler extends IncrementalCompiler {
}

TestIncrementalCompiler(CompilerOptions options, this.entryPoint,
[Uri initializeFrom])
[Uri initializeFrom, bool outlineOnly])
: super(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
initializeFrom);
initializeFrom,
outlineOnly);

TestIncrementalCompiler.fromComponent(CompilerOptions options,
this.entryPoint, Component componentToInitializeFrom)
this.entryPoint, Component componentToInitializeFrom, [bool outlineOnly])
: super.fromComponent(
new CompilerContext(
new ProcessedOptions(options: options, inputs: [entryPoint])),
componentToInitializeFrom);
componentToInitializeFrom,
outlineOnly);

@override
void recordInvalidatedImportUrisForTesting(List<Uri> uris) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.

# Compile an application with the option of only getting an outline.

type: newworld
strong: true
worlds:
- entry: main.dart
sources:
main.dart: |
main() {
print("hello");
b();
}
outlineOnly: true

0 comments on commit 32a5fa0

Please sign in to comment.