diff options
author | Thomas Lively <tlively@google.com> | 2024-03-29 13:01:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-29 13:01:12 -0700 |
commit | b10d59d1d201506eba1aaba035e699fec849ea60 (patch) | |
tree | c4a57f8881bffc06a7d2cf74fc88c2d90f61224b /src | |
parent | 88eabaaddeeff6fb8295a2e35c8e29927df04724 (diff) | |
download | binaryen-b10d59d1d201506eba1aaba035e699fec849ea60.tar.gz binaryen-b10d59d1d201506eba1aaba035e699fec849ea60.tar.bz2 binaryen-b10d59d1d201506eba1aaba035e699fec849ea60.zip |
Remove the TRAVERSE_CALLS option in the ConstantExpressionRunner (#6449)
The implementation of calls with this option was incorrect because it cleared
the locals before evaluating the call arguments. The likely explanation for why
this was never noticed is that there are no users of this option, especially
since it is exposed in the C and JS APIs but not used internally.
Rather than try to fix the implementation, just remove the option.
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 4 | ||||
-rw-r--r-- | src/binaryen-c.h | 6 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 1 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 33 |
4 files changed, 0 insertions, 44 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 402dce553..a34876078 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -6322,10 +6322,6 @@ ExpressionRunnerFlags ExpressionRunnerFlagsPreserveSideeffects() { return CExpressionRunner::FlagValues::PRESERVE_SIDEEFFECTS; } -ExpressionRunnerFlags ExpressionRunnerFlagsTraverseCalls() { - return CExpressionRunner::FlagValues::TRAVERSE_CALLS; -} - ExpressionRunnerRef ExpressionRunnerCreate(BinaryenModuleRef module, ExpressionRunnerFlags flags, BinaryenIndex maxDepth, diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 42bd45915..bc63e963a 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -3495,12 +3495,6 @@ BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsDefault(); // so subsequent code keeps functioning. BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsPreserveSideeffects(); -// Traverse through function calls, attempting to compute their concrete value. -// Must not be used in function-parallel scenarios, where the called function -// might be concurrently modified, leading to undefined behavior. Traversing -// another function reuses all of this runner's flags. -BINARYEN_API ExpressionRunnerFlags ExpressionRunnerFlagsTraverseCalls(); - // Creates an ExpressionRunner instance BINARYEN_API ExpressionRunnerRef ExpressionRunnerCreate(BinaryenModuleRef module, diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 125bbf01e..1461420bb 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -638,7 +638,6 @@ function initializeConstants() { Module['ExpressionRunner']['Flags'] = { 'Default': Module['_ExpressionRunnerFlagsDefault'](), 'PreserveSideeffects': Module['_ExpressionRunnerFlagsPreserveSideeffects'](), - 'TraverseCalls': Module['_ExpressionRunnerFlagsTraverseCalls']() }; } diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 377eb9465..8da80afc9 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -2211,10 +2211,6 @@ public: // the expression if it also sets a local, which must be preserved in this // scenario so subsequent code keeps functioning. PRESERVE_SIDEEFFECTS = 1 << 0, - // Traverse through function calls, attempting to compute their concrete - // value. Must not be used in function-parallel scenarios, where the called - // function might be concurrently modified, leading to undefined behavior. - TRAVERSE_CALLS = 1 << 1 }; // Flags indicating special requirements, for example whether we are just @@ -2322,35 +2318,6 @@ public: Flow visitCall(Call* curr) { NOTE_ENTER("Call"); NOTE_NAME(curr->target); - // Traverse into functions using the same mode, which we can also do - // when replacing as long as the function does not have any side effects. - // Might yield something useful for simple functions like `clamp`, sometimes - // even if arguments are only partially constant or not constant at all. - if ((flags & FlagValues::TRAVERSE_CALLS) != 0 && this->module != nullptr) { - auto* func = this->module->getFunction(curr->target); - if (!func->imported()) { - if (func->getResults().isConcrete()) { - auto numOperands = curr->operands.size(); - assert(numOperands == func->getNumParams()); - auto prevLocalValues = localValues; - localValues.clear(); - for (Index i = 0; i < numOperands; ++i) { - auto argFlow = ExpressionRunner<SubType>::visit(curr->operands[i]); - if (!argFlow.breaking()) { - assert(argFlow.values.isConcrete()); - localValues[i] = argFlow.values; - } - } - auto retFlow = ExpressionRunner<SubType>::visit(func->body); - localValues = prevLocalValues; - if (retFlow.breakTo == RETURN_FLOW) { - return Flow(retFlow.values); - } else if (!retFlow.breaking()) { - return retFlow; - } - } - } - } return Flow(NONCONSTANT_FLOW); } Flow visitCallIndirect(CallIndirect* curr) { |