@@ -259,6 +259,19 @@ std::vector<size_t> IsolateData::Serialize(SnapshotCreator* creator) {
259
259
#undef VY
260
260
#undef VS
261
261
#undef VP
262
+
263
+ #define V (PropertyName, TypeName ) \
264
+ do { \
265
+ Local<TypeName> field = PropertyName (); \
266
+ if (!field.IsEmpty ()) { \
267
+ indexes.push_back (creator->AddData (field)); \
268
+ } else { \
269
+ indexes.push_back (0 ); \
270
+ } \
271
+ } while (0 );
272
+ PER_ISOLATE_TEMPLATE_PROPERTIES (V)
273
+ #undef V
274
+
262
275
for (size_t i = 0 ; i < AsyncWrap::PROVIDERS_LENGTH; i++)
263
276
indexes.push_back (creator->AddData (async_wrap_provider (i)));
264
277
@@ -290,6 +303,22 @@ void IsolateData::DeserializeProperties(const std::vector<size_t>* indexes) {
290
303
#undef VS
291
304
#undef VP
292
305
306
+ #define V (PropertyName, TypeName ) \
307
+ do { \
308
+ size_t index = (*indexes)[i++]; \
309
+ if (index != 0 ) { \
310
+ MaybeLocal<TypeName> maybe_field = \
311
+ isolate_->GetDataFromSnapshotOnce <TypeName>(index); \
312
+ Local<TypeName> field; \
313
+ if (!maybe_field.ToLocal (&field)) { \
314
+ fprintf (stderr, " Failed to deserialize " #PropertyName " \n " ); \
315
+ } \
316
+ PropertyName##_.Set (isolate_, field); \
317
+ } \
318
+ } while (0 );
319
+ PER_ISOLATE_TEMPLATE_PROPERTIES (V)
320
+ #undef V
321
+
293
322
for (size_t j = 0 ; j < AsyncWrap::PROVIDERS_LENGTH; j++) {
294
323
MaybeLocal<String> maybe_field =
295
324
isolate_->GetDataFromSnapshotOnce <String>((*indexes)[i++]);
@@ -1751,19 +1780,6 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) {
1751
1780
should_abort_on_uncaught_toggle_.Serialize (ctx, creator);
1752
1781
1753
1782
size_t id = 0 ;
1754
- #define V (PropertyName, TypeName ) \
1755
- do { \
1756
- Local<TypeName> field = PropertyName (); \
1757
- if (!field.IsEmpty ()) { \
1758
- size_t index = creator->AddData (field); \
1759
- info.persistent_templates .push_back ({#PropertyName, id, index}); \
1760
- } \
1761
- id++; \
1762
- } while (0 );
1763
- ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES (V)
1764
- #undef V
1765
-
1766
- id = 0 ;
1767
1783
#define V (PropertyName, TypeName ) \
1768
1784
do { \
1769
1785
Local<TypeName> field = PropertyName (); \
@@ -1820,9 +1836,6 @@ std::ostream& operator<<(std::ostream& output, const EnvSerializeInfo& i) {
1820
1836
<< i.stream_base_state << " , // stream_base_state\n "
1821
1837
<< i.should_abort_on_uncaught_toggle
1822
1838
<< " , // should_abort_on_uncaught_toggle\n "
1823
- << " // -- persistent_templates begins --\n "
1824
- << i.persistent_templates << " ,\n "
1825
- << " // persistent_templates ends --\n "
1826
1839
<< " // -- persistent_values begins --\n "
1827
1840
<< i.persistent_values << " ,\n "
1828
1841
<< " // -- persistent_values ends --\n "
@@ -1871,7 +1884,7 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
1871
1884
std::cerr << *info << " \n " ;
1872
1885
}
1873
1886
1874
- const std::vector<PropInfo>& templates = info->persistent_templates ;
1887
+ const std::vector<PropInfo>& values = info->persistent_values ;
1875
1888
size_t i = 0 ; // index to the array
1876
1889
size_t id = 0 ;
1877
1890
#define SetProperty (PropertyName, TypeName, vector, type, from ) \
@@ -1890,16 +1903,9 @@ void Environment::DeserializeProperties(const EnvSerializeInfo* info) {
1890
1903
set_##PropertyName (field); \
1891
1904
i++; \
1892
1905
} \
1893
- } while (0 ); \
1894
- id++;
1895
- #define V (PropertyName, TypeName ) SetProperty(PropertyName, TypeName, \
1896
- templates, template , isolate_)
1897
- ENVIRONMENT_STRONG_PERSISTENT_TEMPLATES (V);
1898
- #undef V
1906
+ id++; \
1907
+ } while (0 );
1899
1908
1900
- i = 0 ; // index to the array
1901
- id = 0 ;
1902
- const std::vector<PropInfo>& values = info->persistent_values ;
1903
1909
#define V (PropertyName, TypeName ) SetProperty(PropertyName, TypeName, \
1904
1910
values, value, ctx)
1905
1911
ENVIRONMENT_STRONG_PERSISTENT_VALUES (V);
0 commit comments