Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upworker: implement worker.moveMessagePortToContext() #26497
Conversation
addaleax
added
vm
semver-minor
worker
labels
Mar 7, 2019
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
the
lib / src
label
Mar 7, 2019
addaleax
force-pushed the
addaleax:worker-messageport-move
branch
4 times, most recently
from
b58679b
to
1153455
Mar 7, 2019
This comment has been minimized.
This comment has been minimized.
jasnell
approved these changes
Mar 7, 2019
This comment has been minimized.
This comment has been minimized.
|
@chjj I’m not a 100 % sure but this might also make it easier to implement something closer to a “real” WebWorker-style Environment in Node.js, because you can control the global object and still have |
addaleax
requested a review
from
joyeecheung
Mar 8, 2019
This comment has been minimized.
This comment has been minimized.
BridgeAR
added
the
author ready
label
Mar 8, 2019
gengjiawen
reviewed
Mar 8, 2019
gengjiawen
approved these changes
Mar 8, 2019
addaleax
force-pushed the
addaleax:worker-messageport-move
branch
from
e8b1b4a
to
bd0ef7a
Mar 9, 2019
This comment has been minimized.
This comment has been minimized.
|
Rebased, new CI: https://ci.nodejs.org/job/node-test-pull-request/21369/ |
This comment has been minimized.
This comment has been minimized.
|
/cc @nodejs/workers |
joyeecheung
reviewed
Mar 9, 2019
|
The code generally LGTM but I have some questions |
| FIXED_ONE_BYTE_STRING(isolate, "node:per_context_binding_exports")); | ||
|
|
||
| Local<Value> existing_value; | ||
| if (!global->GetPrivate(context, key).ToLocal(&existing_value)) |
This comment has been minimized.
This comment has been minimized.
joyeecheung
Mar 9, 2019
•
Member
Can we use context->GetExtrasBindingObject() to store these somehow instead of using v8 privates (which are...an experimental feature. Use at your own risk.)? V8 already puts isTraceCategoryEnabled and trace in there.
This comment has been minimized.
This comment has been minimized.
addaleax
Mar 10, 2019
Author
Member
We’ve been using V8 privates extensively for a while, I don’t think they’re going away (and if they did we’d have bigger problems, e.g. N-API relies on them as well).
But yes, if you prefer, we could use the extras binding object for that … I feel like that’s mostly intended for actual v8-extras, but in theory nothing stops us, and I don’t mind making the switch if you prefer.
This comment has been minimized.
This comment has been minimized.
joyeecheung
Mar 13, 2019
Member
@addaleax I don't have very strong opinions about the choices here...although I wonder what does this look like in the heap snapshot? Do they show up?
BTW, we probably need to do something similar for the Environment persistent handles (save them temporarily to the global proxy) when we implement snapshots...
addaleax
force-pushed the
addaleax:worker-messageport-move
branch
3 times, most recently
from
76070c3
to
8937fd6
Mar 11, 2019
This comment has been minimized.
This comment has been minimized.
|
Rebased again, CI: https://ci.nodejs.org/job/node-test-pull-request/21464/ |
This comment has been minimized.
This comment has been minimized.
|
CI is green. I’ll land this tomorrow if there are no objections, but I’d appreciate another review from @nodejs/workers. |
This comment has been minimized.
This comment has been minimized.
|
@addaleax, yeah, that's a possibility. Someone could replicate the web worker scope exactly with |
chjj
added a commit
to chjj/bthreads
that referenced
this pull request
Mar 14, 2019
addaleax
added some commits
Mar 7, 2019
addaleax
force-pushed the
addaleax:worker-messageport-move
branch
from
8937fd6
to
23bf4ce
Mar 15, 2019
This comment has been minimized.
This comment has been minimized.
|
Sigh… Needed to update this because of |
This comment has been minimized.
This comment has been minimized.
|
Landed in 0752a18...fe8972a |
addaleax commentedMar 7, 2019
src,lib: allow running multiple per-context files
Create an
lib/internal/per_context/directory that canhost multiple files which we execute for each context.
src,lib: make DOMException available in all Contexts
This allows using
DOMExceptionfrom Node.js code for anyvm.Context.worker: implement worker.moveMessagePortToContext()
This enables using
MessagePorts in differentvm.Contexts,aiding with the isolation that the
vmmodule seeks to provide.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes