diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 6 | ||||
-rw-r--r-- | src/binaryen-c.h | 5 | ||||
-rw-r--r-- | src/ir/utils.h | 88 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 3 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 3 | ||||
-rw-r--r-- | src/wasm2js.h | 1 |
6 files changed, 1 insertions, 105 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index a278f7778..4294d56ea 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -5496,12 +5496,6 @@ void BinaryenModuleRunPasses(BinaryenModuleRef module, passRunner.run(); } -void BinaryenModuleAutoDrop(BinaryenModuleRef module) { - auto* wasm = (Module*)module; - PassRunner runner(wasm, globalPassOptions); - AutoDrop().run(&runner, wasm); -} - static BinaryenBufferSizes writeModule(BinaryenModuleRef module, char* output, size_t outputSize, diff --git a/src/binaryen-c.h b/src/binaryen-c.h index d24b2bb56..8616571db 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -3045,11 +3045,6 @@ BINARYEN_API void BinaryenModuleRunPasses(BinaryenModuleRef module, const char** passes, BinaryenIndex numPasses); -// Auto-generate drop() operations where needed. This lets you generate code -// without worrying about where they are needed. (It is more efficient to do it -// yourself, but simpler to use autodrop). -BINARYEN_API void BinaryenModuleAutoDrop(BinaryenModuleRef module); - // Serialize a module into binary form. Uses the currently set global debugInfo // option. // @return how many bytes were written. This will be less than or equal to diff --git a/src/ir/utils.h b/src/ir/utils.h index 72aa701bb..8051cb1a3 100644 --- a/src/ir/utils.h +++ b/src/ir/utils.h @@ -181,94 +181,6 @@ struct ReFinalizeNode : public OverriddenVisitor<ReFinalizeNode> { } }; -// Adds drop() operations where necessary. This lets you not worry about adding -// drop when generating code. This also refinalizes before and after, as -// dropping can change types, and depends on types being cleaned up - no -// unnecessary block/if/loop types (see refinalize) -// TODO: optimize that, interleave them -struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop>> { - bool isFunctionParallel() override { return true; } - - std::unique_ptr<Pass> create() override { - return std::make_unique<AutoDrop>(); - } - - AutoDrop() { name = "autodrop"; } - - bool maybeDrop(Expression*& child) { - bool acted = false; - if (child->type.isConcrete()) { - expressionStack.push_back(child); - if (!ExpressionAnalyzer::isResultUsed(expressionStack, getFunction()) && - !ExpressionAnalyzer::isResultDropped(expressionStack)) { - child = Builder(*getModule()).makeDrop(child); - acted = true; - } - expressionStack.pop_back(); - } - return acted; - } - - void reFinalize() { ReFinalizeNode::updateStack(expressionStack); } - - void visitBlock(Block* curr) { - if (curr->list.size() == 0) { - return; - } - for (Index i = 0; i < curr->list.size() - 1; i++) { - auto* child = curr->list[i]; - if (child->type.isConcrete()) { - curr->list[i] = Builder(*getModule()).makeDrop(child); - } - } - if (maybeDrop(curr->list.back())) { - reFinalize(); - assert(curr->type == Type::none || curr->type == Type::unreachable); - } - } - - void visitIf(If* curr) { - bool acted = false; - if (maybeDrop(curr->ifTrue)) { - acted = true; - } - if (curr->ifFalse) { - if (maybeDrop(curr->ifFalse)) { - acted = true; - } - } - if (acted) { - reFinalize(); - assert(curr->type == Type::none); - } - } - - void visitTry(Try* curr) { - bool acted = false; - if (maybeDrop(curr->body)) { - acted = true; - } - for (auto* catchBody : curr->catchBodies) { - if (maybeDrop(catchBody)) { - acted = true; - } - } - if (acted) { - reFinalize(); - assert(curr->type == Type::none); - } - } - - void doWalkFunction(Function* curr) { - ReFinalize().walkFunctionInModule(curr, getModule()); - walk(curr->body); - if (curr->getResults() == Type::none && curr->body->type.isConcrete()) { - curr->body = Builder(*getModule()).makeDrop(curr->body); - } - ReFinalize().walkFunctionInModule(curr, getModule()); - } -}; - struct I64Utilities { static Expression* recreateI64(Builder& builder, Expression* low, Expression* high) { diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index a90b79d49..c8d8e31ba 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -2674,9 +2674,6 @@ function wrapModule(module, self = {}) { Module['_BinaryenFunctionRunPasses'](func, module, i32sToStack(passes.map(strToStack)), passes.length) ); }; - self['autoDrop'] = function() { - return Module['_BinaryenModuleAutoDrop'](module); - }; self['dispose'] = function() { Module['_BinaryenModuleDispose'](module); }; diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 516bb86e1..64c7fda02 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -720,8 +720,7 @@ void FunctionValidator::validateNormalBlockElements(Block* curr) { if (!shouldBeTrue( !curr->list[i]->type.isConcrete(), curr, - "non-final block elements returning a value must be drop()ed " - "(binaryen's autodrop option might help you)") && + "non-final block elements returning a value must be dropped") && !info.quiet) { getStream() << "(on index " << i << ":\n" << curr->list[i] << "\n), type: " << curr->list[i]->type diff --git a/src/wasm2js.h b/src/wasm2js.h index d965dcc0c..f81908948 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -361,7 +361,6 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { // First, do the lowering to a JS-friendly subset. { PassRunner runner(wasm, options); - runner.add(std::make_unique<AutoDrop>()); // TODO: only legalize if necessary - emscripten would already do so, and // likely other toolchains. but spec test suite needs that. runner.add("legalize-js-interface"); |