node
node copied to clipboard
src: introduce node::Realm
To distinguish per-context values from the node::Environment
, split
those values to a new node::Realm
structure and consolidate
bootstrapping methods with it.
This allows creating multiple realms in a node::Environment
. There
can be two kinds of realms:
- A principal realm, comes with a host/implementation-defined global object,
- A synthetic realm, is created by the ShadowRealm API and includes a reduced set of global object properties.
When the changes in this PR are landed with assent, works on migrating BaseObjects to be per-realm native objects and support built-in modules in synthetics realms like ShadowRealm can be started.
Refs: https://github.com/nodejs/node/issues/42528
Review requested:
- [ ] @nodejs/gyp
- [ ] @nodejs/startup
@nodejs/cpp-reviewers
Initial read through is good. It would be helpful to have a better picture of what the additional coming changes will be. Specifically, how is this going to impact individual BaseObject and internal binding implementation
Initial read through is good. It would be helpful to have a better picture of what the additional coming changes will be. Specifically, how is this going to impact individual BaseObject and internal binding implementation
@jasnell thank you for the suggestion. The overall design of the change can be reviewed at https://docs.google.com/document/d/12_CkX6KbM9kt_lj1pdEgLB8-HQaozkJb7_nwQnHfTTg/edit?usp=sharing. Please feel free to drop a comment there!
Rebased with conflicts resolved and suggestions applied. Please take a look again :)
CI: https://ci.nodejs.org/job/node-test-pull-request/46032/
@jasnell @joyeecheung would you mind taking a look again? Thank you!
CI: https://ci.nodejs.org/job/node-test-pull-request/46227/
CI: https://ci.nodejs.org/job/node-test-pull-request/46299/
CI: https://ci.nodejs.org/job/node-test-pull-request/46333/
CI: https://ci.nodejs.org/job/node-test-pull-request/46338/
Landed in 81d9cdb8cd5109f1beadf78558ff9e37b4c63473
Backport to v18.x depends on https://github.com/nodejs/node/pull/44192
Backport to v18.x depends on #44192
Applies for v16.x as well.