diff --git a/document/js-api/index.bs b/document/js-api/index.bs index eeb9ab38..fd3c5ac6 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -619,6 +619,7 @@ In addition, the interface object for {{Module}} must have as its \[[Prototype]] 1. If |module| is [=error=], throw a {{CompileError}} exception. 1. Set **this**.\[[Module]] to |module|. 1. Set **this**.\[[Bytes]] to |stableBytes|. + 1. Set **this**.\[[ModuleRecord]] to null. Note: Some implementations enforce a size limitation on |bytes|. Use of this API is discouraged, in favor of asynchronous APIs. @@ -1381,21 +1382,18 @@ Note: While this specification is not yet merged into the main Wasm specificatio WebAssembly Module Records are a subclass of [=Cyclic Module Record=] which contain WebAssembly code.
-To parse a WebAssembly module given a byte sequence |bytes|, a Realm |realm| and object |hostDefined|, perform the following steps. +To create a WebAssembly Module Record given a WebAssembly module object |moduleObject|, a Realm |realm| and object |hostDefined|, perform the following steps. -1. Let |stableBytes| be a [=get a copy of the buffer source|copy of the bytes held by the buffer=] |bytes|. -1. [=Compile a WebAssembly module|Compile the WebAssembly module=] |stableBytes| and store the result as |module|. -1. If |module| is [=error=], throw a {{CompileError}} exception. -1. [=Construct a WebAssembly module object=] from |module| and |bytes|, and let |module| be the result. +1. Assert: |moduleObject|.\[[ModuleRecord]] is null. 1. Let |requestedModules| be a set. -1. For each (|moduleName|, name, type) in [=module_imports=](|module|.\[[Module]]), +1. For each (|moduleName|, name, type) in [=module_imports=](|moduleObject|.\[[Module]]), 1. [=set/Append=] |moduleName| to |requestedModules|. 1. Let |moduleRecord| be { \[[Realm]]: |realm|, \[[Environment]]: ~empty~, \[[Namespace]]: ~empty~, - \[[ModuleSource]]: |module|, + \[[ModuleSource]]: |moduleObject|, \[[HostDefined]]: |hostDefined|, \[[Status]]: "new", @@ -1411,10 +1409,10 @@ To parse a WebAssembly module given a byte sequence |by \[[AsyncParentModules]]: « », \[[PendingAsyncDependencies]]: ~empty~, }. -1. Set |module|.\[[ModuleRecord]] to |moduleRecord|. +1. Set |moduleObject|.\[[ModuleRecord]] to |moduleRecord|. 1. Return |moduleRecord|. -Note: From HTML, it's not observable when [=parse a WebAssembly module=] begins, so any work perfomed in compilation may be performed off-thread. +Note: From HTML, it's not observable when [=create a WebAssembly Module Record=] begins, so any work perfomed in compilation may be performed off-thread.
@@ -1447,6 +1445,17 @@ WebAssembly Module Records have the following methods:
+
+ +

ModuleSourcesEqual ( |otherRecord| ) Concrete Method

+1. If |otherRecord| is not a WebAssemly Module Record, return false. +1. Let |record| be this WebAssembly Module Record. +1. Let |module| be |record|.\[[ModuleSource]]. +1. Let |otherModule| be |otherRecord|.\[[ModuleSource]]. +1. Return true if |module|.\[[Bytes]] is equal to |otherModule|.\[[Bytes]], and false otherwise. + +
+

GetModuleSourceKind ( ) Concrete Method

diff --git a/document/web-api/index.bs b/document/web-api/index.bs index c086c432..fe5f31f6 100644 --- a/document/web-api/index.bs +++ b/document/web-api/index.bs @@ -60,7 +60,12 @@ urlPrefix: https://webassembly.github.io/spec/js-api/; spec: WASMJS text: asynchronously compile a webassembly module; url: #asynchronously-compile-a-webassembly-module text: instantiate a promise of a module; url: #instantiate-a-promise-of-a-module text: Exported Function; url: #exported-function -url:https://html.spec.whatwg.org/#cors-same-origin;text:CORS-same-origin;type:dfn;spec:HTML +urlPrefix: https://html.spec.whatwg.org/; spec: HTML; type: dfn + text: rooted source; url: #concept-script-rooted-source + text: default script fetch options; url: #default-script-fetch-options + text: current settings object; url: #current-settings-object + text: CORS-same-origin; url: #cors-same-origin + text: create a WebAssembly Module Script; url: #creating-a-webassembly-module-script url:https://fetch.spec.whatwg.org/#concept-body-consume-body;text:consume body;type:dfn;spec:FETCH @@ -148,15 +153,49 @@ The [=serialization steps=], given |value|, |serialized|, and |forStorage|, are: 1. Set |serialized|.\[[AgentCluster]] to the [=current Realm=]'s corresponding [=agent cluster=]. + 1. Let |rooted| be false. + + 1. If |value|.\[[ModuleRecord]] is not null and |value|.\[[ModuleRecord]].\[[HostDefined]] is not empty: + + 1. Let |moduleScript| be |value|.\[[ModuleRecord]].\[[HostDefined]]. + + 1. Set |rooted| to |moduleScript|'s [=rooted source=] boolean. + + 1. If |rooted| is true then, + + 1. Set |serialized|.\[[Rooted]] to true. + + 1. Set |serialized|.\[[BaseURL]] to |moduleScript|'s [=base URL=]. + + 1. If |rooted| is false: + + 1. Set |serialized|.\[[Rooted]] to false. + + 1. Set |serialized|.\[[BaseURL]] to null. + The [=deserialization steps=], given |serialized|, |value|, and |targetRealm| are: + 1. If |targetRealm|'s corresponding [=agent cluster=] is not |serialized|.\[[AgentCluster]], then throw a "DataCloneError" {{DOMException}}. + 1. Let |bytes| be the [=sub-deserialization=] of |serialized|.\[[Bytes]]. 1. Set |value|.\[[Bytes]] to |bytes|. + + 1. [=Compile a WebAssembly module=] from |bytes| and set |value|.\[[Module]] to the result. - 1. If |targetRealm|'s corresponding [=agent cluster=] is not |serialized|.\[[AgentCluster]], then throw a "DataCloneError" {{DOMException}}. + 1. Assert: there was no compile error as this same module was previously compiled successfully. - 1. [=Compile a WebAssembly module=] from |bytes| and set |value|.\[[Module]] to the result. + 1. Let |rooted| be the [=sub-deserialization=] of |serialized|.\[[Rooted]]. + + 1. If |rooted| is true: + + 1. Let |baseURL| be the [=sub-deserialization=] of |serialized|.\[[BaseURL]]. + + 1. Let |settings| be the [=current settings object=]. + + 1. Let |fetchOptions| be the [=default script fetch options=]. + + 1. [=Create a WebAssembly module script=] given |value|.\[[Module]], |settings|, |baseURL|, |fetchOptions|, and true. Engines should attempt to share/reuse internal compiled code when performing a structured serialization, although in corner cases like CPU upgrade or browser