summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2023-04-06 01:14:55 +0200
committerJoyee Cheung <joyeec9h3@gmail.com>2023-05-04 17:33:35 +0200
commit27467a8698bf263366b937218c2dd94e401dcbea (patch)
tree3d8b5f37f83de8466d7309133ffd6b35a995af60 /src
parent2de10f5149c0fc25278bfb6c64f33e967ccd1741 (diff)
downloadnode-new-27467a8698bf263366b937218c2dd94e401dcbea.tar.gz
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: https://github.com/nodejs/node/pull/47437 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_realm-inl.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/node_realm-inl.h b/src/node_realm-inl.h
index 6a6e2a0c51..c6a85d24d1 100644
--- a/src/node_realm-inl.h
+++ b/src/node_realm-inl.h
@@ -88,14 +88,14 @@ inline T* Realm::AddBindingData(v8::Local<v8::Context> context,
// This won't compile if T is not a BaseObject subclass.
BaseObjectPtr<T> item =
MakeDetachedBaseObject<T>(this, target, std::forward<Args>(args)...);
- BindingDataStore* map =
- static_cast<BindingDataStore*>(context->GetAlignedPointerFromEmbedderData(
- ContextEmbedderIndex::kBindingDataStoreIndex));
- DCHECK_NOT_NULL(map);
+ DCHECK_EQ(context->GetAlignedPointerFromEmbedderData(
+ ContextEmbedderIndex::kBindingDataStoreIndex),
+ &binding_data_store_);
constexpr size_t binding_index = static_cast<size_t>(T::binding_type_int);
static_assert(binding_index < std::tuple_size_v<BindingDataStore>);
- CHECK(!(*map)[binding_index]); // Should not insert the binding twice.
- (*map)[binding_index] = item;
+ // Should not insert the binding twice.
+ CHECK(!binding_data_store_[binding_index]);
+ binding_data_store_[binding_index] = item;
DCHECK_EQ(GetBindingData<T>(context), item.get());
return item.get();
}