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
text: global address; url: exec/runtime.html#syntax-globaladdr
130
145
text: tag address; url: exec/runtime.html#syntax-tagaddr
@@ -226,7 +241,14 @@ emu-const {
226
241
}
227
242
</style>
228
243
229
-
This API provides a way to access WebAssembly [[WEBASSEMBLY]] through a bridge to explicitly construct modules from JavaScript [[ECMASCRIPT]].
244
+
<h2 id="intro">Introduction</h2>
245
+
246
+
By design, the [=scope=] of the WebAssembly core specification [[WEBASSEMBLY]] does not include a description of how WebAssembly programs interact with their surrounding execution environment.
247
+
Instead it defines an abstract [=embedding interface=] between WebAssembly and its environment, (called the *embedder*).
248
+
It is only through this interface that an embedder interacts with the semantics of WebAssembly, and the embedder implements the connection between its host environment and the embedding API.
249
+
This document describes the embedding of WebAssembly into JavaScript [[ECMASCRIPT]] environments, including how WebAssembly modules can be constructed and instantiated, how imported and exported functions are called, how data is exchanged, and how errors are handled.
250
+
When the JavaScript environment is itself embedded in a Web browser, the Web API spec [[WASMWEB]] describes additional behavior relevant to the Web environment.
251
+
230
252
231
253
<h2 id="sample">Sample API Usage</h2>
232
254
@@ -733,8 +755,8 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
733
755
The <dfn constructor for="Memory">Memory(|descriptor|)</dfn> constructor, when invoked, performs the following steps:
734
756
1. Let |initial| be |descriptor|["initial"].
735
757
1. If |descriptor|["maximum"][=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
736
-
1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception.
737
-
1. Let |memtype| be { min |initial|, max |maximum| }.
758
+
1. Let |memtype| be the [=memory type=] { <b>[=limits|min=]</b>|initial|, <b>[=limits|max=]</b> |maximum| }.
759
+
1. If |memtype| is not [=valid memtype|valid=], throw a {{RangeError}} exception.
738
760
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
739
761
1. Let (|store|, |memaddr|) be [=mem_alloc=](|store|, |memtype|). If allocation fails, throw a {{RangeError}} exception.
740
762
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
@@ -894,15 +916,17 @@ Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address
894
916
1. Throw a {{TypeError}} exception.
895
917
1. Let |initial| be |descriptor|["initial"].
896
918
1. If |descriptor|["maximum"][=map/exists=], let |maximum| be |descriptor|["maximum"]; otherwise, let |maximum| be empty.
897
-
1. If |maximum| is not empty and |maximum| < |initial|, throw a {{RangeError}} exception.
919
+
1. Let |type| be the [=table type=] { <b>[=limits|min=]</b> |initial|, <b>[=limits|max=]</b> |maximum| } |elementType|.
920
+
1. If |type| is not [=valid tabletype|valid=], throw a {{RangeError}} exception.
921
+
922
+
Note: Because tables may have up to 2<sup>32</sup> - 1 elements in validation, the checks for [=limits|min=] ≤ 2<sup>32</sup> - 1 and [=limits|max=] ≤ 2<sup>32</sup> - 1 in [=valid limits|limits validation=] cannot fail.
898
923
1. If |value| is missing,
899
924
1. Let |ref| be [=DefaultValue=](|elementType|).
900
925
1. Assert: |ref| is not [=error=].
901
926
1. Otherwise,
902
927
1. Let |ref| be [=?=][=ToWebAssemblyValue=](|value|, |elementType|).
903
-
1. Let |type| be the [=table type=] {[=table type|min=] |initial|, [=table type|max=] |maximum|} |elementType|.
904
928
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
905
-
1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). <!-- TODO(littledan): Report allocation failure https://github.com/WebAssembly/spec/issues/584 -->
929
+
1. Let (|store|, |tableaddr|) be [=table_alloc=](|store|, |type|, |ref|). If allocation fails, throw a {{RangeError}} exception.
906
930
1. Set the [=surrounding agent=]'s [=associated store=] to |store|.
907
931
1. [=initialize a table object|Initialize=] **this** from |tableaddr|.
908
932
</div>
@@ -1736,3 +1760,22 @@ In practice, an implementation may run out of resources for valid modules below
1736
1760
<p><em>This section is non-normative.</em></p>
1737
1761
1738
1762
This document defines a host environment for WebAssembly. It enables a WebAssembly instance to [=import=] JavaScript objects and functions from an [=read the imports|import object=], but otherwise provides no access to the embedding environment. Thus a WebAssembly instance is bound to the same constraints as JavaScript.
1763
+
1764
+
<h2 id="change-history">Change History</h2>
1765
+
1766
+
<p><em>This section is non-normative.</em></p>
1767
+
1768
+
<p>Since the original release 1.0 of the WebAssembly specification, a number of proposals for extensions have been integrated.
1769
+
The following sections provide an overview of what has changed.</p>
WebAssembly [=i64=] values can be passed to and from JavaScript (via imported or exported globals, table get or set operations, function return values or arguments) as [=BigInt=] objects.
JavaScript values can be passed to and from WebAssembly (via imported or exported globals, table set or get operations, and function arguments or return values) as [=externref=] values.
1781
+
Multiple tables can be exported and imported to and from JavaScript.
0 commit comments