From beccdf70258cd99ea25f10af13103e14dc243ffa Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Fri, 15 Jan 2021 18:48:00 +0900 Subject: Basic EH instrucion support for the new spec (#3487) This updates `try`-`catch`-`catch_all` and `rethrow` instructions to match the new spec. `delegate` is not included. Now `Try` contains not a single `catchBody` expression but a vector of catch bodies and events. This updates most existing routines, optimizations, and tests modulo the interpreter and the CFG traversal. Because the interpreter has not been updated yet, the EH spec test is temporarily disabled in check.py. Also, because the CFG traversal for EH is not yet updated, several EH tests in `rse_all-features.wast`, which uses CFG traversal, are temporarily commented out. Also added a few more tests in existing EH test functions in test/passes. In the previous spec, `catch` was catching all exceptions so it was assumed that anything `try` body throws is caught by its `catch`, but now we can assume the same only if there is a `catch_all`. Newly added tests test cases when there is a `catch_all` and cases there are only `catch`es separately. --- test/reference-types.wast.fromBinary | 47 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'test/reference-types.wast.fromBinary') diff --git a/test/reference-types.wast.fromBinary b/test/reference-types.wast.fromBinary index a540048f9..50d403caf 100644 --- a/test/reference-types.wast.fromBinary +++ b/test/reference-types.wast.fromBinary @@ -8,6 +8,7 @@ (type $none_=>_externref (func (result externref))) (type $none_=>_exnref (func (result exnref))) (type $none_=>_none (func)) + (type $i32_=>_none (func (param i32))) (type $externref_=>_funcref (func (param externref) (result funcref))) (import "env" "import_global" (global $import_global externref)) (import "env" "import_func" (func $import_func (param externref) (result funcref))) @@ -22,6 +23,7 @@ (global $global_anyref3 (mut anyref) (ref.null func)) (global $global_anyref4 (mut anyref) (ref.func $foo)) (global $global_anyref5 (mut anyref) (ref.null exn)) + (event $event$0 (attr 0) (param i32)) (export "export_func" (func $import_func)) (export "export_global" (global $import_global)) (func $take_externref (param $0 externref) @@ -700,9 +702,9 @@ (do (local.get $local_funcref) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (ref.null extern) ) @@ -713,9 +715,9 @@ (do (ref.func $foo) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (ref.null func) ) @@ -726,8 +728,11 @@ (do (ref.null exn) ) - (catch - (pop exnref) + (catch $event$0 + (drop + (pop i32) + ) + (ref.null exn) ) ) ) @@ -736,9 +741,9 @@ (do (local.get $local_funcref) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (ref.func $foo) ) @@ -749,8 +754,11 @@ (do (local.get $local_funcref) ) - (catch - (pop exnref) + (catch $event$0 + (drop + (pop i32) + ) + (local.get $local_exnref) ) ) ) @@ -759,9 +767,9 @@ (do (ref.func $foo) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (local.get $local_funcref) ) @@ -772,8 +780,11 @@ (do (ref.func $foo) ) - (catch - (pop exnref) + (catch $event$0 + (drop + (pop i32) + ) + (local.get $local_exnref) ) ) ) @@ -782,9 +793,9 @@ (do (ref.null exn) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (local.get $local_funcref) ) @@ -795,9 +806,9 @@ (do (ref.null exn) ) - (catch + (catch $event$0 (drop - (pop exnref) + (pop i32) ) (ref.func $foo) ) -- cgit v1.2.3