Skip to content

Commit 2ec934d

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[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 <[email protected]> Reviewed-by: Vyacheslav Egorov <[email protected]>
1 parent 279024d commit 2ec934d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

runtime/vm/image_snapshot.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,17 @@ void ImageWriter::DumpInstructionsSizes() {
310310
auto& owner = Object::Handle(zone);
311311
auto& url = String::Handle(zone);
312312
auto& name = String::Handle(zone);
313+
intptr_t trampolines_total_size = 0;
313314

314315
JSONWriter js;
315316
js.OpenArray();
316317
for (intptr_t i = 0; i < instructions_.length(); i++) {
317318
auto& data = instructions_[i];
319+
const bool is_trampoline = data.code_ == nullptr;
320+
if (is_trampoline) {
321+
trampolines_total_size += data.trampoline_length;
322+
continue;
323+
}
318324
owner = WeakSerializationReference::Unwrap(data.code_->owner());
319325
js.OpenObject();
320326
if (owner.IsFunction()) {
@@ -337,6 +343,12 @@ void ImageWriter::DumpInstructionsSizes() {
337343
js.PrintProperty("s", SizeInSnapshot(data.insns_->raw()));
338344
js.CloseObject();
339345
}
346+
if (trampolines_total_size != 0) {
347+
js.OpenObject();
348+
js.PrintProperty("n", "[Stub] Trampoline");
349+
js.PrintProperty("s", trampolines_total_size);
350+
js.CloseObject();
351+
}
340352
js.CloseArray();
341353

342354
auto file_open = Dart::file_open_callback();

0 commit comments

Comments
 (0)