@@ -76,6 +76,8 @@ std::vector<size_t> IsolateData::Serialize(SnapshotCreator* creator) {
76
76
#undef VY
77
77
#undef VS
78
78
#undef VP
79
+ for (size_t i = 0 ; i < AsyncWrap::PROVIDERS_LENGTH; i++)
80
+ indexes.push_back (creator->AddData (async_wrap_provider (i)));
79
81
80
82
return indexes;
81
83
}
@@ -103,6 +105,15 @@ void IsolateData::DeserializeProperties(const std::vector<size_t>* indexes) {
103
105
#undef VY
104
106
#undef VS
105
107
#undef VP
108
+
109
+ for (size_t j = 0 ; j < AsyncWrap::PROVIDERS_LENGTH; j++) {
110
+ MaybeLocal<String> field =
111
+ isolate_->GetDataFromSnapshotOnce <String>((*indexes)[i++]);
112
+ if (field.IsEmpty ()) {
113
+ fprintf (stderr, " Failed to deserialize AsyncWrap provider %zu\n " , j);
114
+ }
115
+ async_wrap_providers_[j].Set (isolate_, field.ToLocalChecked ());
116
+ }
106
117
}
107
118
108
119
void IsolateData::CreateProperties () {
@@ -153,6 +164,20 @@ void IsolateData::CreateProperties() {
153
164
.ToLocalChecked ());
154
165
PER_ISOLATE_STRING_PROPERTIES (V)
155
166
#undef V
167
+
168
+ // Create all the provider strings that will be passed to JS. Place them in
169
+ // an array so the array index matches the PROVIDER id offset. This way the
170
+ // strings can be retrieved quickly.
171
+ #define V (Provider ) \
172
+ async_wrap_providers_[AsyncWrap::PROVIDER_ ## Provider].Set ( \
173
+ isolate_, \
174
+ v8::String::NewFromOneByte ( \
175
+ isolate_, \
176
+ reinterpret_cast <const uint8_t *>(#Provider), \
177
+ v8::NewStringType::kInternalized , \
178
+ sizeof (#Provider) - 1 ).ToLocalChecked ());
179
+ NODE_ASYNC_PROVIDER_TYPES (V)
180
+ #undef V
156
181
}
157
182
158
183
IsolateData::IsolateData (Isolate* isolate,
@@ -190,6 +215,8 @@ void IsolateData::MemoryInfo(MemoryTracker* tracker) const {
190
215
PER_ISOLATE_STRING_PROPERTIES (V)
191
216
#undef V
192
217
218
+ tracker->TrackField (" async_wrap_providers" , async_wrap_providers_);
219
+
193
220
if (node_allocator_ != nullptr ) {
194
221
tracker->TrackFieldWithSize (
195
222
" node_allocator" , sizeof (*node_allocator_), " NodeArrayBufferAllocator" );
@@ -951,7 +978,6 @@ void TickInfo::MemoryInfo(MemoryTracker* tracker) const {
951
978
}
952
979
953
980
void AsyncHooks::MemoryInfo (MemoryTracker* tracker) const {
954
- tracker->TrackField (" providers" , providers_);
955
981
tracker->TrackField (" async_ids_stack" , async_ids_stack_);
956
982
tracker->TrackField (" fields" , fields_);
957
983
tracker->TrackField (" async_id_fields" , async_id_fields_);
0 commit comments