From 1ad4e23342ef83b9210ce81bbf119047e08b6f3b Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Mon, 8 Nov 2021 22:44:29 -0800 Subject: [EH] Improve catch validation (#4315) This improves validation of `catch` bodies mostly by checking the validity of `pop`s. For every `catch` body: - Checks if its tag exists - If the tag's type is none: - Ensures there shouldn't be any `pop`s - If the tag's type is not none: - Checks if there's a single `pop` within the catch body - Checks if the tag type matches the `pop`'s type - Checks if the `pop`'s location is valid For every `catch_all` body: - Ensures there shuldn't be any `pop`s This uncovers several bugs related to `pop`s in existing tests, which this PR also fixes. --- test/exception-handling.wast.fromBinary | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'test/exception-handling.wast.fromBinary') diff --git a/test/exception-handling.wast.fromBinary b/test/exception-handling.wast.fromBinary index d37f48a23..9a89a0beb 100644 --- a/test/exception-handling.wast.fromBinary +++ b/test/exception-handling.wast.fromBinary @@ -3,10 +3,12 @@ (type $i32_=>_none (func (param i32))) (type $i64_=>_none (func (param i64))) (type $i32_i64_=>_none (func (param i32 i64))) + (type $anyref_=>_none (func (param anyref))) (tag $tag$0 (param i32)) (tag $tag$1 (param i64)) (tag $tag$2 (param i32 i64)) - (tag $tag$3 (param)) + (tag $tag$3 (param anyref)) + (tag $tag$4 (param)) (func $foo (nop) ) @@ -269,7 +271,7 @@ (do (nop) ) - (catch $tag$3 + (catch $tag$4 (nop) ) ) @@ -380,5 +382,31 @@ ) ) ) + (func $pop_test + (try $label$5 + (do + (nop) + ) + (catch $tag$0 + (throw $tag$0 + (if (result i32) + (pop i32) + (i32.const 0) + (i32.const 3) + ) + ) + ) + ) + (try $label$8 + (do + (nop) + ) + (catch $tag$3 + (drop + (pop anyref) + ) + ) + ) + ) ) -- cgit v1.2.3