Don't include .dill artifacts in delta program

Change-Id: Ibbcb490cdaca57c600bcf4b9783d889644e8af00
Reviewed-on: https://dart-review.googlesource.com/30822
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Peter von der Ahé 2017-12-20 15:58:02 +00:00 committed by commit-bot@chromium.org
parent a671328de3
commit d1543b3986
3 changed files with 48 additions and 11 deletions

View file

@ -6,7 +6,8 @@ library fasta.incremental_compiler;
import 'dart:async' show Future;
import 'package:kernel/kernel.dart' show Program, loadProgramFromBytes;
import 'package:kernel/kernel.dart'
show Library, Program, Source, loadProgramFromBytes;
import '../api_prototype/incremental_kernel_generator.dart'
show DeltaProgram, IncrementalKernelGenerator;
@ -99,7 +100,10 @@ class IncrementalCompiler extends DeprecatedIncrementalKernelGenerator {
List<LibraryBuilder> reusedLibraries =
computeReusedLibraries(invalidatedUris);
ticker.logMs("Decided to reuse ${reusedLibraries.length} libraries");
if (userCode != null) {
ticker.logMs("Decided to reuse ${reusedLibraries.length}"
" of ${userCode.loader.builders.length} libraries");
}
userCode = new KernelTarget(
c.fileSystem, false, platform, platform.uriTranslator,
@ -115,8 +119,18 @@ class IncrementalCompiler extends DeprecatedIncrementalKernelGenerator {
await userCode.buildOutlines();
return new FastaDelta(
await userCode.buildProgram(verify: c.options.verify));
// This is not the full program. It is the program including all
// libraries loaded from .dill files.
Program programWithDill =
await userCode.buildProgram(verify: c.options.verify);
// This is the incremental program.
Program program = new Program(
nameRoot: programWithDill.root,
libraries: new List<Library>.from(userCode.loader.libraries),
uriToSource: new Map<Uri, Source>.from(userCode.uriToSource));
return new FastaDelta(program);
});
}

View file

@ -14,6 +14,9 @@ import "package:front_end/src/api_prototype/compiler_options.dart"
import 'package:front_end/src/base/processed_options.dart'
show ProcessedOptions;
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext;
import 'package:front_end/src/fasta/fasta_codes.dart' show LocatedMessage;
@ -28,13 +31,20 @@ void problemHandler(LocatedMessage message, Severity severity, String formatted,
throw "Unexpected message: $formatted";
}
test() async {
test({bool sdkFromSource}) async {
final CompilerOptions optionBuilder = new CompilerOptions()
..librariesSpecificationUri = Uri.base.resolve("sdk/lib/libraries.json")
..packagesFileUri = Uri.base.resolve(".packages")
..strongMode = false
..onProblem = problemHandler;
if (sdkFromSource) {
optionBuilder.librariesSpecificationUri =
Uri.base.resolve("sdk/lib/libraries.json");
} else {
optionBuilder.sdkSummary =
computePlatformBinariesLocation().resolve("vm_platform.dill");
}
final Uri helloDart = Uri.base.resolve("pkg/front_end/testcases/hello.dart");
final ProcessedOptions options =
@ -45,17 +55,28 @@ test() async {
FastaDelta delta = await compiler.computeDelta();
// Expect that the new program contains at least the following libraries:
// dart:core, dart:async, and hello.dart.
Expect.isTrue(delta.newProgram.libraries.length > 2);
if (sdkFromSource) {
// Expect that the new program contains at least the following libraries:
// dart:core, dart:async, and hello.dart.
Expect.isTrue(delta.newProgram.libraries.length > 2,
"${delta.newProgram.libraries.length} <= 2");
} else {
// Expect that the new program contains exactly hello.dart.
Expect.isTrue(delta.newProgram.libraries.length == 1,
"${delta.newProgram.libraries.length} != 1");
}
compiler.invalidate(helloDart);
delta = await compiler.computeDelta(entryPoint: helloDart);
// Expect that the new program contains exactly hello.dart
Expect.isTrue(delta.newProgram.libraries.length == 1);
Expect.isTrue(delta.newProgram.libraries.length == 1,
"${delta.newProgram.libraries.length} != 1");
}
void main() {
asyncTest(test);
asyncTest(() async {
await test(sdkFromSource: true);
await test(sdkFromSource: false);
});
}

View file

@ -3,3 +3,5 @@
# BSD-style license that can be found in the LICENSE.md file.
# Status file for the test suite ../test/fasta/incremental_test.dart.
dartino/change_in_part.incremental: Crash # Parts aren't handled correctly