-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for new exception handling proposal
The exception handling proposal switched its design from an exnref-based approach with first-class exception reference values to a version with tagged catch blocks and implicit exception references. This commit adds support for this new semantics and revises tests to match. It does not yet remove exnref, as that can be done in a separate patch. Note: it does not add the `delegate` instruction in the new proposal yet, as it does not yet have an opcode assigned.
- Loading branch information
Showing
11 changed files
with
194 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,57 @@ | ||
;; --enable-exceptions --enable-multi-value | ||
(module | ||
(type (func (param i32 i64))) | ||
(type (func (param i32))) | ||
(event (type 0)) | ||
(func $check-br_on_exn-rethrow (param exnref) | ||
block $l (result i32 i64) | ||
local.get 0 | ||
;; exnref $e is on the stack at this point | ||
br_on_exn $l 0 ;; branch to $l with $e's arguments | ||
rethrow | ||
end | ||
drop | ||
drop | ||
) | ||
(event (type 1)) | ||
(func $check-throw | ||
i32.const 1 | ||
i64.const 2 | ||
throw 0 | ||
) | ||
(func $check-try-w-calls (result i32) | ||
try (result i32) | ||
(func $check-try-catch-rethrow | ||
try (result i32 i64) | ||
call $check-throw | ||
i32.const 0 | ||
catch | ||
call $check-br_on_exn-rethrow | ||
unreachable | ||
catch 0 | ||
;; the exception arguments are on the stack at this point | ||
catch 1 | ||
i64.const 2 | ||
catch_all | ||
rethrow 0 | ||
end | ||
drop | ||
drop | ||
) | ||
(func $check-unwind (local i32) | ||
try | ||
i32.const 1 | ||
local.set 0 | ||
call $check-throw | ||
unwind | ||
i32.const 0 | ||
local.set 0 | ||
end | ||
) | ||
) | ||
|
||
(assert_invalid | ||
(module | ||
(func try catch_all catch_all end)) | ||
;; we can't distinguish between `catch_all` and `else` in error cases | ||
"else found outside of an `if` block") | ||
|
||
(assert_invalid | ||
(module | ||
(func try catch_all catch 0 end)) | ||
"catch found outside of an `try` block") | ||
|
||
(assert_invalid | ||
(module | ||
(func try unwind i32.const 1 end)) | ||
"type mismatch: values remaining on stack at end of block") | ||
|
||
(assert_invalid | ||
(module | ||
(func block try catch_all rethrow 1 end end)) | ||
"rethrow target was not a `catch` block") |
Oops, something went wrong.