Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 2b0131c

Browse files
committed
wasi: support SharedArrayBuffers as memory
This commit adds support for SharedArrayBuffers as the WASI memory.
1 parent 118fb4f commit 2b0131c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/wasi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const { Array, ArrayPrototype } = primordials;
66
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
77
const { WASI: _WASI } = internalBinding('wasi');
8+
const { isAnyArrayBuffer } = require('internal/util/types');
89

910

1011
class WASI {
@@ -46,7 +47,7 @@ class WASI {
4647

4748
if (memory instanceof WebAssembly.Memory) {
4849
memory = memory.buffer;
49-
} else {
50+
} else if (!isAnyArrayBuffer(memory)) {
5051
throw new ERR_INVALID_ARG_TYPE(
5152
'options.memory', 'WebAssembly.Memory', memory);
5253
}

src/node_wasi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void WASI::New(const FunctionCallbackInfo<Value>& args) {
4141
CHECK(args[0]->IsArray());
4242
CHECK(args[1]->IsArray());
4343
// CHECK(args[2]->IsArray());
44-
CHECK(args[3]->IsArrayBuffer());
44+
CHECK(args[3]->IsArrayBuffer() || args[3]->IsSharedArrayBuffer());
4545

4646
Environment* env = Environment::GetCurrent(args);
4747
Local<Context> context = env->context();

0 commit comments

Comments
 (0)