Commit fb85d38
cli: allow running wasm in limited vmem with --disable-wasm-trap-handler
By default, Node.js enables trap-handler-based WebAssembly bound
checks. As a result, V8 does not need to insert inline bound checks
int the code compiled from WebAssembly which may speedup WebAssembly
execution significantly, but this optimization requires allocating
a big virtual memory cage (currently 10GB). If the Node.js process
does not have access to a large enough virtual memory address space
due to system configurations or hardware limitations, users won't
be able to run any WebAssembly that involves allocation in this
virtual memory cage and will see an out-of-memory error.
```console
$ ulimit -v 5000000
$ node -p "new WebAssembly.Memory({ initial: 10, maximum: 100 });"
[eval]:1
new WebAssembly.Memory({ initial: 10, maximum: 100 });
^
RangeError: WebAssembly.Memory(): could not allocate memory
at [eval]:1:1
at runScriptInThisContext (node:internal/vm:209:10)
at node:internal/process/execution:118:14
at [eval]-wrapper:6:24
at runScript (node:internal/process/execution:101:62)
at evalScript (node:internal/process/execution:136:3)
at node:internal/main/eval_string:49:3
```
`--disable-wasm-trap-handler` disables this optimization so that
users can at least run WebAssembly (with a less optimial performance)
when the virtual memory address space available to their Node.js
process is lower than what the V8 WebAssembly memory cage needs.
PR-URL: #52766
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>1 parent c6043fe commit fb85d38Copy full SHA for fb85d38
File tree
Expand file treeCollapse file tree
9 files changed
+127
-31
lines changedOpen diff view settings
Filter options
- doc
- api
- src
- test
- testpy
- wasm-allocation
Expand file treeCollapse file tree
9 files changed
+127
-31
lines changedOpen diff view settings
Collapse file
+40Lines changed: 40 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
565 | 565 | |
566 | 566 | |
567 | 567 | |
| 568 | + |
| 569 | + |
| 570 | + |
| 571 | + |
| 572 | + |
| 573 | + |
| 574 | + |
| 575 | + |
| 576 | + |
| 577 | + |
| 578 | + |
| 579 | + |
| 580 | + |
| 581 | + |
| 582 | + |
| 583 | + |
| 584 | + |
| 585 | + |
| 586 | + |
| 587 | + |
| 588 | + |
| 589 | + |
| 590 | + |
| 591 | + |
| 592 | + |
| 593 | + |
| 594 | + |
| 595 | + |
| 596 | + |
| 597 | + |
| 598 | + |
| 599 | + |
| 600 | + |
| 601 | + |
| 602 | + |
| 603 | + |
| 604 | + |
| 605 | + |
| 606 | + |
568 | 607 | |
569 | 608 | |
570 | 609 | |
| ||
2634 | 2673 | |
2635 | 2674 | |
2636 | 2675 | |
| 2676 | + |
2637 | 2677 | |
2638 | 2678 | |
2639 | 2679 | |
|
Collapse file
+5Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
142 | 142 | |
143 | 143 | |
144 | 144 | |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
145 | 150 | |
146 | 151 | |
147 | 152 | |
|
Collapse file
+38-31Lines changed: 38 additions & 31 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
425 | 425 | |
426 | 426 | |
427 | 427 | |
| 428 | + |
428 | 429 | |
429 | 430 | |
430 | 431 | |
| ||
470 | 471 | |
471 | 472 | |
472 | 473 | |
473 | | - |
| 474 | + |
| 475 | + |
| 476 | + |
474 | 477 | |
475 | 478 | |
476 | 479 | |
477 | 480 | |
478 | 481 | |
479 | | - |
| 482 | + |
480 | 483 | |
481 | | - |
| 484 | + |
482 | 485 | |
483 | 486 | |
484 | 487 | |
| ||
630 | 633 | |
631 | 634 | |
632 | 635 | |
633 | | - |
634 | | - |
635 | | - |
636 | | - |
637 | | - |
638 | | - |
639 | | - |
640 | | - |
641 | | - |
642 | | - |
643 | | - |
644 | | - |
645 | | - |
646 | | - |
647 | | - |
648 | | - |
649 | | - |
650 | | - |
651 | | - |
652 | 636 | |
653 | 637 | |
654 | 638 | |
| ||
675 | 659 | |
676 | 660 | |
677 | 661 | |
678 | | - |
679 | | - |
680 | | - |
681 | | - |
682 | | - |
683 | | - |
684 | | - |
685 | | - |
686 | 662 | |
687 | 663 | |
688 | 664 | |
| ||
1225 | 1201 | |
1226 | 1202 | |
1227 | 1203 | |
| 1204 | + |
| 1205 | + |
| 1206 | + |
| 1207 | + |
| 1208 | + |
| 1209 | + |
| 1210 | + |
| 1211 | + |
| 1212 | + |
| 1213 | + |
| 1214 | + |
| 1215 | + |
| 1216 | + |
| 1217 | + |
| 1218 | + |
| 1219 | + |
| 1220 | + |
| 1221 | + |
| 1222 | + |
| 1223 | + |
| 1224 | + |
| 1225 | + |
| 1226 | + |
| 1227 | + |
| 1228 | + |
| 1229 | + |
| 1230 | + |
| 1231 | + |
| 1232 | + |
| 1233 | + |
| 1234 | + |
1228 | 1235 | |
1229 | 1236 | |
1230 | 1237 | |
| ||
1254 | 1261 | |
1255 | 1262 | |
1256 | 1263 | |
1257 | | - |
| 1264 | + |
1258 | 1265 | |
1259 | 1266 | |
1260 | 1267 | |
|
Collapse file
+7Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1066 | 1066 | |
1067 | 1067 | |
1068 | 1068 | |
| 1069 | + |
| 1070 | + |
| 1071 | + |
| 1072 | + |
| 1073 | + |
| 1074 | + |
| 1075 | + |
1069 | 1076 | |
1070 | 1077 | |
1071 | 1078 | |
|
Collapse file
+2Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
306 | 306 | |
307 | 307 | |
308 | 308 | |
| 309 | + |
| 310 | + |
309 | 311 | |
310 | 312 | |
311 | 313 | |
|
Collapse file
+12Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
167 | 167 | |
168 | 168 | |
169 | 169 | |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
Collapse file
test/wasm-allocation/test-wasm-allocation.js
Copy file name to clipboard+7Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
Collapse file
test/wasm-allocation/testcfg.py
Copy file name to clipboard+6Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
Collapse file
test/wasm-allocation/wasm-allocation.status
Copy file name to clipboard+10Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
0 commit comments