88#include " node_buffer.h"
99#include " node_context_data.h"
1010#include " node_errors.h"
11+ #include " node_file.h"
1112#include " node_internals.h"
1213#include " node_options-inl.h"
1314#include " node_process.h"
15+ #include " node_v8.h"
1416#include " node_v8_platform-inl.h"
1517#include " node_worker.h"
1618#include " req_wrap-inl.h"
@@ -1258,6 +1260,7 @@ EnvSerializeInfo Environment::Serialize(SnapshotCreator* creator) {
12581260 EnvSerializeInfo info;
12591261 Local<Context> ctx = context ();
12601262
1263+ SerializeBindingData (this , creator, &info);
12611264 // Currently all modules are compiled without cache in builtin snapshot
12621265 // builder.
12631266 info.native_modules = std::vector<std::string>(
@@ -1324,6 +1327,9 @@ std::ostream& operator<<(std::ostream& output,
13241327
13251328std::ostream& operator <<(std::ostream& output, const EnvSerializeInfo& i) {
13261329 output << " {\n "
1330+ << " // -- bindings begins --\n "
1331+ << i.bindings << " ,\n "
1332+ << " // -- bindings ends --\n "
13271333 << " // -- native_modules begins --\n "
13281334 << i.native_modules << " ,\n "
13291335 << " // -- native_modules ends --\n "
@@ -1349,9 +1355,29 @@ std::ostream& operator<<(std::ostream& output, const EnvSerializeInfo& i) {
13491355 return output;
13501356}
13511357
1358+ void Environment::EnqueueDeserializeRequest (DeserializeRequest request) {
1359+ deserialize_requests_.push_back (std::move (request));
1360+ }
1361+
1362+ void Environment::RunDeserializeRequests () {
1363+ HandleScope scope (isolate ());
1364+ Local<Context> ctx = context ();
1365+ Isolate* is = isolate ();
1366+ while (!deserialize_requests_.empty ()) {
1367+ DeserializeRequest request (std::move (deserialize_requests_.front ()));
1368+ deserialize_requests_.pop_front ();
1369+ Local<Object> holder = request.holder .Get (is);
1370+ request.cb (ctx, holder, request.info );
1371+ request.holder .Reset (); // unnecessary?
1372+ request.info ->Delete ();
1373+ }
1374+ }
1375+
13521376void Environment::DeserializeProperties (const EnvSerializeInfo* info) {
13531377 Local<Context> ctx = context ();
13541378
1379+ RunDeserializeRequests ();
1380+
13551381 native_modules_in_snapshot = info->native_modules ;
13561382 async_hooks_.Deserialize (ctx);
13571383 immediate_info_.Deserialize (ctx);
0 commit comments