da8cb470cc
Size of a large application:
Before: 26628600
After: 21480120 (-19.3%)
Size of snapshots:
isolate_snapshot_framework.bin
Before: 9322496
After: 6782976 (-27.2%)
isolate_snapshot_product_framework.bin
Before: 9166848
After: 6602752 (-27.9%)
Regressions in tests:
1) Test language_2/type_alias_equality_test/04 fails similarly to default mode, as VM
does not implement comparison of function types according to the specification.
Previously this test was passing as function types were canonicalized in bytecode,
which was not always correct. This CL fixes the problem with canonicalization of
function types in bytecode and the test starts failing again.
2) Tests standalone_2/entrypoints_verification_test, standalone_2/io/test_extension_test,
standalone_2/io/test_extension_fail_test fail as native extensions are not supported
in bytecode yet. These tests start passing after df5e7aac17,
which switched bytecode tests to kernel service (on x64), because kernel service doesn't
drop ASTs. This CL switches from reading AST library declarations to bytecode even if
AST is not removed, so tests fail again.
Change-Id: I8b7ba44bfa49d0b1599b2509553ff7c831a4e244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104700
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
65 lines
2.0 KiB
Dart
65 lines
2.0 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.
|
|
|
|
library vm.metadata.bytecode;
|
|
|
|
import 'package:kernel/ast.dart'
|
|
show BinarySink, BinarySource, MetadataRepository, Node, TreeNode;
|
|
import '../bytecode/bytecode_serialization.dart'
|
|
show BufferedWriter, BufferedReader, LinkWriter, LinkReader;
|
|
import '../bytecode/declarations.dart' show Component;
|
|
|
|
class BytecodeMetadata {
|
|
final Component component;
|
|
|
|
BytecodeMetadata(this.component);
|
|
|
|
void write(BufferedWriter writer) {
|
|
component.write(writer);
|
|
}
|
|
|
|
factory BytecodeMetadata.read(BufferedReader reader) {
|
|
return new BytecodeMetadata(new Component.read(reader));
|
|
}
|
|
|
|
@override
|
|
String toString() => "\n"
|
|
"BytecodeMetadata {\n"
|
|
"$component\n"
|
|
"}\n";
|
|
}
|
|
|
|
/// Repository for [BytecodeMetadata].
|
|
class BytecodeMetadataRepository extends MetadataRepository<BytecodeMetadata> {
|
|
@override
|
|
final String tag = 'vm.bytecode';
|
|
|
|
@override
|
|
final Map<TreeNode, BytecodeMetadata> mapping =
|
|
<TreeNode, BytecodeMetadata>{};
|
|
|
|
@override
|
|
void writeToBinary(BytecodeMetadata metadata, Node node, BinarySink sink) {
|
|
final bytecodeComponent = metadata.component;
|
|
final linkWriter = new LinkWriter();
|
|
final writer = new BufferedWriter(
|
|
bytecodeComponent.version,
|
|
bytecodeComponent.stringTable,
|
|
bytecodeComponent.objectTable,
|
|
linkWriter,
|
|
baseOffset: sink.getBufferOffset());
|
|
metadata.write(writer);
|
|
sink.writeBytes(writer.takeBytes());
|
|
}
|
|
|
|
@override
|
|
BytecodeMetadata readFromBinary(Node node, BinarySource source) {
|
|
final linkReader = new LinkReader();
|
|
final reader = new BufferedReader(-1, null, null, linkReader, source.bytes,
|
|
baseOffset: source.currentOffset);
|
|
final bytecodeComponent = new Component.read(reader);
|
|
return new BytecodeMetadata(bytecodeComponent);
|
|
}
|
|
}
|