Commit 14cd6b9
committed
feat(runtime): native MessagePort, MessageChannel, BroadcastChannel, and node:worker_threads
Ports are Node's three-way split without libuv: an isolate-free PortData
(mutex-guarded queue, sibling-group entanglement) under a per-isolate
NativeMessagePort whose wake is a coalesced EventLoop::PostInternal —
producers never take a foreign isolate's Locker. Pairwise channels and
named BroadcastChannel groups share one SiblingGroup mechanism; close
sentinels are empty messages ordered behind queued traffic.
Ports transfer through postMessage and structuredClone as host-object
tag 2 on the DOMException wire format: index in-stream, PortData
out-of-band, nothing detached until the whole graph has written, and
received ports pre-constructed before ReadValue since no JS may run
inside ReadHostObject. In passing this fixes claimed host objects
suppressing V8's embedder-field detection (ObjC wrappers were written
as plain objects once any DOMException existed) and a dangling handle
in Deserialize's ports out-parameter.
Worker and the worker global scope are now real EventTargets: delivery
dispatches MessageEvents through defineEventHandler-backed onmessage
attributes (position-fixed HTML handler semantics), replacing the
direct property calls. Handler wrappers live on the target's own
listener bag — a WeakMap keyed by ObjectManager-registered objects
corrupts the heap when the finalizer resurrects them.
node:worker_threads ships the real MessageChannel/MessagePort/
BroadcastChannel/receiveMessageOnPort/threadId/environment-data
surface with documented shims for the rest (docs/worker-threads.md).
New globals ride the lazy tier: MessagePort, MessageChannel,
BroadcastChannel, MessageEvent.
Suite: 1664/0 (+154 messaging specs in the shared submodule).1 parent 0e243e6 commit 14cd6b9
28 files changed
Lines changed: 3100 additions & 156 deletions
File tree
- NativeScript/runtime
- js
- TestRunner/app
- tests
- docs
- tools
- v8ios.xcodeproj
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
0 commit comments