Skip to content

Commit

Permalink
[js-api] Add support for exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Aug 21, 2019
1 parent e7196b7 commit 1fe9cff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,9 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
1. Let (|store|, |ret|) be the result of [=func_invoke=](|store|, |funcaddr|, |argsSeq|).
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
1. If |ret| is [=error=], throw an exception. This exception should be a WebAssembly {{RuntimeError}} exception, unless otherwise indicated by <a href="#errors">the WebAssembly error mapping</a>.
1. If |ret| is an exception,
1. If the exception is a value that was thrown by JavaScript code called by the Exported Function, throw the exception itself.
1. Else, throw a {{RuntimeError}} exception.
1. If |ret| is empty, return undefined.
1. Otherwise, return [=ToJSValue=](|v|), where |v| is the singular element of |ret|.
</div>
Expand Down Expand Up @@ -1006,7 +1009,9 @@ Note: Exported Functions do not have a \[[Construct]] method and thus it is not
1. Let |hostfunc| be a [=host function=] which performs the following steps when called:
1. Let |result| be the result of [=run a host function|running a host function=] from |func| and |functype|.
1. Assert: |result|.\[[Type]] is throw or return.
1. If |result|.\[[Type]] is [=throw=], then trigger a WebAssembly trap, and propagate |result|.\[[Value]] to the enclosing JavaScript.
1. If |result|.\[[Type]] is [=throw=], then:
1. Let |exception| be [=ToWebAssemblyValue=](|result|.\[[Value]], [=anyref=]).
1. Throw |exception|.
1. Otherwise, return |result|.\[[Value]].
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1. Let (|store|, |funcaddr|) be [=func_alloc=](|store|, |functype|, |hostfunc|).
Expand Down

0 comments on commit 1fe9cff

Please sign in to comment.