Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
587dafb
Add exceptional return to func_invoke in embedding doc
dschuff Mar 16, 2023
15a47cf
review comments
dschuff Mar 27, 2023
904a8fb
swap order of error/exception in func_invoke
dschuff Mar 30, 2023
fe0d00e
Expose the JavaScript Exception tag and allow importing it
dschuff Apr 7, 2023
ec302e1
review suggestions
dschuff Apr 11, 2023
fdf1b7c
Apply suggestions from code review
dschuff May 4, 2023
997754d
fix typo
dschuff Mar 15, 2024
a276636
Merge branch 'main' into js-tag-import
dschuff Mar 15, 2024
4799452
Merge branch 'main' into embedding-invoke
dschuff Mar 15, 2024
f57cdb8
add exception allocation
dschuff Mar 22, 2024
ccbee0f
udpate for exnref
dschuff Mar 22, 2024
4d08a58
apply all suggestions other than exn_read
dschuff Mar 29, 2024
74a92cb
add exn_read
dschuff Mar 29, 2024
b17459a
Update allocation, initialization, construction and call-exported-fn
dschuff Mar 29, 2024
fa07dea
fix linkage, syntax
dschuff Mar 29, 2024
ea5217b
fix typo
dschuff Mar 29, 2024
1c958c2
fix vars
dschuff Mar 29, 2024
46de060
Merge branch 'main' into exnref-js
dschuff Apr 2, 2024
5b8380a
address comments
dschuff Apr 4, 2024
4d03423
remove Tag parameter from getArg
dschuff Apr 4, 2024
d073cfe
remove 2 more spurious references to webassembly throw
dschuff Apr 4, 2024
b6a79f9
more properly allocate the JS exception tag, and wrap/unwrap JS excep…
dschuff Apr 5, 2024
51338d7
apply review comments
dschuff Apr 5, 2024
dfdd0b9
inline throwing into 'create a host function' and define in terms of …
dschuff Apr 5, 2024
a80e7b3
Merge branch 'exnref-js' into js-tag-import
dschuff Apr 5, 2024
bc04bb4
update for exnref
dschuff Apr 5, 2024
6c05eaa
remove leftover text
dschuff Apr 5, 2024
bece351
revert algorithm change
dschuff Apr 9, 2024
41b08cf
add getter
dschuff Apr 9, 2024
d3c3ab6
Merge branch 'main' into js-tag-import
dschuff Apr 11, 2024
8834860
Don't allow construction of a WebAssembly.Exception object with the J…
dschuff Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions document/js-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ namespace WebAssembly {

Promise<Instance> instantiate(
Module moduleObject, optional object importObject);

readonly attribute Tag JSTag;
Comment thread
dschuff marked this conversation as resolved.
};
</pre>

Expand Down Expand Up @@ -1063,6 +1065,9 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
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 exception |exntag| |payload| |opaqueData|, then
1. If |exntag| is the [=JavaScript exception tag=], then
1. Let « [=ref.extern=] |externaddr| » be |payload|
1. Throw the result of [=retrieving an extern value=] from |externaddr|.
1. If |opaqueData| is not [=ref.null=] [=externref=],
1. Let « [=ref.extern=] |externaddr| » be |opaqueData|.
1. Throw the result of [=retrieving an extern value=] from |externaddr|.
Expand Down Expand Up @@ -1126,7 +1131,7 @@ Note: Exported Functions do not have a \[[Construct]] method and thus it is not
1. Let |payload| be |v|.\[[Payload]].
1. Otherwise,
1. Let |type| be the [=JavaScript exception tag=].
1. Let |payload| be « ».
1. Let |payload| be « [=ToWebAssemblyValue=](|v|, [=externref=]) ».
1. Let |opaqueData| be [=ToWebAssemblyValue=](|v|, [=externref=])
1. [=WebAssembly/Throw=] with |type|, |payload| and |opaqueData|.
1. Otherwise, return |result|.\[[Value]].
Expand Down Expand Up @@ -1383,10 +1388,14 @@ The <dfn attribute for="Exception">stack</dfn> getter steps are:
<h4 id="js-exceptions">JavaScript exceptions</h4>

The <dfn>JavaScript exception tag</dfn> is a [=tag address=] reserved by this
specification to distinguish exceptions originating from JavaScript.
specification to distinguish exceptions originating from JavaScript. It is exposed
to JavaScript code via {{WebAssembly}}.{{JSTag}} a global pre-initailized (TODO: what's ths spec-y way to say this?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to JavaScript code via {{WebAssembly}}.{{JSTag}} a global pre-initailized (TODO: what's ths spec-y way to say this?)
to JavaScript code via {{WebAssembly}}.{{JSTag}} a global pre-initialized (TODO: what's ths spec-y way to say this?)

Not sure about more spec-y way to say this though.

Tag object [=create a Tag object|created=] from the JavaScript exception tag address.


For any [=associated store=] |store|, the result of
[=tag_parameters=](|store|, [=JavaScript exception tag=]) must be « ».
[=tag_parameters=](|store|, [=JavaScript exception tag=]) must be « [=externref=] ».

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we should be doing (as the "spec-y" thing, and in order to preerve abstraction boundaries) is to invoke tag_alloc from the core spec's embedding interface to create that tag, with the respective tag type. That could happen lazily, i.e., the JS spec does the allocation the first time the tag address is needed and then memoizes it.

Btw, I think the embedding spec should also provide a tag_type function, analogous to the other *_type functions.


<div algorithm>

Expand Down