summaryrefslogtreecommitdiff
path: root/src/abi
diff options
context:
space:
mode:
Diffstat (limited to 'src/abi')
-rw-r--r--src/abi/js.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/abi/js.h b/src/abi/js.h
index de74899b6..c8ac94407 100644
--- a/src/abi/js.h
+++ b/src/abi/js.h
@@ -44,14 +44,21 @@ extern cashew::IString SCRATCH_LOAD_F32;
extern cashew::IString SCRATCH_STORE_F32;
extern cashew::IString SCRATCH_LOAD_F64;
extern cashew::IString SCRATCH_STORE_F64;
+extern cashew::IString MEMORY_INIT;
+extern cashew::IString MEMORY_FILL;
+extern cashew::IString MEMORY_COPY;
+extern cashew::IString DATA_DROP;
+extern cashew::IString ATOMIC_WAIT_I32;
+extern cashew::IString ATOMIC_RMW_I64;
+extern cashew::IString GET_STASHED_BITS;
-// The wasm2js scratch memory helpers let us read and write to scratch memory
-// for purposes of implementing things like reinterpret, etc.
+// The wasm2js helpers let us do things that can't be done without special help,
+// like read and write to scratch memory for purposes of implementing things
+// like reinterpret, etc.
// The optional "specific" parameter is a specific function we want. If not
// provided, we create them all.
-inline void
-ensureScratchMemoryHelpers(Module* wasm,
- cashew::IString specific = cashew::IString()) {
+inline void ensureHelpers(Module* wasm,
+ cashew::IString specific = cashew::IString()) {
auto ensureImport = [&](Name name, Type params, Type results) {
if (wasm->getFunctionOrNull(name)) {
return;
@@ -75,13 +82,28 @@ ensureScratchMemoryHelpers(Module* wasm,
ensureImport(SCRATCH_STORE_F32, {Type::f32}, Type::none);
ensureImport(SCRATCH_LOAD_F64, {}, Type::f64);
ensureImport(SCRATCH_STORE_F64, {Type::f64}, Type::none);
+ ensureImport(
+ MEMORY_INIT, {Type::i32, Type::i32, Type::i32, Type::i32}, Type::none);
+ ensureImport(MEMORY_FILL, {Type::i32, Type::i32, Type::i32}, Type::none);
+ ensureImport(MEMORY_COPY, {Type::i32, Type::i32, Type::i32}, Type::none);
+ ensureImport(DATA_DROP, {Type::i32}, Type::none);
+ ensureImport(
+ ATOMIC_WAIT_I32, {Type::i32, Type::i32, Type::i32, Type::i32}, Type::i32);
+ ensureImport(
+ ATOMIC_RMW_I64,
+ {Type::i32, Type::i32, Type::i32, Type::i32, Type::i32, Type::i32},
+ Type::i32);
+ ensureImport(GET_STASHED_BITS, {}, Type::i32);
}
-inline bool isScratchMemoryHelper(cashew::IString name) {
+inline bool isHelper(cashew::IString name) {
return name == SCRATCH_LOAD_I32 || name == SCRATCH_STORE_I32 ||
name == SCRATCH_LOAD_I64 || name == SCRATCH_STORE_I64 ||
name == SCRATCH_LOAD_F32 || name == SCRATCH_STORE_F32 ||
- name == SCRATCH_LOAD_F64 || name == SCRATCH_STORE_F64;
+ name == SCRATCH_LOAD_F64 || name == SCRATCH_STORE_F64 ||
+ name == ATOMIC_WAIT_I32 || name == MEMORY_INIT ||
+ name == MEMORY_FILL || name == MEMORY_COPY || name == DATA_DROP ||
+ name == ATOMIC_RMW_I64 || name == GET_STASHED_BITS;
}
} // namespace wasm2js