d117760ba6
This relands 75a9579ea0.
The approach works as follows:
Step 1: Kernel transform. Under the closed world assumption compute the
set of selectors dispatched dynamically, then mark all procedures that don't
match any of those selectors as 'not-dispatched-dynamically'.
Step 2: VM backend. When building IR for a function if this function was
marked as not-dispatched-dynamically then omit type checks for any parameter
that is not marked as generic-covariant-impl, as such arguments are guaranteed
to be checked on the caller side (by front-end).
+------------------------+------------+----------+-----------+--------------+
| benchmark | baseline | current | with opt | improved by |
+------------------------+------------+----------+-----------+--------------+
| stock_layout_iteration | 2366.3786 | 2724.3 | 2562.75 | -5.93% |
| stock_build_iteration | 3824.3 | 4914.8 | 4681 | -4.76% |
+------------------------+------------+----------+-----------+--------------+
* Flutter gallery Instructions size is reduced by 11% (8748720 bytes to 7846368 bytes).
Baseline is at 6196496 bytes.
Alternatively to annotating individual procedures, I considered annotating Program node
with a set of dynamically dispatched selectors. Decoding and passing this information
around proved to be quite cumbersome in the "streaming" world, so I opted for a simpler
approach where all individual procedures are annotated.
Bug: https://github.com/dart-lang/sdk/issues/3179
Change-Id: I2f32a609e3872c74d5ae7bbd97555453aaedf15f
Reviewed-on: https://dart-review.googlesource.com/38125
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
// Copyright (c) 2017, 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:kernel/kernel.dart' show Program, writeProgramToText;
|
|
import 'package:kernel/binary/ast_from_binary.dart'
|
|
show BinaryBuilderWithMetadata;
|
|
|
|
import 'package:vm/metadata/direct_call.dart' show DirectCallMetadataRepository;
|
|
import 'package:vm/metadata/inferred_type.dart'
|
|
show InferredTypeMetadataRepository;
|
|
import 'package:vm/metadata/procedure_attributes.dart'
|
|
show ProcedureAttributesMetadataRepository;
|
|
|
|
final String _usage = '''
|
|
Usage: dump_kernel input.dill output.txt
|
|
Dumps kernel binary file with VM-specific metadata.
|
|
''';
|
|
|
|
main(List<String> arguments) async {
|
|
if (arguments.length != 2) {
|
|
print(_usage);
|
|
exit(1);
|
|
}
|
|
|
|
final input = arguments[0];
|
|
final output = arguments[1];
|
|
|
|
final program = new Program();
|
|
|
|
// Register VM-specific metadata.
|
|
program.addMetadataRepository(new DirectCallMetadataRepository());
|
|
program.addMetadataRepository(new InferredTypeMetadataRepository());
|
|
program.addMetadataRepository(new ProcedureAttributesMetadataRepository());
|
|
|
|
final List<int> bytes = new File(input).readAsBytesSync();
|
|
new BinaryBuilderWithMetadata(bytes).readProgram(program);
|
|
|
|
writeProgramToText(program, path: output, showMetadata: true);
|
|
}
|