@@ -122,7 +122,8 @@ void Environment::ResetPromiseHooks(Local<Function> init,
122122// Remember to keep this code aligned with pushAsyncContext() in JS.
123123void AsyncHooks::push_async_context (double async_id,
124124 double trigger_async_id,
125- Local<Object> resource) {
125+ Local<Object>* resource) {
126+ CHECK_IMPLIES (resource != nullptr , !resource->IsEmpty ());
126127 // Since async_hooks is experimental, do only perform the check
127128 // when async_hooks is enabled.
128129 if (fields_[kCheck ] > 0 ) {
@@ -140,14 +141,14 @@ void AsyncHooks::push_async_context(double async_id,
140141
141142#ifdef DEBUG
142143 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]);
144145#endif
145146
146147 // When this call comes from JS (as a way of increasing the stack size),
147148 // `resource` will be empty, because JS caches these values anyway.
148- if (! resource. IsEmpty () ) {
149+ if (resource != nullptr ) {
149150 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<>!
151152 native_execution_async_resources_[offset] = resource;
152153 }
153154}
@@ -172,11 +173,11 @@ bool AsyncHooks::pop_async_context(double async_id) {
172173 fields_[kStackLength ] = offset;
173174
174175 if (offset < native_execution_async_resources_.size () &&
175- ! native_execution_async_resources_[offset]. IsEmpty () ) [[likely]] {
176+ native_execution_async_resources_[offset] != nullptr ) [[likely]] {
176177#ifdef DEBUG
177178 for (uint32_t i = offset + 1 ; i < native_execution_async_resources_.size ();
178179 i++) {
179- CHECK (native_execution_async_resources_[i]. IsEmpty () );
180+ CHECK_NULL (native_execution_async_resources_[i]);
180181 }
181182#endif
182183 native_execution_async_resources_.resize (offset);
@@ -1717,7 +1718,6 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
17171718 fields_(isolate, kFieldsCount , MAYBE_FIELD_PTR(info, fields)),
17181719 async_id_fields_(
17191720 isolate, kUidFieldsCount , MAYBE_FIELD_PTR(info, async_id_fields)),
1720- native_execution_async_resources_(isolate),
17211721 info_(info) {
17221722 HandleScope handle_scope (isolate);
17231723 if (info == nullptr ) {
@@ -1806,10 +1806,9 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local<Context> context,
18061806 native_execution_async_resources_.size ());
18071807 for (size_t i = 0 ; i < native_execution_async_resources_.size (); i++) {
18081808 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]);
18131812 }
18141813
18151814 // At the moment, promise hooks are not supported in the startup snapshot.
0 commit comments