@@ -120,7 +120,8 @@ void Environment::ResetPromiseHooks(Local<Function> init,
120120// Remember to keep this code aligned with pushAsyncContext() in JS.
121121void AsyncHooks::push_async_context (double async_id,
122122 double trigger_async_id,
123- Local<Object> resource) {
123+ Local<Object>* resource) {
124+ CHECK_IMPLIES (resource != nullptr , !resource->IsEmpty ());
124125 // Since async_hooks is experimental, do only perform the check
125126 // when async_hooks is enabled.
126127 if (fields_[kCheck ] > 0 ) {
@@ -138,14 +139,14 @@ void AsyncHooks::push_async_context(double async_id,
138139
139140#ifdef DEBUG
140141 for (uint32_t i = offset; i < native_execution_async_resources_.size (); i++)
141- CHECK (native_execution_async_resources_[i]. IsEmpty () );
142+ CHECK_NULL (native_execution_async_resources_[i]);
142143#endif
143144
144145 // When this call comes from JS (as a way of increasing the stack size),
145146 // `resource` will be empty, because JS caches these values anyway.
146- if (! resource. IsEmpty () ) {
147+ if (resource != nullptr ) {
147148 native_execution_async_resources_.resize (offset + 1 );
148- // Caveat: This is a v8::Local<> assignment, we do not keep a v8::Global<>!
149+ // Caveat: This is a v8::Local<>* assignment, we do not keep a v8::Global<>!
149150 native_execution_async_resources_[offset] = resource;
150151 }
151152}
@@ -170,11 +171,11 @@ bool AsyncHooks::pop_async_context(double async_id) {
170171 fields_[kStackLength ] = offset;
171172
172173 if (offset < native_execution_async_resources_.size () &&
173- ! native_execution_async_resources_[offset]. IsEmpty () ) [[likely]] {
174+ native_execution_async_resources_[offset] != nullptr ) [[likely]] {
174175#ifdef DEBUG
175176 for (uint32_t i = offset + 1 ; i < native_execution_async_resources_.size ();
176177 i++) {
177- CHECK (native_execution_async_resources_[i]. IsEmpty () );
178+ CHECK_NULL (native_execution_async_resources_[i]);
178179 }
179180#endif
180181 native_execution_async_resources_.resize (offset);
@@ -1740,7 +1741,6 @@ AsyncHooks::AsyncHooks(Isolate* isolate, const SerializeInfo* info)
17401741 fields_(isolate, kFieldsCount , MAYBE_FIELD_PTR(info, fields)),
17411742 async_id_fields_(
17421743 isolate, kUidFieldsCount , MAYBE_FIELD_PTR(info, async_id_fields)),
1743- native_execution_async_resources_(isolate),
17441744 info_(info) {
17451745 HandleScope handle_scope (isolate);
17461746 if (info == nullptr ) {
@@ -1829,10 +1829,9 @@ AsyncHooks::SerializeInfo AsyncHooks::Serialize(Local<Context> context,
18291829 native_execution_async_resources_.size ());
18301830 for (size_t i = 0 ; i < native_execution_async_resources_.size (); i++) {
18311831 info.native_execution_async_resources [i] =
1832- native_execution_async_resources_[i].IsEmpty () ? SIZE_MAX :
1833- creator->AddData (
1834- context,
1835- native_execution_async_resources_[i]);
1832+ native_execution_async_resources_[i] == nullptr
1833+ ? SIZE_MAX
1834+ : creator->AddData (context, *native_execution_async_resources_[i]);
18361835 }
18371836
18381837 // At the moment, promise hooks are not supported in the startup snapshot.
0 commit comments