From a26681f9519954b56a1f47ddfc88e350728460f0 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Tue, 13 Jan 2026 09:59:22 -0800 Subject: [PATCH] [vm] Avoid call in the middle of ReadFill loop. Hoist more of header computation from the variable-cid clusters. TEST=ci Change-Id: I14269992f9156383fd7c702f076bdc4de49be1e2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472421 Commit-Queue: Ryan Macnak Reviewed-by: Alexander Aprelev --- runtime/vm/app_snapshot.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/runtime/vm/app_snapshot.cc b/runtime/vm/app_snapshot.cc index 5de7084acfe..23efb7176b5 100644 --- a/runtime/vm/app_snapshot.cc +++ b/runtime/vm/app_snapshot.cc @@ -832,7 +832,7 @@ class Deserializer : public ThreadStackResource { } template - void ReadFromTo(T obj, P&&... params) { + DART_FORCE_INLINE void ReadFromTo(T obj, P&&... params) { auto* from = obj->untag()->from(); auto* to_snapshot = obj->untag()->to_snapshot(d_->kind(), params...); auto* to = obj->untag()->to(params...); @@ -848,6 +848,8 @@ class Deserializer : public ThreadStackResource { } } + ObjectPtr null() const { return null_; } + private: Deserializer* const d_; const ArrayPtr refs_; @@ -4637,7 +4639,7 @@ class InstanceDeserializationCluster while (offset < instance_size) { CompressedObjectPtr* p = reinterpret_cast( reinterpret_cast(instance->untag()) + offset); - *p = Object::null(); + *p = d.null(); offset += kCompressedWordSize; } ASSERT(offset == instance_size); @@ -5509,10 +5511,11 @@ class Simd128DeserializationCluster Deserializer::Local d(d_); const intptr_t cid = cid_; const bool mark_canonical = is_root_unit_ && is_canonical(); + const bool is_immutable = ShouldHaveImmutabilityBitSetCid(cid); for (intptr_t id = start_index_, n = stop_index_; id < n; id++) { ObjectPtr vector = d.Ref(id); Deserializer::InitializeHeader(vector, cid, Int32x4::InstanceSize(), - mark_canonical); + mark_canonical, is_immutable); d.ReadBytes(&(static_cast(vector)->untag()->value_), sizeof(simd128_value_t)); } @@ -6518,12 +6521,13 @@ class ArrayDeserializationCluster const intptr_t cid = cid_; const bool stamp_canonical = is_root_unit_ && is_canonical(); + const bool is_immutable = ShouldHaveImmutabilityBitSetCid(cid); for (intptr_t id = start_index_, n = stop_index_; id < n; id++) { ArrayPtr array = static_cast(d.Ref(id)); const intptr_t length = d.ReadUnsigned(); Deserializer::InitializeHeader(array, cid, Array::InstanceSize(length), - stamp_canonical); - if (Array::UseCardMarkingForAllocation(length)) { + stamp_canonical, is_immutable); + if (UNLIKELY(Array::UseCardMarkingForAllocation(length))) { array->untag()->SetCardRememberedBitUnsynchronized(); Page::Of(array)->AllocateCardTable(); }