@@ -66,9 +66,9 @@ inline T* Realm::GetBindingData(
66
66
// static
67
67
template <typename T>
68
68
inline T* Realm::GetBindingData (v8::Local<v8::Context> context) {
69
- BindingDataStore* map =
70
- static_cast <BindingDataStore*>(context-> GetAlignedPointerFromEmbedderData (
71
- ContextEmbedderIndex:: kBindingDataStoreIndex ) );
69
+ Realm* realm = GetCurrent (context);
70
+ DCHECK_NOT_NULL (realm);
71
+ BindingDataStore* map = realm-> binding_data_store ( );
72
72
DCHECK_NOT_NULL (map);
73
73
constexpr size_t binding_index = static_cast <size_t >(T::binding_type_int);
74
74
static_assert (binding_index < std::tuple_size_v<BindingDataStore>);
@@ -81,10 +81,7 @@ inline T* Realm::GetBindingData(v8::Local<v8::Context> context) {
81
81
}
82
82
83
83
template <typename T, typename ... Args>
84
- inline T* Realm::AddBindingData (v8::Local<v8::Context> context,
85
- v8::Local<v8::Object> target,
86
- Args&&... args) {
87
- DCHECK_EQ (GetCurrent (context), this );
84
+ inline T* Realm::AddBindingData (v8::Local<v8::Object> target, Args&&... args) {
88
85
// This won't compile if T is not a BaseObject subclass.
89
86
static_assert (std::is_base_of_v<BaseObject, T>);
90
87
// The binding data must be weak so that it won't keep the realm reachable
@@ -93,15 +90,11 @@ inline T* Realm::AddBindingData(v8::Local<v8::Context> context,
93
90
// reachable throughout the lifetime of the realm.
94
91
BaseObjectWeakPtr<T> item =
95
92
MakeWeakBaseObject<T>(this , target, std::forward<Args>(args)...);
96
- DCHECK_EQ (context->GetAlignedPointerFromEmbedderData (
97
- ContextEmbedderIndex::kBindingDataStoreIndex ),
98
- &binding_data_store_);
99
93
constexpr size_t binding_index = static_cast <size_t >(T::binding_type_int);
100
94
static_assert (binding_index < std::tuple_size_v<BindingDataStore>);
101
- // Should not insert the binding twice .
95
+ // Each slot is expected to be assigned only once .
102
96
CHECK (!binding_data_store_[binding_index]);
103
97
binding_data_store_[binding_index] = item;
104
- DCHECK_EQ (GetBindingData<T>(context), item.get ());
105
98
return item.get ();
106
99
}
107
100
0 commit comments