node icon indicating copy to clipboard operation
node copied to clipboard

src: introduce node::Realm

Open legendecas opened this issue 1 year ago • 2 comments

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

legendecas avatar Aug 08 '22 17:08 legendecas

Review requested:

  • [ ] @nodejs/gyp
  • [ ] @nodejs/startup

nodejs-github-bot avatar Aug 08 '22 17:08 nodejs-github-bot

@nodejs/cpp-reviewers

targos avatar Aug 08 '22 18:08 targos

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 avatar Aug 10 '22 13:08 jasnell

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!

legendecas avatar Aug 10 '22 16:08 legendecas

Rebased with conflicts resolved and suggestions applied. Please take a look again :)

legendecas avatar Aug 14 '22 16:08 legendecas

CI: https://ci.nodejs.org/job/node-test-pull-request/46032/

nodejs-github-bot avatar Aug 15 '22 09:08 nodejs-github-bot

@jasnell @joyeecheung would you mind taking a look again? Thank you!

legendecas avatar Aug 19 '22 06:08 legendecas

CI: https://ci.nodejs.org/job/node-test-pull-request/46227/

nodejs-github-bot avatar Aug 24 '22 16:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/46299/

nodejs-github-bot avatar Aug 28 '22 15:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/46333/

nodejs-github-bot avatar Aug 31 '22 02:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/46338/

nodejs-github-bot avatar Aug 31 '22 05:08 nodejs-github-bot

Landed in 81d9cdb8cd5109f1beadf78558ff9e37b4c63473

nodejs-github-bot avatar Aug 31 '22 14:08 nodejs-github-bot

Backport to v18.x depends on https://github.com/nodejs/node/pull/44192

legendecas avatar Sep 07 '22 17:09 legendecas

Backport to v18.x depends on #44192

Applies for v16.x as well.

juanarbol avatar Sep 30 '22 04:09 juanarbol