From 0833f8c011253bf177fbb802586081ea4ee18052 Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Thu, 4 Apr 2024 20:44:28 +0000 Subject: [PATCH] [vm] Always deduplicate UnlinkedCalls in local object pools CodeSerializationCluster::Trace uses local object pools to discover object pool entries used by the Code object, even when code object uses GOP. So UnlinkedCall objects should be de-duplicated in the local object pools to avoid stale references regardless of --write_v8_snapshot_profile_to and --trace_precompiler_to flags. TEST=User tested on their app. Fixes https://github.com/dart-lang/sdk/issues/55343 Change-Id: I781dc6dc75f2fca25c1c107e224dedbaeadbc53a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361240 Commit-Queue: Alexander Markov Reviewed-by: Ryan Macnak --- runtime/vm/program_visitor.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/runtime/vm/program_visitor.cc b/runtime/vm/program_visitor.cc index cb22ae706f3..af88a749626 100644 --- a/runtime/vm/program_visitor.cc +++ b/runtime/vm/program_visitor.cc @@ -926,16 +926,9 @@ void ProgramVisitor::DedupUnlinkedCalls(Thread* thread) { StackZone stack_zone(thread); DedupUnlinkedCallsVisitor visitor(thread->zone(), thread->isolate_group()); - // Note: in bare instructions mode we can still have object pools attached - // to code objects and these pools need to be deduplicated. - // We use these pools to carry information about references between code - // objects and other objects in the snapshots (these references are otherwise - // implicit and go through global object pool). This information is needed - // to produce more informative snapshot profile. - if (FLAG_write_v8_snapshot_profile_to != nullptr || - FLAG_trace_precompiler_to != nullptr) { - WalkProgram(thread->zone(), thread->isolate_group(), &visitor); - } + // Deduplicate local object pools as they are used to trace + // objects when writing snapshots. + WalkProgram(thread->zone(), thread->isolate_group(), &visitor); } void ProgramVisitor::PruneSubclasses(Thread* thread) {