[vm] Fix crash on trampolines in --print_instructions_sizes_to

Trampolines which are generated in use_bare_instructions mode should be
taken into account when dumping sizes in --print_instructions_sizes_to.

This change fixes failing pkg/vm/test/snapshot/instruction_sizes_test on
Windows after https://dart-review.googlesource.com/c/sdk/+/148543.

Change-Id: I343f82699407ba54d9ccb9a9800875c61a6e8df3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149043
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This commit is contained in:
Alexander Markov 2020-05-26 23:14:32 +00:00 committed by commit-bot@chromium.org
parent 279024d823
commit 2ec934d267

View file

@ -310,11 +310,17 @@ void ImageWriter::DumpInstructionsSizes() {
auto& owner = Object::Handle(zone);
auto& url = String::Handle(zone);
auto& name = String::Handle(zone);
intptr_t trampolines_total_size = 0;
JSONWriter js;
js.OpenArray();
for (intptr_t i = 0; i < instructions_.length(); i++) {
auto& data = instructions_[i];
const bool is_trampoline = data.code_ == nullptr;
if (is_trampoline) {
trampolines_total_size += data.trampoline_length;
continue;
}
owner = WeakSerializationReference::Unwrap(data.code_->owner());
js.OpenObject();
if (owner.IsFunction()) {
@ -337,6 +343,12 @@ void ImageWriter::DumpInstructionsSizes() {
js.PrintProperty("s", SizeInSnapshot(data.insns_->raw()));
js.CloseObject();
}
if (trampolines_total_size != 0) {
js.OpenObject();
js.PrintProperty("n", "[Stub] Trampoline");
js.PrintProperty("s", trampolines_total_size);
js.CloseObject();
}
js.CloseArray();
auto file_open = Dart::file_open_callback();