From 3666cbc74d690f5a062bd45e7ac0df0d58c24636 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 29 Oct 2021 14:38:17 -0700 Subject: Effects: Differentiate mutable from immutable globals (#4286) Similar to what we do with structs, if a global is immutable then we know it cannot interact with calls. This changes the JS API for getSideEffects(). That was actually broken, as passing in the optional module param would just pass it along to the compiled C code, so it was coerced to 0 or 1, and not a pointer to a module. To fix that, this now does module.ptr to actually get the pointer, and this is now actually tested as without a module we cannot compute the effects of a global. This PR also makes the module param mandatory in the JS API, as again, without a module we can't compute global effects. (The module param has already been mandatory in the C++ API for some time.) --- src/js/binaryen.js-post.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/js/binaryen.js-post.js') diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 3f8b6545b..ee90aa1fc 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -3181,7 +3181,9 @@ Module['getExpressionInfo'] = function(expr) { // Gets the side effects of the specified expression Module['getSideEffects'] = function(expr, module) { - return Module['_BinaryenExpressionGetSideEffects'](expr, module); + assert(module); // guard against incorrect old API usage: a module must be + // provided here. + return Module['_BinaryenExpressionGetSideEffects'](expr, module['ptr']); }; Module['createType'] = function(types) { -- cgit v1.2.3