61f0f5bc43
This change replaces kernel AST declarations of fields and functions with bytecode declarations. Size of dilp files is reduced by 11-12%. Startup latency: Time to the first full frame: 1.945s -> 1.687s FinalizeClass: 554ms -> 277ms FinishClassLoading: 296ms -> 156ms There are following regressions in bytecode mode, which will be fixed in future: * dart:mirrors are not supported yet (implementation of mirrors relies on reading kernel AST in certain cases). As the result, lib_2/mirrors/* tests fail. * native extensions are not supported yet (annotations on libraries and classes in AST are cleaned up as they could reference members which are now removed from AST). As the result, standalone_2/entrypoints_verification_test test fails. * language_2/spread_collections/const_error_test/* tests fail due to https://github.com/dart-lang/sdk/issues/36286. Change-Id: I5130f401fd7b84038b136136e7ccc1a6e51b6cea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97561 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
61 lines
2.1 KiB
Dart
61 lines
2.1 KiB
Dart
// Copyright (c) 2018, 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.
|
|
|
|
import 'dart:io';
|
|
|
|
import 'package:front_end/src/api_unstable/vm.dart'
|
|
show CompilerOptions, DiagnosticMessage;
|
|
import 'package:kernel/ast.dart';
|
|
import 'package:kernel/kernel.dart';
|
|
import 'package:test/test.dart';
|
|
import 'package:vm/bytecode/gen_bytecode.dart' show generateBytecode;
|
|
import 'package:vm/kernel_front_end.dart' show runWithFrontEndCompilerContext;
|
|
|
|
import '../common_test_utils.dart';
|
|
|
|
final String pkgVmDir = Platform.script.resolve('../..').toFilePath();
|
|
|
|
runTestCase(Uri source) async {
|
|
// Certain tests require super-mixin semantics which is used in Flutter.
|
|
bool enableSuperMixins = source.pathSegments.last == 'super_calls.dart';
|
|
|
|
Component component = await compileTestCaseToKernelProgram(source,
|
|
enableSuperMixins: enableSuperMixins);
|
|
|
|
final options = new CompilerOptions()
|
|
..onDiagnostic = (DiagnosticMessage message) {
|
|
fail("Compilation error: ${message.plainTextFormatted.join('\n')}");
|
|
};
|
|
|
|
final mainLibrary = component.mainMethod.enclosingLibrary;
|
|
|
|
await runWithFrontEndCompilerContext(source, options, component, () {
|
|
// Need to omit source positions from bytecode as they are different on
|
|
// Linux and Windows (due to differences in newline characters).
|
|
generateBytecode(component,
|
|
omitAssertSourcePositions: true, libraries: [mainLibrary]);
|
|
});
|
|
|
|
component.libraries.removeWhere((lib) => lib != mainLibrary);
|
|
String actual = kernelComponentToString(component);
|
|
|
|
// Remove absolute library URIs.
|
|
actual = actual.replaceAll(new Uri.file(pkgVmDir).toString(), '#pkg/vm');
|
|
|
|
compareResultWithExpectationsFile(source, actual);
|
|
}
|
|
|
|
main() {
|
|
group('gen-bytecode', () {
|
|
final testCasesDir = new Directory(pkgVmDir + '/testcases/bytecode');
|
|
|
|
for (var entry
|
|
in testCasesDir.listSync(recursive: true, followLinks: false)) {
|
|
if (entry.path.endsWith(".dart")) {
|
|
test(entry.path, () => runTestCase(entry.uri));
|
|
}
|
|
}
|
|
});
|
|
}
|