diff options
author | Sam Clegg <sbc@chromium.org> | 2023-01-12 22:38:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-12 22:38:39 -0800 |
commit | 400fa0f5210a68a610db878a39237be1c6591099 (patch) | |
tree | 8bd3a24b69a908edc4d943af47bbc328e3d998c7 /test/wasm2c/add.txt | |
parent | ce775b0b55a29665956b021074d9eec9d2fa870a (diff) | |
download | wabt-400fa0f5210a68a610db878a39237be1c6591099.tar.gz wabt-400fa0f5210a68a610db878a39237be1c6591099.tar.bz2 wabt-400fa0f5210a68a610db878a39237be1c6591099.zip |
wasm2c: Initial implementation of memory64 (#2086)
Note, there are still some issues here that needs to be resolved,
mostly about memory sandboxing (bounds checking).
Since this is still experimental I've also added a `--experimental` flag
to wasm2c that is required in addition to passing `--enable-memory64`.
Diffstat (limited to 'test/wasm2c/add.txt')
-rw-r--r-- | test/wasm2c/add.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/wasm2c/add.txt b/test/wasm2c/add.txt index ec0d2b49..6f005f6d 100644 --- a/test/wasm2c/add.txt +++ b/test/wasm2c/add.txt @@ -84,9 +84,20 @@ u32 Z_testZ_add(Z_test_instance_t*, u32, u32); TRAP(CALL_INDIRECT), \ ((t)table.data[x].func)(__VA_ARGS__)) +#ifdef SUPPORT_MEMORY64 +#define RANGE_CHECK(mem, offset, len) \ + do { \ + uint64_t res; \ + if (__builtin_add_overflow(offset, len, &res)) \ + TRAP(OOB); \ + if (UNLIKELY(res > mem->size)) \ + TRAP(OOB); \ + } while (0); +#else #define RANGE_CHECK(mem, offset, len) \ if (UNLIKELY(offset + (uint64_t)len > mem->size)) \ TRAP(OOB); +#endif #if WASM_RT_MEMCHECK_SIGNAL_HANDLER #define MEMCHECK(mem, a, t) |