You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
text: create a namespace object; url: create-a-namespace-object
@@ -382,12 +391,18 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
382
391
1. Note: [=module_instantiate=] invoked below will check the imported {{Memory}}'s size against the importing module's requirements.
383
392
1. Let |externmem| be the [=external value=][=external value|𝗆𝖾𝗆=] |v|.\[[Memory]].
384
393
1. [=Append=] |externmem| to |imports|.
385
-
1. Otherwise, |externtype| is of the form [=𝗍𝖺𝖻𝗅𝖾=]<var ignore>tabletype</var>,
394
+
1. If |externtype| is of the form [=𝗍𝖺𝖻𝗅𝖾=]<var ignore>tabletype</var>,
386
395
1. If |v| is not a {{Table}} instance, throw a {{LinkError}} exception.
387
396
1. Note: The table's length, etc. is checked by [=module_instantiate=] invoked below.
388
397
1. Let |tableaddr| be |v|.\[[Table]]
389
398
1. Let |externtable| be the [=external value=][=external value|𝗍𝖺𝖻𝗅𝖾=] |tableaddr|.
390
399
1. [=Append=] |externtable| to |imports|.
400
+
1. If |externtype| is of the form [=externtype/event=] |attribute| <var ignore>functype</var>,
401
+
1. Assert: |attribute| is [=eventtype/attribute/exception=].
402
+
1. If |v| does not [=implement=]{{Exception}}, throw a {{LinkError}} exception.
403
+
1. Let |tag| be |v|'s [=Exception/exception tag=].
404
+
1. Let |extern| be the [=external value=][=external value/event=] |tag|.
405
+
1. [=Append=] |extern| to |imports|.
391
406
1. Return |imports|.
392
407
</div>
393
408
@@ -412,11 +427,17 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
412
427
1. Let [=external value|𝗆𝖾𝗆=] |memaddr| be |externval|.
413
428
1. Let |memory| be [=create a memory object|a new Memory object=] created from |memaddr|.
414
429
1. Let |value| be |memory|.
415
-
1. Otherwise, |externtype| is of the form [=𝗍𝖺𝖻𝗅𝖾=]<var ignore>tabletype</var>,
430
+
1. If |externtype| is of the form [=𝗍𝖺𝖻𝗅𝖾=]<var ignore>tabletype</var>,
416
431
1. Assert: |externval| is of the form [=external value|𝗍𝖺𝖻𝗅𝖾=] |tableaddr|.
417
432
1. Let [=external value|𝗍𝖺𝖻𝗅𝖾=] |tableaddr| be |externval|.
418
433
1. Let |table| be [=create a Table object|a new Table object=] created from |tableaddr|.
419
434
1. Let |value| be |table|.
435
+
1. If |externtype| is of the form [=externtype/event=] |attribute| <var ignore>functype</var>,
436
+
1. Assert: |attribute| is [=eventtype/attribute/exception=].
437
+
1. Assert: |externval| is of the form [=external value/event=] |eventaddr|.
438
+
1. Let [=external value/event=] |eventaddr| be |externval|.
439
+
1. Let |exception| be [=create an Exception object|a new Exception object=] created from |eventaddr|.
440
+
1. Let |value| be |exception|.
420
441
1. Let |status| be ! [=CreateDataProperty=](|exportsObject|, |name|, |value|).
421
442
1. Assert: |status| is true.
422
443
@@ -508,7 +529,8 @@ enum ImportExportKind {
508
529
"function",
509
530
"table",
510
531
"memory",
511
-
"global"
532
+
"global",
533
+
"event"
512
534
};
513
535
514
536
dictionary ModuleExportDescriptor {
@@ -537,6 +559,7 @@ interface Module {
537
559
* "table" if |type| is of the form [=𝗍𝖺𝖻𝗅𝖾=] tabletype
538
560
* "memory" if |type| is of the form [=𝗆𝖾𝗆=] memtype
539
561
* "global" if |type| is of the form [=𝗀𝗅𝗈𝖻𝖺𝗅=] globaltype
562
+
* "event" if |type| is of the form [=externtype/event=]<var ignore>event</var>
540
563
</div>
541
564
542
565
<div algorithm>
@@ -1003,14 +1026,8 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
1003
1026
1. Let (|store|, |ret|) be the result of [=func_invoke=](|store|, |funcaddr|, |argsSeq|).
1004
1027
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
1005
1028
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>.
1006
-
1. If |ret| is exception [=exnref=] |exception|,
1007
-
1. If |exception|'s [=exnref/exception tag=] is the [=JavaScript exception tag=], then
1008
-
1. Let [=ref.extern=] |externaddr| be |exception|'s [=exnref/payload=].
1009
-
1. Let |jsException| be the result of [=retrieving an extern value=] from |externaddr|.
1010
-
1. Throw |jsException|.
1011
-
1. Throw a {{RuntimeError}} exception.
1012
-
1013
-
Issue: Probably shouldn't be a {{RuntimeError}}.
1029
+
1. If |ret| is exception |exnaddr|,
1030
+
1. Throw [=ToJSValue=]([=ref.exn=] |exnaddr|).
1014
1031
1. If |ret| is empty, return undefined.
1015
1032
1. Otherwise, return [=ToJSValue=](|v|), where |v| is the singular element of |ret|.
1016
1033
</div>
@@ -1041,7 +1058,7 @@ Note: Exported Functions do not have a \[[Construct]] method and thus it is not
1041
1058
1. Let |result| be the result of [=run a host function|running a host function=] from |func|, |functype|, and |arguments|.
1042
1059
1. Assert: |result|.\[[Type]] is <emu-const>throw</emu-const> or <emu-const>return</emu-const>.
1043
1060
1. If |result|.\[[Type]] is <emu-const>throw</emu-const>, then:
1044
-
1. Let |exception| be [=ToWebAssemblyValue=](|result|.\[[Value]], [=anyref=]).
1061
+
1. Let |exception| be [=ToWebAssemblyValue=](|result|.\[[Value]], [=exnref=]).
1045
1062
1. [=WebAssembly/Throw=] |exception| with the [=JavaScript exception tag=].
1046
1063
1. Otherwise, return |result|.\[[Value]].
1047
1064
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
@@ -1060,6 +1077,11 @@ The algorithm <dfn>ToJSValue</dfn>(|w|) coerces a [=WebAssembly value=] to a Jav
1060
1077
1. If |w| is of the form [=ref.null=], return null.
1061
1078
1. If |w| is of the form [=ref.func=] |funcaddr|, return the result of creating [=a new Exported Function=] from |funcaddr|.
1062
1079
1. If |w| is of the form [=ref.host=] |hostaddr|, return the result of [=retrieving a host value=] from |hostaddr|.
1080
+
1. If |w| is of the form [=ref.exn=] |exntag| |payload|, then
1081
+
1. If |exntag| is the [=JavaScript exception tag=], then
1082
+
1. Let « [=ref.extern=] |externaddr| » be |payload|.
1083
+
1. Return the result of [=retrieving an extern value=] from |externaddr|.
1084
+
1. Return a {{RuntimeException}} whose [=RuntimeException/internal exception=] is |exnaddr|.
1063
1085
1064
1086
<!-- If the WebAssembly value is optional, then given `None`, return JavaScript value `undefined`. -->
1065
1087
@@ -1087,6 +1109,15 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|, |error|) coerces a Java
1087
1109
1. If |type| is [=𝖿𝟨𝟦=],
1088
1110
1. Let |f64| be ? [=ToNumber=](|v|).
1089
1111
1. Return [=𝖿𝟨𝟦.𝖼𝗈𝗇𝗌𝗍=] |f64|.
1112
+
1. If |type| is [=exnref=],
1113
+
1. If |v| [=implements=]{{RuntimeException}},
1114
+
1. Let |exnaddr| be |v|'s [=RuntimeException/internal exception=].
1115
+
1. Otherwise,
1116
+
1. Let |payload| be [=ToWebAssemblyValue=](|v|, [=anyref=]).
1117
+
1. Let |exnaddr| be a new [=event address=] referencing |payload| and the [=JavaScript exception tag=].
1118
+
1. Return [=ref.exn=] |exnaddr|.
1119
+
1120
+
Note: There is no way to compare [=exnref=] values by reference.
1090
1121
1. Assert: |type| is a reference type.
1091
1122
1. If |type| is [=anyref=],
1092
1123
1. Do nothing.
@@ -1116,22 +1147,85 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|, |error|) coerces a Java
1116
1147
1117
1148
<h3 id="exceptions">Exceptions</h3>
1118
1149
1119
-
A new type <dfn>exnref</dfn>is introduced for references to exceptions.
1120
-
Values of this type have an <dfn for=exnref>exception tag</dfn> and a <dfn for=exnref>payload</dfn>
1150
+
Values of the [=exnref=]type have an <dfn for=exnref>exception tag</dfn>and a
1151
+
<dfn for=exnref>payload</dfn>
1121
1152
(whose type is dependent on the value of the [=exnref/exception tag=]).
1122
1153
The concrete representation of values of this type is undefined.
0 commit comments