a9469269d7
In AOT this makes reading faster: Output from `out/ReleaseX64/dart pkg/front_end/tool/benchmarker.dart --iterations=10 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.1 --snapshot=pkg/front_end/test/kernel_binary_bench.aot.2 --arguments="--warmups=10" --arguments="--iterations=5" --arguments="AstFromBinaryEager" --arguments="out/ReleaseX64/vm_platform_strong.dill"`: ``` msec task-clock:u: -8.6925% +/- 0.5737% (-167.09 +/- 11.03) page-faults:u: 0.1410% +/- 0.0051% (243.00 +/- 8.71) cycles:u: -10.2918% +/- 0.6161% (-732576747.50 +/- 43853449.16) instructions:u: -14.4988% +/- 0.0004% (-1636799813.90 +/- 39902.18) branch-misses:u: -3.4891% +/- 2.1142% (-1166085.00 +/- 706582.35) seconds time elapsed: -8.7005% +/- 0.5634% (-0.17 +/- 0.01) seconds user: -9.9752% +/- 1.5104% (-0.17 +/- 0.03) ``` Stats running manually (run as e.g. `out/ReleaseX64/dart-sdk/bin/dartaotruntime pkg/front_end/test/kernel_binary_bench.aot.1 --warmups=10 --iterations=5 AstFromBinaryEager out/ReleaseX64/vm_platform_strong.dill`): ``` AstFromBinaryEagerCold: -12.5174% +/- 3.10688% AstFromBinaryEagerWarmup: -8.33675% +/- 2.62433% AstFromBinaryEager: -10.3432% +/- 3.68375% ``` I don't expect there to be much of a change (if any) in JIT as the actual type was in practise always Uint8List anyway. TEST=Existing tests. Change-Id: I86b16ed207343848dee2e376f42598c223bbc48f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393740 Reviewed-by: Mayank Patke <fishythefish@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Morgan :) <davidmorgan@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
123 lines
3.5 KiB
Dart
123 lines
3.5 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:convert' show utf8;
|
|
import 'dart:typed_data';
|
|
|
|
import "package:front_end/src/api_prototype/file_system.dart" show FileSystem;
|
|
import 'package:front_end/src/kernel/utils.dart' show serializeComponent;
|
|
import 'package:kernel/kernel.dart'
|
|
show
|
|
Class,
|
|
Component,
|
|
EmptyStatement,
|
|
FileUriNode,
|
|
Library,
|
|
Node,
|
|
Procedure,
|
|
RecursiveVisitor;
|
|
|
|
Uint8List postProcess(Component c, {bool clearMetadata = true}) {
|
|
postProcessComponent(c, clearMetadata: clearMetadata);
|
|
return serializeComponent(c);
|
|
}
|
|
|
|
void postProcessComponent(Component c, {bool clearMetadata = true}) {
|
|
if (clearMetadata) {
|
|
// For now metadata isn't great for recompiles because it will only contain
|
|
// what was just compiled. To avoid failures caused by this we for now just
|
|
// clear the metadata.
|
|
c.metadata.clear();
|
|
}
|
|
c.libraries.sort((l1, l2) {
|
|
return "${l1.fileUri}".compareTo("${l2.fileUri}");
|
|
});
|
|
|
|
c.problemsAsJson?.sort();
|
|
|
|
c.computeCanonicalNames();
|
|
for (Library library in c.libraries) {
|
|
library.additionalExports.sort();
|
|
library.problemsAsJson?.sort();
|
|
}
|
|
}
|
|
|
|
void throwOnEmptyMixinBodies(Component component) {
|
|
int empty = countEmptyMixinBodies(component);
|
|
if (empty != 0) {
|
|
throw "Expected 0 empty bodies in mixins, but found $empty";
|
|
}
|
|
}
|
|
|
|
int countEmptyMixinBodies(Component component) {
|
|
int empty = 0;
|
|
for (Library lib in component.libraries) {
|
|
for (Class c in lib.classes) {
|
|
if (c.isAnonymousMixin) {
|
|
for (Procedure p in c.procedures) {
|
|
if (p.function.body is EmptyStatement) {
|
|
empty++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return empty;
|
|
}
|
|
|
|
Future<void> throwOnInsufficientUriToSource(Component component,
|
|
{FileSystem? fileSystem}) async {
|
|
UriFinder uriFinder = new UriFinder();
|
|
component.accept(uriFinder);
|
|
Set<Uri> uris = uriFinder.seenUris.toSet();
|
|
uris.removeAll(component.uriToSource.keys);
|
|
uris.remove(null);
|
|
if (uris.length != 0) {
|
|
throw "Expected 0 uris with no source, but found ${uris.length} ($uris)";
|
|
}
|
|
|
|
if (fileSystem != null) {
|
|
uris = uriFinder.seenUris.toSet();
|
|
for (Uri uri in uris) {
|
|
if (!uri.isScheme("org-dartlang-test")) continue;
|
|
// The file system doesn't have the sources for any modules.
|
|
// For now assume that that is always what's going on.
|
|
if (!await fileSystem.entityForUri(uri).exists()) continue;
|
|
List<int> expected = await fileSystem.entityForUri(uri).readAsBytes();
|
|
List<int> actual = component.uriToSource[uri]!.source;
|
|
bool fail = false;
|
|
if (expected.length != actual.length) {
|
|
fail = true;
|
|
}
|
|
if (!fail) {
|
|
for (int i = 0; i < expected.length; i++) {
|
|
if (expected[i] != actual[i]) {
|
|
fail = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (fail) {
|
|
String expectedString = utf8.decode(expected);
|
|
String actualString = utf8.decode(actual);
|
|
throw "Not expected source for $uri:\n\n"
|
|
"$expectedString\n\n"
|
|
"vs\n\n"
|
|
"$actualString";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class UriFinder extends RecursiveVisitor {
|
|
Set<Uri> seenUris = new Set<Uri>();
|
|
@override
|
|
void defaultNode(Node node) {
|
|
super.defaultNode(node);
|
|
if (node is FileUriNode) {
|
|
seenUris.add(node.fileUri);
|
|
}
|
|
}
|
|
}
|