New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bootstrap: include bootstrapped Environment in builtin snapshot #32984
Commits on Jul 14, 2020
-
src: split the main context initialization from Environemnt ctor
So that it's possible to create an Environment not yet attached to any V8 context. We'll use this to deserialize the V8 context before attaching an Environment to it.
-
src: add an ExternalReferenceRegistry class
Add an ExternalReferenceRegistry class for registering static external references. To register the external JS to C++ references created in a binding (e.g. when a FunctionTemplate is created): - Add the binding name (same as the id used for `internalBinding()` and `NODE_MODULE_CONTEXT_AWARE_INTERNAL`) to `EXTERNAL_REFERENCE_BINDING_LIST` in `src/node_external_reference.h`. - In the file where the binding is implemented, create a registration function to register the static C++ references (e.g. the C++ functions in `v8::FunctionCallback` associated with the function templates), like this: ```c++ void RegisterExternalReferences( ExternalReferenceRegistry* registry) { registry->Register(cpp_func_1); } ``` - At the end of the file where `NODE_MODULE_CONTEXT_AWARE_INTERNAL` is also usually called, register the registration function with ``` NODE_MODULE_EXTERNAL_REFERENCE(binding_name, RegisterExternalReferences); ```
-
tools: enable Node.js command line flags in node_mksnapshot
Pass the flags down to node_mksnapshot so that we can use them when generating the snapshot (e.g. to debug or enable V8 flags)
-
src: snapshot Environment upon instantiation
This includes the initial Environment (without running bootstrap scripts) into the builtin snapshot
-
src: make code cache test work with snapshots
Keep track of snapshotted modules in JS land, and move bootstrap switches into StartExecution() so that they are not included into part of the environment-independent bootstrap process.
-
This runs `lib/internal/bootstrap/loaders.js` before creating the builtin snapshot and deserialize the loaders from the snapshot in deserialization mode.
-
src: reset zero fill toggle at pre-execution
The connection between the JS land zero fill toggle and the C++ one in the NodeArrayBufferAllocator gets lost if the toggle is deserialized from the snapshot, because V8 owns the underlying memory of this toggle. This resets the connection at pre-execution.
-
bootstrap: build fast APIs in pre-execution
Fast APIs need to work with ArrayBuffers which we need to rebuild connections to after deserializing them from the snapshot. For now, postpone their creation until pre-execution to simplify the process.
-
lib: initialize instance members in class constructors
Since V8 snapshot does not currently support instance member initialization, initialize them in ordianry class constructors for now so that these classes can be included in the snapshot. This may be reverted once https://bugs.chromium.org/p/v8/issues/detail?id=10704 is fixed and backported.
-
This runs `lib/internal/bootstrap/node.js` before creating the builtin snapshot and deserialize the loaders from the snapshot in deserialization mode.