From 3e70ac4d164d8363850b1863e766d1395b6dbe6f Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 30 Mar 2025 14:28:16 -0700 Subject: [PATCH 1/5] support separate instance lookup function --- document/js-api/index.bs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index ec224142..e86d9cae 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -80,6 +80,7 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT text: Cyclic Module Record; url: cyclic-module-record text: GetMethod; url: sec-getmethod text: ToBigInt64; url: #sec-tobigint64 + text: Module Namespace exotic object; url: #sec-module-namespace-exotic-objects type: abstract-op text: CreateDataPropertyOrThrow; url: sec-createdatapropertyorthrow text: CreateMethodProperty; url: sec-createmethodproperty @@ -318,6 +319,8 @@ namespace WebAssembly { Promise<Instance> instantiate( Module moduleObject, optional object importObject); + + Instance moduleInstance(ModuleNamespace namespace); }; @@ -534,6 +537,14 @@ The verification of WebAssembly type requirements is deferred to the 1. [=asynchronously instantiate a WebAssembly module|Asynchronously instantiate the WebAssembly module=] |moduleObject| importing |importObject|, and return the result. +
+ The moduleInstance(|namespace|) method, when invoked, performs the following steps: + 1. If |namespace| is not a [=is a Module Namespace exotic object=], [=throw=] a {{TypeError}} exception. + 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. + 1. Let |module| be |namespace|.\[[Module]]. + 1. Return |module|.\[[Instance]]. +
+ Note: A follow-on streaming API is documented in the WebAssembly Web API.

Modules

From 61e6abd4ed5eef178eba2a533a6d51a33e032bf3 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 30 Mar 2025 14:43:14 -0700 Subject: [PATCH 2/5] moduleInstance -> namespaceInstance --- document/js-api/index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index e86d9cae..da386a17 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -320,7 +320,7 @@ namespace WebAssembly { Promise<Instance> instantiate( Module moduleObject, optional object importObject); - Instance moduleInstance(ModuleNamespace namespace); + Instance namespaceInstance(ModuleNamespace namespace); }; @@ -538,7 +538,7 @@ The verification of WebAssembly type requirements is deferred to the
- The moduleInstance(|namespace|) method, when invoked, performs the following steps: + The namespaceInstance(|namespace|) method, when invoked, performs the following steps: 1. If |namespace| is not a [=is a Module Namespace exotic object=], [=throw=] a {{TypeError}} exception. 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. 1. Let |module| be |namespace|.\[[Module]]. From 09b4432fbc31f3cb0dba33f9bf5401a3aef37170 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 30 Mar 2025 14:50:35 -0700 Subject: [PATCH 3/5] fixup reference --- document/js-api/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index da386a17..f0e17ae5 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -539,7 +539,7 @@ The verification of WebAssembly type requirements is deferred to the
The namespaceInstance(|namespace|) method, when invoked, performs the following steps: - 1. If |namespace| is not a [=is a Module Namespace exotic object=], [=throw=] a {{TypeError}} exception. + 1. If |namespace| is not a [=Module Namespace exotic object=], [=throw=] a {{TypeError}} exception. 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. 1. Let |module| be |namespace|.\[[Module]]. 1. Return |module|.\[[Instance]]. From 8307913759a327cd01778510954120b7498c8e85 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 30 Mar 2025 15:03:25 -0700 Subject: [PATCH 4/5] move to Instance, assume IDL integration --- document/js-api/index.bs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index f0e17ae5..a45c891a 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -319,8 +319,6 @@ namespace WebAssembly { Promise<Instance> instantiate( Module moduleObject, optional object importObject); - - Instance namespaceInstance(ModuleNamespace namespace); }; @@ -537,14 +535,6 @@ The verification of WebAssembly type requirements is deferred to the 1. [=asynchronously instantiate a WebAssembly module|Asynchronously instantiate the WebAssembly module=] |moduleObject| importing |importObject|, and return the result.
-
- The namespaceInstance(|namespace|) method, when invoked, performs the following steps: - 1. If |namespace| is not a [=Module Namespace exotic object=], [=throw=] a {{TypeError}} exception. - 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. - 1. Let |module| be |namespace|.\[[Module]]. - 1. Return |module|.\[[Instance]]. -
- Note: A follow-on streaming API is documented in the WebAssembly Web API.

Modules

@@ -642,6 +632,7 @@ Note: Some implementations enforce a size limitation on |bytes|. Use of this API interface Instance { constructor(Module module, optional object importObject); readonly attribute object exports; + static Instance namespaceInstance(ModuleNamespace moduleNamespace); }; @@ -659,6 +650,14 @@ Note: The use of this synchronous API is discouraged, as some implementations so The getter of the exports attribute of {{Instance}} returns **this**.\[[Exports]].
+
+ The namespaceInstance(|moduleNamespace|) method, when invoked, performs the following steps: + 1. Assert: |namespace| is a [=Module Namespace exotic object=]. + 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. + 1. Let |module| be |namespace|.\[[Module]]. + 1. Return |module|.\[[Instance]]. +
+

Memories


From 87df70936cb8faa42320a5313c45419cf2f29677 Mon Sep 17 00:00:00 2001
From: Guy Bedford 
Date: Tue, 8 Apr 2025 09:33:44 -0700
Subject: [PATCH 5/5] Update document/js-api/index.bs

Co-authored-by: Andreas Rossberg 
---
 document/js-api/index.bs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/document/js-api/index.bs b/document/js-api/index.bs
index a45c891a..bcf302bd 100644
--- a/document/js-api/index.bs
+++ b/document/js-api/index.bs
@@ -651,7 +651,7 @@ Note: The use of this synchronous API is discouraged, as some implementations so
 
 
 
- The namespaceInstance(|moduleNamespace|) method, when invoked, performs the following steps: + The namespaceInstance(|namespace|) method, when invoked, performs the following steps: 1. Assert: |namespace| is a [=Module Namespace exotic object=]. 1. If |namespace|.\[[Module]] is not a [=WebAssembly Module Record=], [=throw=] a {{TypeError}} exception. 1. Let |module| be |namespace|.\[[Module]].