Commit 0d35eaa
committed
worker: allow passing JS wrapper objects via postMessage
Enable JS wrapper objects to be used as transferable or cloneable
objects in `postMessage()` calls, by having them extend a C++-backed
class.
This requires a few internal changes:
- This commit adds the possibility for transferred objects to
read/write JS values at the end of the serialization/deserialization
phases.
- This commit adds the possibility for transferred objects to list
sub-transferables, e.g. typically the public JS wrapper class
would list its C++ handle in there.
- This commit adds usage of `BaseObject` in a few more places, because
now during deserialization weakly held objects can also be involved,
in addition to `MessagePort`s.
PR-URL: #33772
Backport-PR-URL: #33965
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>1 parent 8e1698a commit 0d35eaaCopy full SHA for 0d35eaa
File tree
Expand file treeCollapse file tree
10 files changed
+384
-33
lines changedOpen diff view settings
Filter options
- lib/internal
- bootstrap
- worker
- src
- test/parallel
Expand file treeCollapse file tree
10 files changed
+384
-33
lines changedOpen diff view settings
Collapse file
lib/internal/bootstrap/node.js
Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
59 | 59 | |
60 | 60 | |
61 | 61 | |
| 62 | + |
62 | 63 | |
63 | 64 | |
64 | 65 | |
|
Collapse file
lib/internal/worker/js_transferable.js
Copy file name to clipboard+31Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
216 | 216 | |
217 | 217 | |
218 | 218 | |
| 219 | + |
219 | 220 | |
220 | 221 | |
221 | 222 | |
|
Collapse file
+9Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
123 | 123 | |
124 | 124 | |
125 | 125 | |
| 126 | + |
| 127 | + |
126 | 128 | |
127 | 129 | |
128 | 130 | |
129 | 131 | |
130 | 132 | |
131 | 133 | |
| 134 | + |
| 135 | + |
| 136 | + |
132 | 137 | |
133 | 138 | |
134 | 139 | |
| ||
137 | 142 | |
138 | 143 | |
139 | 144 | |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
140 | 149 | |
141 | 150 | |
142 | 151 | |
|
Collapse file
+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
167 | 167 | |
168 | 168 | |
169 | 169 | |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
170 | 174 | |
171 | 175 | |
172 | 176 | |
| ||
209 | 213 | |
210 | 214 | |
211 | 215 | |
| 216 | + |
212 | 217 | |
213 | 218 | |
214 | 219 | |
| ||
465 | 470 | |
466 | 471 | |
467 | 472 | |
| 473 | + |
468 | 474 | |
469 | 475 | |
470 | 476 | |
|
Collapse file
+2-1Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
97 | 97 | |
98 | 98 | |
99 | 99 | |
100 | | - |
| 100 | + |
| 101 | + |
101 | 102 | |
102 | 103 | |
103 | 104 | |
|
0 commit comments