Skip to content

bootstrap: include v8 and fs modules in the startup snapshot

Fixes: https://github.com/nodejs/node/issues/35930 Refs: https://github.com/nodejs/node/issues/35711

The basic idea is:

  1. Before serialization is done, iterate over supported embeder objects and perform whatever necessary to clean up the embedder objects. In the case of V8 and fs binding data, since we can discard the contents of these AliasedBuffers anyway, we'll just release them so that V8 don't error on unregistered global handles - I have a different POC of actually storing them behind private symbols so that we can retrieve them at deserialization time, but in these two particular cases it doesn't seem to worth the trouble, we can just reinitialize these buffers.
  2. At serialization time, we save whatever data we need for each embedder slot to be deserialized properly. For v8 and fs bindings we just need to return a type constant in the callback for V8
  3. At deserialization time, we enqueue functions in the deserialization callback of the context. We don't invoke them right away because it's more convenient to dehydrate the objects when the graph is completed (also potentially it's better if different embedder fields of one object depend on each other and need to be deserialized in a particular order).

src: support serialization of binding data

This patch adds the SnapshotableObject interface. Native objects supporting serialization can inherit from it, implementing PrepareForSerialization(), Serialize() and Deserialize() to control how the native states should be serialized and deserialized.

See doc: https://docs.google.com/document/d/15bu038I36oILq5t4Qju1sS2nKudVB6NSGWz00oD48Q8/edit

bootstrap: include fs module into the builtin snapshot

bootstrap: include v8 module into the builtin snapshot

Merge request reports

Loading