@@ -122,7 +122,8 @@ void Environment::ResetPromiseHooks(Local<Function> init,
122
122
// Remember to keep this code aligned with pushAsyncContext() in JS.
123
123
void AsyncHooks::push_async_context (double async_id,
124
124
double trigger_async_id,
125
- Local<Object> resource) {
125
+ Local<Object>* resource) {
126
+ CHECK_IMPLIES (resource != nullptr , !resource->IsEmpty ());
126
127
// Since async_hooks is experimental, do only perform the check
127
128
// when async_hooks is enabled.
128
129
if (fields_[kCheck ] > 0 ) {
@@ -140,14 +141,14 @@ void AsyncHooks::push_async_context(double async_id,
140
141
141
142
#ifdef DEBUG
142
143
for (uint32_t i = offset; i < native_execution_async_resources_.size (); i++)
143
- CHECK (native_execution_async_resources_[i]. IsEmpty () );
144
+ CHECK_NULL (native_execution_async_resources_[i]);
144
145
#endif
145
146
146
147
// When this call comes from JS (as a way of increasing the stack size),
147
148
// `resource` will be empty, because JS caches these values anyway.
148
- if (! resource. IsEmpty () ) {
149
+ if (resource != nullptr ) {
149
150
native_execution_async_resources_.resize (offset + 1 );
150
- // Caveat: This is a v8::Local<> assignment, we do not keep a v8::Global<>!
151
+ // Caveat: This is a v8::Local<>* assignment, we do not keep a v8::Global<>!
151
152
native_execution_async_resources_[offset] = resource;
152
153
}
153
154
}
@@ -172,11 +173,11 @@ bool AsyncHooks::pop_async_context(double async_id) {
172
173
fields_[kStackLength ] = offset;
173
174
174
175
if (offset < native_execution_async_resources_.size () &&
175
- ! native_execution_async_resources_[offset]. IsEmpty () ) [[likely]] {
176
+ native_execution_async_resources_[offset] != nullptr ) [[likely]] {
176
177
#ifdef DEBUG
177
178
for (uint32_t i = offset + 1 ; i < native_execution_async_resources_.size ();
178
179
i++) {
179
- CHECK (native_execution_async_resources_[i]. IsEmpty () );
180
+ CHECK_NULL (native_execution_async_resources_[i]);
180
181
}
181
182
#endif
182
183
native_execution_async_resources_.resize (offset);
@@ -1717,7 +1718,6 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
1717
1718
fields_(isolate, kFieldsCount , MAYBE_FIELD_PTR(info, fields)),
1718
1719
async_id_fields_(
1719
1720
isolate, kUidFieldsCount , MAYBE_FIELD_PTR(info, async_id_fields)),
1720
- native_execution_async_resources_(isolate),
1721
1721
info_(info) {
1722
1722
HandleScope handle_scope (isolate);
1723
1723
if (info == nullptr ) {
@@ -1806,10 +1806,9 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local<Context> context,
1806
1806
native_execution_async_resources_.size ());
1807
1807
for (size_t i = 0 ; i < native_execution_async_resources_.size (); i++) {
1808
1808
info.native_execution_async_resources [i] =
1809
- native_execution_async_resources_[i].IsEmpty () ? SIZE_MAX :
1810
- creator->AddData (
1811
- context,
1812
- native_execution_async_resources_[i]);
1809
+ native_execution_async_resources_[i] == nullptr
1810
+ ? SIZE_MAX
1811
+ : creator->AddData (context, *native_execution_async_resources_[i]);
1813
1812
}
1814
1813
1815
1814
// At the moment, promise hooks are not supported in the startup snapshot.
0 commit comments