diff options
author | Alon Zakai <azakai@google.com> | 2021-10-29 14:38:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 14:38:17 -0700 |
commit | 3666cbc74d690f5a062bd45e7ac0df0d58c24636 (patch) | |
tree | 8779610bb91f717226f6750a3d7755f46e97723b /src/js/binaryen.js-post.js | |
parent | 5b3cc376af95daba7da944842babe47b2b2197d2 (diff) | |
download | binaryen-3666cbc74d690f5a062bd45e7ac0df0d58c24636.tar.gz binaryen-3666cbc74d690f5a062bd45e7ac0df0d58c24636.tar.bz2 binaryen-3666cbc74d690f5a062bd45e7ac0df0d58c24636.zip |
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.)
Diffstat (limited to 'src/js/binaryen.js-post.js')
-rw-r--r-- | src/js/binaryen.js-post.js | 4 |
1 files changed, 3 insertions, 1 deletions
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) { |