Skip to content

Commit d358317

Browse files
joyeecheungtargos
authored andcommitted
src: get binding data store directly from the realm
We now store the binding data store in the realm and invoke `Realm::AddBindingData` to add the binding data, so there is no need to get a reference to the binding data store from the context now, we can just get the reference from the realm. PR-URL: #47437 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c4596b9 commit d358317

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/node_realm-inl.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ inline T* Realm::AddBindingData(v8::Local<v8::Context> context,
8888
// This won't compile if T is not a BaseObject subclass.
8989
BaseObjectPtr<T> item =
9090
MakeDetachedBaseObject<T>(this, target, std::forward<Args>(args)...);
91-
BindingDataStore* map =
92-
static_cast<BindingDataStore*>(context->GetAlignedPointerFromEmbedderData(
93-
ContextEmbedderIndex::kBindingDataStoreIndex));
94-
DCHECK_NOT_NULL(map);
91+
DCHECK_EQ(context->GetAlignedPointerFromEmbedderData(
92+
ContextEmbedderIndex::kBindingDataStoreIndex),
93+
&binding_data_store_);
9594
constexpr size_t binding_index = static_cast<size_t>(T::binding_type_int);
9695
static_assert(binding_index < std::tuple_size_v<BindingDataStore>);
97-
CHECK(!(*map)[binding_index]); // Should not insert the binding twice.
98-
(*map)[binding_index] = item;
96+
// Should not insert the binding twice.
97+
CHECK(!binding_data_store_[binding_index]);
98+
binding_data_store_[binding_index] = item;
9999
DCHECK_EQ(GetBindingData<T>(context), item.get());
100100
return item.get();
101101
}

0 commit comments

Comments
 (0)