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
@@ -383,6 +392,12 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
383
392
1. Let |tableaddr| be |v|.\[[Table]].
384
393
1. Let |externtable| be the [=external value=][=external value|table=] |tableaddr|.
385
394
1. [=list/Append=] |externtable| to |imports|.
395
+
1. If |externtype| is of the form [=externtype/event=] |attribute| <var ignore>functype</var>,
396
+
1. Assert: |attribute| is [=eventtype/attribute/exception=].
397
+
1. If |v| does not [=implement=]{{Exception}}, throw a {{LinkError}} exception.
398
+
1. Let |tag| be |v|'s [=Exception/exception tag=].
399
+
1. Let |extern| be the [=external value=][=external value/event=] |tag|.
400
+
1. [=list/Append=] |extern| to |imports|.
386
401
1. Return |imports|.
387
402
388
403
Note: This algorithm only verifies the right kind of JavaScript values are passed.
@@ -411,11 +426,17 @@ The verification of WebAssembly type requirements is deferred to the
411
426
1. Let [=external value|mem=] |memaddr| be |externval|.
412
427
1. Let |memory| be [=create a memory object|a new Memory object=] created from |memaddr|.
413
428
1. Let |value| be |memory|.
414
-
1. Otherwise, |externtype| is of the form [=table=]<var ignore>tabletype</var>,
429
+
1. If |externtype| is of the form [=table=]<var ignore>tabletype</var>,
415
430
1. Assert: |externval| is of the form [=external value|table=] |tableaddr|.
416
431
1. Let [=external value|table=] |tableaddr| be |externval|.
417
432
1. Let |table| be [=create a Table object|a new Table object=] created from |tableaddr|.
418
433
1. Let |value| be |table|.
434
+
1. If |externtype| is of the form [=externtype/event=] |attribute| <var ignore>functype</var>,
435
+
1. Assert: |attribute| is [=eventtype/attribute/exception=].
436
+
1. Assert: |externval| is of the form [=external value/event=] |eventaddr|.
437
+
1. Let [=external value/event=] |eventaddr| be |externval|.
438
+
1. Let |exception| be [=create an Exception object|a new Exception object=] created from |eventaddr|.
439
+
1. Let |value| be |exception|.
419
440
1. Let |status| be ! [=CreateDataProperty=](|exportsObject|, |name|, |value|).
420
441
1. Assert: |status| is true.
421
442
@@ -507,7 +528,8 @@ enum ImportExportKind {
507
528
"function",
508
529
"table",
509
530
"memory",
510
-
"global"
531
+
"global",
532
+
"event"
511
533
};
512
534
513
535
dictionary ModuleExportDescriptor {
@@ -537,6 +559,7 @@ interface Module {
537
559
* "table" if |type| is of the form [=table=] tabletype
538
560
* "memory" if |type| is of the form [=mem=] memtype
539
561
* "global" if |type| is of the form [=global=] globaltype
562
+
* "event" if |type| is of the form [=externtype/event=]<var ignore>event</var>
540
563
</div>
541
564
542
565
<div algorithm>
@@ -1017,14 +1040,8 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
1017
1040
1. Let (|store|, |ret|) be the result of [=func_invoke=](|store|, |funcaddr|, |argsSeq|).
1018
1041
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
1019
1042
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>.
1020
-
1. If |ret| is exception [=exnref=] |exception|,
1021
-
1. If |exception|'s [=exnref/exception tag=] is the [=JavaScript exception tag=], then
1022
-
1. Let [=ref.extern=] |externaddr| be |exception|'s [=exnref/payload=].
1023
-
1. Let |jsException| be the result of [=retrieving an extern value=] from |externaddr|.
1024
-
1. Throw |jsException|.
1025
-
1. Throw a {{RuntimeError}} exception.
1026
-
1027
-
Issue: Probably shouldn't be a {{RuntimeError}}.
1043
+
1. If |ret| is exception |exnaddr|,
1044
+
1. Throw [=ToJSValue=]([=ref.exn=] |exnaddr|).
1028
1045
1. Let |outArity| be the [=list/size=] of |ret|.
1029
1046
1. If |outArity| is 0, return undefined.
1030
1047
1. Otherwise, if |outArity| is 1, return [=ToJSValue=](|ret|[0]).
@@ -1069,7 +1086,7 @@ Note: Exported Functions do not have a \[[Construct]] method and thus it is not
1069
1086
1. Let |result| be the result of [=run a host function|running a host function=] from |func|, |functype|, and |arguments|.
1070
1087
1. Assert: |result|.\[[Type]] is <emu-const>throw</emu-const> or <emu-const>return</emu-const>.
1071
1088
1. If |result|.\[[Type]] is <emu-const>throw</emu-const>, then:
1072
-
1. Let |exception| be [=ToWebAssemblyValue=](|result|.\[[Value]], [=anyref=]).
1089
+
1. Let |exception| be [=ToWebAssemblyValue=](|result|.\[[Value]], [=exnref=]).
1073
1090
1. [=WebAssembly/Throw=] |exception| with the [=JavaScript exception tag=].
1074
1091
1. Otherwise, return |result|.\[[Value]].
1075
1092
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
@@ -1088,6 +1105,11 @@ The algorithm <dfn>ToJSValue</dfn>(|w|) coerces a [=WebAssembly value=] to a Jav
1088
1105
1. If |w| is of the form [=ref.null=]<var ignore>t</var>, return null.
1089
1106
1. If |w| is of the form [=ref.func=] |funcaddr|, return the result of creating [=a new Exported Function=] from |funcaddr|.
1090
1107
1. If |w| is of the form [=ref.extern=] |externaddr|, return the result of [=retrieving an extern value=] from |externaddr|.
1108
+
1. If |w| is of the form [=ref.exn=] |exntag| |payload|, then
1109
+
1. If |exntag| is the [=JavaScript exception tag=], then
1110
+
1. Let « [=ref.extern=] |externaddr| » be |payload|.
1111
+
1. Return the result of [=retrieving an extern value=] from |externaddr|.
1112
+
1. Return a {{RuntimeException}} whose [=RuntimeException/internal exception=] is |exnaddr|.
1091
1113
1092
1114
<!-- If the WebAssembly value is optional, then given `None`, return JavaScript value `undefined`. -->
1093
1115
@@ -1115,6 +1137,15 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|) coerces a JavaScript va
1115
1137
1. If |type| is [=f64=],
1116
1138
1. Let |f64| be ? [=ToNumber=](|v|).
1117
1139
1. Return [=f64.const=] |f64|.
1140
+
1. If |type| is [=exnref=],
1141
+
1. If |v| [=implements=]{{RuntimeException}},
1142
+
1. Let |exnaddr| be |v|'s [=RuntimeException/internal exception=].
1143
+
1. Otherwise,
1144
+
1. Let |payload| be [=ToWebAssemblyValue=](|v|, [=anyref=]).
1145
+
1. Let |exnaddr| be a new [=event address=] referencing |payload| and the [=JavaScript exception tag=].
1146
+
1. Return [=ref.exn=] |exnaddr|.
1147
+
1148
+
Note: There is no way to compare [=exnref=] values by reference.
1118
1149
1. If |type| is [=funcref=],
1119
1150
1. If |v| is null,
1120
1151
1. Return [=ref.null=][=funcref=].
@@ -1138,22 +1169,85 @@ The algorithm <dfn>ToWebAssemblyValue</dfn>(|v|, |type|) coerces a JavaScript va
1138
1169
1139
1170
<h3 id="exceptions">Exceptions</h3>
1140
1171
1141
-
A new type <dfn>exnref</dfn>is introduced for references to exceptions.
1142
-
Values of this type have an <dfn for=exnref>exception tag</dfn> and a <dfn for=exnref>payload</dfn>
1172
+
Values of the [=exnref=]type have an <dfn for=exnref>exception tag</dfn>and a
1173
+
<dfn for=exnref>payload</dfn>
1143
1174
(whose type is dependent on the value of the [=exnref/exception tag=]).
1144
1175
The concrete representation of values of this type is undefined.
0 commit comments