diff --git a/CHANGELOG.md b/CHANGELOG.md index 1134e5518e9..26776141b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,13 @@ #### dart2js +* `--fast-startup` is forced on. The flag is silently ignored and will be + deprecated and then removed at a later date. + + The alternative 'full emitter' is no longer available. The generated code for + `--fast-startup` is optimized to load faster, even though it can be slightly + larger. + * We fixed a bug in how deferred constructor calls were incorrectly not marked as deferred. The old behavior didn't cause breakages, but was imprecise and pushed more code to the main output unit. diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart index 74818db0ae1..daab7fcf5a7 100644 --- a/pkg/compiler/lib/src/dart2js.dart +++ b/pkg/compiler/lib/src/dart2js.dart @@ -340,7 +340,7 @@ Future compile(List argv, new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), new OptionHandler('-O.*', setOptimizationLevel), new OptionHandler(Flags.allowMockCompilation, ignoreOption), - new OptionHandler(Flags.fastStartup, passThrough), + new OptionHandler(Flags.fastStartup, ignoreOption), new OptionHandler(Flags.genericMethodSyntax, ignoreOption), new OptionHandler(Flags.initializingFormalAccess, ignoreOption), new OptionHandler(Flags.minify, passThrough), diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart index 81ea82f6065..9ae8118122f 100644 --- a/pkg/compiler/lib/src/js_backend/backend.dart +++ b/pkg/compiler/lib/src/js_backend/backend.dart @@ -387,12 +387,13 @@ class JavaScriptBackend { JavaScriptBackend(this.compiler, {bool generateSourceMap: true, - bool useStartupEmitter: false, + bool useStartupEmitter: true, bool useMultiSourceInfo: false, bool useNewSourceInfo: false}) : this.sourceInformationStrategy = compiler.backendStrategy.sourceInformationStrategy, constantCompilerTask = new JavaScriptConstantTask(compiler) { + useStartupEmitter = true; CommonElements commonElements = compiler.frontendStrategy.commonElements; _backendUsageBuilder = new BackendUsageBuilderImpl(compiler.frontendStrategy); diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart index 41c32cc18fd..f52a2fc8204 100644 --- a/pkg/compiler/lib/src/options.dart +++ b/pkg/compiler/lib/src/options.dart @@ -244,9 +244,9 @@ class CompilerOptions implements DiagnosticOptions { /// (experimental) bool useNewSourceInfo = false; - /// Whether the user requested to use the fast startup emitter. The full - /// emitter might still be used if the program uses dart:mirrors. - bool useStartupEmitter = false; + /// Whether the user requested to use the fast startup emitter. Always `true`. + // TODO(sra): Remove. + bool useStartupEmitter = true; /// Enable verbose printing during compilation. Includes a time-breakdown /// between phases at the end. @@ -358,7 +358,7 @@ class CompilerOptions implements DiagnosticOptions { !_hasOption(options, Flags.noFrequencyBasedMinification) ..useMultiSourceInfo = _hasOption(options, Flags.useMultiSourceInfo) ..useNewSourceInfo = _hasOption(options, Flags.useNewSourceInfo) - ..useStartupEmitter = _hasOption(options, Flags.fastStartup) + ..useStartupEmitter = true ..verbose = _hasOption(options, Flags.verbose) ..showInternalProgress = _hasOption(options, Flags.progress) ..readDataUri = _extractUriOption(options, '${Flags.readData}=') @@ -390,6 +390,8 @@ class CompilerOptions implements DiagnosticOptions { } void deriveOptions() { + useStartupEmitter = true; + if (benchmarkingProduction) { useStartupEmitter = true; trustPrimitives = true; diff --git a/tests/compiler/dart2js/codegen/class_codegen_test.dart b/tests/compiler/dart2js/codegen/class_codegen_test.dart index a9439f98eda..bb22e20d00e 100644 --- a/tests/compiler/dart2js/codegen/class_codegen_test.dart +++ b/tests/compiler/dart2js/codegen/class_codegen_test.dart @@ -66,14 +66,14 @@ main() { twoClasses() async { String generated = await compileAll(TEST_ONE); - Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"'))); - Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "Object;"'))); + Expect.isTrue(generated.contains('A: function A()')); + Expect.isTrue(generated.contains('B: function B()')); } subClass() async { checkOutput(String generated) { - Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"\\^": "Object;"'))); - Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"\\^": "A;"'))); + Expect.isTrue(generated.contains(RegExp(r'_inherit\(.\.A, .\.Object\)'))); + Expect.isTrue(generated.contains(RegExp(r'_inherit\(.\.B, .\.A\)'))); } checkOutput(await compileAll(TEST_TWO)); @@ -82,12 +82,15 @@ subClass() async { fieldTest() async { String generated = await compileAll(TEST_FOUR); - Expect.isTrue(generated - .contains(new RegExp('B: {[ \n]*"\\^": "A;y,z,x",[ \n]*static:'))); + Expect.isTrue(generated.contains(RegExp(r'B: function B\(t0, t1, t2\) {' + r'\s*this.y = t0;' + r'\s*this.z = t1;' + r'\s*this.x = t2;'))); } constructor1() async { String generated = await compileAll(TEST_FIVE); + print('--------------------\n$generated\n'); Expect.isTrue(generated.contains(new RegExp(r"new [$A-Z]+\.A\(a\);"))); } diff --git a/tests/compiler/dart2js/codegen/gvn_test.dart b/tests/compiler/dart2js/codegen/gvn_test.dart index 54f4d309cd6..678d9fc7989 100644 --- a/tests/compiler/dart2js/codegen/gvn_test.dart +++ b/tests/compiler/dart2js/codegen/gvn_test.dart @@ -108,24 +108,22 @@ main() { main() { runTests() async { await compile(TEST_ONE, entry: 'foo', check: (String generated) { - RegExp regexp = new RegExp(r"1 \+ [a-z]+"); + RegExp regexp = RegExp(r"1 \+ [a-z]+"); checkNumberOfMatches(regexp.allMatches(generated).iterator, 1); }); await compile(TEST_TWO, entry: 'foo', check: (String generated) { - checkNumberOfMatches( - new RegExp("length").allMatches(generated).iterator, 1); + checkNumberOfMatches(RegExp("length").allMatches(generated).iterator, 1); }); await compile(TEST_THREE, entry: 'foo', check: (String generated) { - checkNumberOfMatches( - new RegExp("number").allMatches(generated).iterator, 1); + checkNumberOfMatches(RegExp("number").allMatches(generated).iterator, 1); }); await compile(TEST_FOUR, entry: 'foo', check: (String generated) { - checkNumberOfMatches(new RegExp("shr").allMatches(generated).iterator, 1); + checkNumberOfMatches(RegExp("shr").allMatches(generated).iterator, 1); }); await compileAll(TEST_FIVE).then((generated) { checkNumberOfMatches( - new RegExp("get\\\$foo").allMatches(generated).iterator, 1); + RegExp(r"get\$foo\(").allMatches(generated).iterator, 1); }); await compileAll(TEST_SIX).then((generated) { Expect.isTrue(generated.contains('for (t1 = a.field === 54; t1;)')); diff --git a/tests/compiler/dart2js/codegen/no_constructor_body_test.dart b/tests/compiler/dart2js/codegen/no_constructor_body_test.dart index e34f13c05f7..7edc7008abc 100644 --- a/tests/compiler/dart2js/codegen/no_constructor_body_test.dart +++ b/tests/compiler/dart2js/codegen/no_constructor_body_test.dart @@ -20,9 +20,8 @@ main() { main() { runTest() async { String generated = await compileAll(TEST); - - Expect.isTrue(generated - .contains(new RegExp('A: {[ \n]*"\\^": "Object;",[ \n]*static:'))); + // No methods (including no constructor body method. + Expect.isTrue(generated.contains('.A.prototype = {}')); } asyncTest(() async { diff --git a/tests/compiler/dart2js/codegen/no_duplicate_constructor_body_test.dart b/tests/compiler/dart2js/codegen/no_duplicate_constructor_body_test.dart index 194fce29f8b..8d180911636 100644 --- a/tests/compiler/dart2js/codegen/no_duplicate_constructor_body_test.dart +++ b/tests/compiler/dart2js/codegen/no_duplicate_constructor_body_test.dart @@ -18,9 +18,14 @@ main() { main() { runTest() async { String generated = await compileAll(CODE); - RegExp regexp = new RegExp(r'\A: {[ \n]*"\^": "[A-Za-z]+;"'); + + RegExp regexp = RegExp(r'\.A\.prototype = {'); Iterator matches = regexp.allMatches(generated).iterator; checkNumberOfMatches(matches, 1); + + RegExp regexp2 = RegExp(r'A\$\w+: function'); + Iterator matches2 = regexp2.allMatches(generated).iterator; + checkNumberOfMatches(matches2, 1); } asyncTest(() async { diff --git a/tests/compiler/dart2js/deferred/inline_restrictions_test.dart b/tests/compiler/dart2js/deferred/inline_restrictions_test.dart index 4d11985e0cd..70df323669e 100644 --- a/tests/compiler/dart2js/deferred/inline_restrictions_test.dart +++ b/tests/compiler/dart2js/deferred/inline_restrictions_test.dart @@ -57,7 +57,8 @@ void main() { // Test that inlineSameContext was inlined into lib1. RegExp re4 = new RegExp(r"inline same context"); - Expect.isFalse(re4.hasMatch(lib3Output)); + // Output can be null when it contains no code. + Expect.isTrue(lib3Output == null || !re4.hasMatch(lib3Output)); Expect.isTrue(re4.hasMatch(lib1Output)); }); } diff --git a/tests/compiler/dart2js/end_to_end/uri_retention_test.dart b/tests/compiler/dart2js/end_to_end/uri_retention_test.dart deleted file mode 100644 index 1fb8a7240c8..00000000000 --- a/tests/compiler/dart2js/end_to_end/uri_retention_test.dart +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2013, 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 file. - -library dart2js.test.uri_retention_test; - -import 'dart:async'; - -import 'package:async_helper/async_helper.dart'; -import 'package:compiler/compiler_new.dart'; -import 'package:compiler/src/commandline_options.dart'; -import 'package:expect/expect.dart'; -import '../helpers/memory_compiler.dart' show runCompiler, OutputCollector; - -Future compileSources(sources, {bool minify}) async { - var options = []; - if (minify) options.add(Flags.minify); - OutputCollector outputCollector = new OutputCollector(); - await runCompiler( - memorySourceFiles: sources, - options: options, - outputProvider: outputCollector); - return outputCollector.getOutput('', OutputType.js); -} - -Future test(sources, {bool libName, bool fileName}) { - return compileSources(sources, minify: false).then((output) { - // Unminified the sources should always contain the library name and the - // file name. - Expect.isTrue(output.contains("main_lib")); - Expect.isTrue(output.contains("main.dart")); - }).then((_) { - compileSources(sources, minify: true).then((output) { - Expect.equals(libName, output.contains("main_lib")); - Expect.isFalse(output.contains("main.dart")); - }); - }); -} - -void main() { - runTests() async { - await test(MEMORY_SOURCE_FILES1, libName: false, fileName: false); - } - - asyncTest(() async { - print('--test from kernel------------------------------------------------'); - await runTests(); - }); -} - -const MEMORY_SOURCE_FILES1 = const { - 'main.dart': """ -library main_lib; - -class A { - final uri = "foo"; -} - -main() { - print(Uri.base); - print(new A().uri); -} -""", -}; diff --git a/tests/compiler/dart2js/rti/emission/closure_function_type.dart b/tests/compiler/dart2js/rti/emission/closure_function_type.dart index 56d1d56d266..aed5de1bc7a 100644 --- a/tests/compiler/dart2js/rti/emission/closure_function_type.dart +++ b/tests/compiler/dart2js/rti/emission/closure_function_type.dart @@ -8,7 +8,7 @@ import 'package:meta/dart2js.dart'; test(o) => o is Function(); main() { - test(/*checks=[],functionType,instance*/ () {}); + test(/*checks=[$signature],instance*/ () {}); test( /*strong.checks=[],instance*/ diff --git a/tests/compiler/dart2js/rti/emission/closure_signature.dart b/tests/compiler/dart2js/rti/emission/closure_signature.dart index b1250b0a858..aedf5f658ff 100644 --- a/tests/compiler/dart2js/rti/emission/closure_signature.dart +++ b/tests/compiler/dart2js/rti/emission/closure_signature.dart @@ -13,7 +13,7 @@ class A { @NoInline() f() { - return /*checks=[],functionType,instance*/ (int t) {}; + return /*checks=[$signature],instance*/ (int t) {}; } } diff --git a/tests/compiler/dart2js/rti/emission/runtime_type_instantiate_to_string1.dart b/tests/compiler/dart2js/rti/emission/runtime_type_instantiate_to_string1.dart index 3123b79363d..dc43c4b25ed 100644 --- a/tests/compiler/dart2js/rti/emission/runtime_type_instantiate_to_string1.dart +++ b/tests/compiler/dart2js/rti/emission/runtime_type_instantiate_to_string1.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. main() { - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ T id(T t) => t; int Function(int) x = id; diff --git a/tests/compiler/dart2js/rti/emission/subtype_named_args.dart b/tests/compiler/dart2js/rti/emission/subtype_named_args.dart index 759210b0644..cb83d5e430b 100644 --- a/tests/compiler/dart2js/rti/emission/subtype_named_args.dart +++ b/tests/compiler/dart2js/rti/emission/subtype_named_args.dart @@ -53,50 +53,50 @@ typedef okWithDynamicFunc_2({int x, bool y, List z, classesFunc v}); main() { Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({D a, B b, C c, A d}) {} is classesFunc); Expect.isTrue( - /*checks=[],functionType,instance*/ + /*checks=[$signature],instance*/ ({A a, A b, A c, A d}) {} is classesFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({D a, A1 b, A1 c, A1 d}) {} is classesFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({D a, A2 b, A2 c, A2 d}) {} is classesFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({D a, D b, D c, D d}) {} is classesFunc); Expect.isTrue( - /*checks=[],functionType,instance*/ + /*checks=[$signature],instance*/ ({var a, var b, var c, var d}) {} is classesFunc); - Expect.isTrue(/*checks=[],functionType,instance*/ + Expect.isTrue(/*checks=[$signature],instance*/ ({Object a, Object b, Object c, Object d}) {} is classesFunc); - Expect.isTrue(/*checks=[],functionType,instance*/ + Expect.isTrue(/*checks=[$signature],instance*/ ({Map m, List> l, G g}) {} is genericsFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({Map m, List> l, G g}) {} is genericsFunc); Expect.isTrue( - /*checks=[],functionType,instance*/ + /*checks=[$signature],instance*/ ({var m, var l, var g}) {} is genericsFunc); Expect.isTrue( - /*checks=[],functionType,instance*/ + /*checks=[$signature],instance*/ ({Object m, Object l, Object g}) {} is genericsFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({A x, G y, mixFunc z, var v}) {} is dynamicFunc); Expect.isTrue( - /*strong.checks=[],functionType,instance*/ + /*strong.checks=[$signature],instance*/ /*omit.checks=[],instance*/ ({int x, bool y, List z, classesFunc v}) {} is dynamicFunc); @@ -106,7 +106,7 @@ main() { {okWithClassesFunc_1 f1, okWithGenericsFunc_1 f2, okWithDynamicFunc_1 f3}) {} is funcFunc); - Expect.isTrue(/*checks=[],functionType,instance*/ + Expect.isTrue(/*checks=[$signature],instance*/ ( {okWithClassesFunc_2 f1, okWithGenericsFunc_2 f2,