Skip to content

Commit 867d809

Browse files
committed
wasm: enable JSPI
1 parent 4612c79 commit 867d809

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/node.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ static ExitCode ProcessGlobalArgsInternal(std::vector<std::string>* args,
782782

783783
v8_args.emplace_back("--js-source-phase-imports");
784784

785+
// WebAssembly JS Promise Integration
786+
v8_args.emplace_back("--experimental-wasm-jspi");
787+
785788
#ifdef __POSIX__
786789
// Block SIGPROF signals when sleeping in epoll_wait/kevent/etc. Avoids the
787790
// performance penalty of frequent EINTR wakeups when the profiler is running.

test/fixtures/wasm/jspi.wasm

85 Bytes
Binary file not shown.

test/parallel/test-wasm.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import '../common/index.mjs';
2+
import { strictEqual } from 'node:assert';
3+
import { readSync } from '../common/fixtures.mjs';
4+
5+
// Test Wasm JSPI
6+
{
7+
const asyncImport = async (x) => {
8+
await new Promise((resolve) => setTimeout(resolve, 10));
9+
return x + 42;
10+
};
11+
12+
const { instance } = await WebAssembly.instantiate(readSync('wasm/jspi.wasm'), {
13+
js: {
14+
async: new WebAssembly.Suspending(asyncImport),
15+
},
16+
});
17+
18+
const promisingExport = WebAssembly.promising(instance.exports.test);
19+
strictEqual(await promisingExport(10), 52);
20+
}

0 commit comments

Comments
 (0)