89cec72771
This CL adds two new kernel tools which can answer questions about a dill file: * count_breakdown.dart Enumerates the different node types in the provided dill file and counts them. This has proved useful in the past to e.g. see how many doubles are included in Flutter. * size_breakdown.dart Gives an overview of which parts of the dill file contributes how many bytes. This has proved useful in the past to see that the string table gets huge when we have many doubles (because we currently save doubles in kernel as strings). It also adds error handling and usage information to existing tools. Change-Id: Ie2ce9e4b8806d5975dba8f57445705a840be3474 Reviewed-on: https://dart-review.googlesource.com/42660 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Kevin Millikin <kmillikin@google.com>
34 lines
1.1 KiB
Dart
Executable File
34 lines
1.1 KiB
Dart
Executable File
#!/usr/bin/env dart
|
|
// Copyright (c) 2016, 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';
|
|
|
|
import 'util.dart';
|
|
|
|
void usage() {
|
|
print("Prints a dill file as a textual format.");
|
|
print("");
|
|
print("Usage: dart <script> dillFile.dill [output]");
|
|
print("");
|
|
print("The first given argument should be an existing file");
|
|
print("that is valid to load as a dill file.");
|
|
print("");
|
|
print("The second argument is optional.");
|
|
print("If given, output will be written to this file.");
|
|
print("If not given, output will be written to standard out.");
|
|
exit(1);
|
|
}
|
|
|
|
main(List<String> args) {
|
|
CommandLineHelper.requireVariableArgumentCount([1, 2], args, usage);
|
|
CommandLineHelper.requireFileExists(args[0], usage);
|
|
var binary = CommandLineHelper.tryLoadDill(args[0], usage);
|
|
writeProgramToText(binary,
|
|
path: args.length > 1 ? args[1] : null,
|
|
showOffsets: const bool.fromEnvironment("showOffsets"));
|
|
}
|