From 0ee15961e43e0282b014e4328458e065b6976ba7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 23 Aug 2022 12:39:33 -0700 Subject: Fix multi-memory + C API for MemoryGrow and MemorySize (#4953) Those instructions need to know if the memory is 64-bit or not. We looked that up on the module globally, which is convenient, but in the C API this was actually a breaking change, it turns out. To keep things working, provide that information when creating a MemoryGrow or MemorySize, as another parameter in the C API. In the C++ API (wasm-builder), support both modes, and default to the automatic lookup. We already require a bunch of other explicit info when creating expressions, like making a Call requires the return type (we don't look it up globally), and even a LocalGet requires the local type (we don't look it up on the function), so this is consistent with those. Fixes #4946 --- src/js/binaryen.js-post.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/js') diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 53930e16c..c684553a5 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -687,11 +687,12 @@ function wrapModule(module, self = {}) { } self['memory'] = { - 'size'(name) { - return Module['_BinaryenMemorySize'](module, strToStack(name)); + // memory64 defaults to undefined/false. + 'size'(name, memory64) { + return Module['_BinaryenMemorySize'](module, strToStack(name), memory64); }, - 'grow'(value, name) { - return Module['_BinaryenMemoryGrow'](module, value, strToStack(name)); + 'grow'(value, name, memory64) { + return Module['_BinaryenMemoryGrow'](module, value, strToStack(name), memory64); }, 'init'(segment, dest, offset, size, name) { return Module['_BinaryenMemoryInit'](module, segment, dest, offset, size, strToStack(name)); -- cgit v1.2.3