From af1edd95809508c7d2ded1a444a8f43b5f0a4ad4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 29 Sep 2016 18:18:03 -0700 Subject: [PATCH] validate drop --- src/wasm-validator.h | 7 +------ test/passes/vacuum.txt | 16 ++++++++-------- test/passes/vacuum.wast | 6 ++++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/wasm-validator.h b/src/wasm-validator.h index 3616313d3a2..3c580ce5155 100644 --- a/src/wasm-validator.h +++ b/src/wasm-validator.h @@ -303,12 +303,7 @@ struct WasmValidator : public PostWalker> } void visitDrop(Drop* curr) { - // TODO: assert on this, when tests pass - if (getenv("BINARYEN_WARN_DROP")) { - if (!(isConcreteWasmType(curr->value->type) || curr->value->type == unreachable)) { - std::cerr << "warning: bad drop " << curr << " in " << (getFunction() ? getFunction()->name : Name("?")) << '\n'; - } - } + shouldBeTrue(isConcreteWasmType(curr->value->type) || curr->value->type == unreachable, curr, "can only drop a valid value"); } void visitReturn(Return* curr) { diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index 2639dee5d2e..0c2feeb09fa 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -145,17 +145,17 @@ ) (func $if-drop (type $3) (result i32) (block $out - (drop - (if - (call $if-drop) + (if + (call $if-drop) + (drop (call $int) - (br $out) ) + (br $out) ) - (drop - (if - (call $if-drop) - (br $out) + (if + (call $if-drop) + (br $out) + (drop (call $int) ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index 9095a40f4fe..05a8611c5ae 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -302,13 +302,15 @@ (func $if-drop (result i32) (block $out (drop - (if (call $if-drop) + (if i32 + (call $if-drop) (call $int) (br $out) ) ) (drop - (if (call $if-drop) + (if i32 + (call $if-drop) (br $out) (call $int) )