8
8
#include " node_buffer.h"
9
9
#include " node_context_data.h"
10
10
#include " node_errors.h"
11
+ #include " node_file.h"
11
12
#include " node_internals.h"
12
13
#include " node_options-inl.h"
13
14
#include " node_process.h"
15
+ #include " node_v8.h"
14
16
#include " node_v8_platform-inl.h"
15
17
#include " node_worker.h"
16
18
#include " req_wrap-inl.h"
@@ -1249,6 +1251,7 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) {
1249
1251
EnvSerializeInfo info;
1250
1252
Local<Context> ctx = context ();
1251
1253
1254
+ SerializeBindingData (this , creator, &info);
1252
1255
// Currently all modules are compiled without cache in builtin snapshot
1253
1256
// builder.
1254
1257
info.native_modules = std::vector<std::string>(
@@ -1315,6 +1318,9 @@ std::ostream& operator<<(std::ostream& output,
1315
1318
1316
1319
std::ostream& operator <<(std::ostream& output, const EnvSerializeInfo& i) {
1317
1320
output << " {\n "
1321
+ << " // -- bindings begins --\n "
1322
+ << i.bindings << " ,\n "
1323
+ << " // -- bindings ends --\n "
1318
1324
<< " // -- native_modules begins --\n "
1319
1325
<< i.native_modules << " ,\n "
1320
1326
<< " // -- native_modules ends --\n "
@@ -1340,9 +1346,29 @@ std::ostream& operator<<(std::ostream& output, const EnvSerializeInfo& i) {
1340
1346
return output;
1341
1347
}
1342
1348
1349
+ void Environment::EnqueueDeserializeRequest (DeserializeRequest request) {
1350
+ deserialize_requests_.push_back (std::move (request));
1351
+ }
1352
+
1353
+ void Environment::RunDeserializeRequests () {
1354
+ HandleScope scope (isolate ());
1355
+ Local<Context> ctx = context ();
1356
+ Isolate* is = isolate ();
1357
+ while (!deserialize_requests_.empty ()) {
1358
+ DeserializeRequest request (std::move (deserialize_requests_.front ()));
1359
+ deserialize_requests_.pop_front ();
1360
+ Local<Object> holder = request.holder .Get (is);
1361
+ request.cb (ctx, holder, request.info );
1362
+ request.holder .Reset (); // unnecessary?
1363
+ request.info ->Delete ();
1364
+ }
1365
+ }
1366
+
1343
1367
void Environment::DeserializeProperties (const EnvSerializeInfo* info) {
1344
1368
Local<Context> ctx = context ();
1345
1369
1370
+ RunDeserializeRequests ();
1371
+
1346
1372
native_modules_in_snapshot = info->native_modules ;
1347
1373
async_hooks_.Deserialize (ctx);
1348
1374
immediate_info_.Deserialize (ctx);
0 commit comments