From 60fa630ec1ce85ee3095391ff81e81d953ad38ab Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 5 Feb 2025 15:11:11 -0800 Subject: [PATCH 1/4] Note integration with string builtins using "wasm:" prefix --- document/js-api/index.bs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index e85da2d57..fbb920d9a 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -1400,9 +1400,12 @@ To parse a WebAssembly module given a byte sequence |by 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. Note: When integrating with the JS String Builtins proposal, |builtinSetNames| should be passed in the following step as « "js-string" » and |importedStringModule| as null. 1. [=Construct a WebAssembly module object=] from |module| and |bytes|, and let |module| be the result. 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=](|module|.\[[Module]]), + 1. Note: The following step only applies when integrating with the JS String Builtins proposal. + 1. If [=Find a builtin=] with (|moduleName|, |name|, |type|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=]. 1. [=set/Append=] |moduleName| to |requestedModules|. 1. Let |moduleRecord| be { @@ -1489,6 +1492,8 @@ WebAssembly Module Records have the following methods: 1. Let |module| be |record|.\[[ModuleSource]].\[[Module]]. 1. Let |imports| be « ». 1. [=list/iterate|For each=] (|importedModuleName|, |name|, |importtype|) in [=module_imports=](|module|), + 1. Note: The following step only applies when integrating with the JS String Builtins proposal. + 1. If [=Find a builtin=] with (|importedModuleName|, |name|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=]. 1. Let |importedModule| be [$GetImportedModule$](|record|, |importedModuleName|). 1. Let |resolution| be |importedModule|.ResolveExport(|name|). 1. Assert: |resolution| is a [=ResolvedBinding Record=], as validated during environment initialization. From 910997ad9094fd5a1cb59c800409bbf6cc18a939 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 30 Jun 2025 05:02:02 -0700 Subject: [PATCH 2/4] reserve wasm-js: on imports, hide wasm:, wasm-js: on exports --- document/js-api/index.bs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index fbb920d9a..b907c7eaa 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -1404,6 +1404,8 @@ To parse a WebAssembly module given a byte sequence |by 1. [=Construct a WebAssembly module object=] from |module| and |bytes|, and let |module| be the result. 1. Let |requestedModules| be a set. 1. For each (|moduleName|, |name|, |type|) in [=module_imports=](|module|.\[[Module]]), + 1. If |moduleName| starts with the prefix "wasm-js:", + 1. Throw a {{LinkError}} exception. 1. Note: The following step only applies when integrating with the JS String Builtins proposal. 1. If [=Find a builtin=] with (|moduleName|, |name|, |type|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=]. 1. [=set/Append=] |moduleName| to |requestedModules|. @@ -1442,7 +1444,8 @@ The export name list of a WebAssembly Module Record |record| is defin 1. Let |module| be |record|'s \[[ModuleSource]] internal slot. 1. Let |exports| be an empty [=list=]. 1. For each (|name|, type) in [=module_exports=](|module|.\[[Module]]) - 1. [=list/Append=] |name| to the end of |exports|. + 1. If |name| does not start with the prefix "wasm:" or "wasm-js:", + 1. [=list/Append=] |name| to the end of |exports|. 1. Return |exports|. From bf93c9bf22464af45c97f2cf505d57eb897a842b Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 30 Jun 2025 12:26:37 -0700 Subject: [PATCH 3/4] throw on exports, instead of hiding --- document/js-api/index.bs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index b907c7eaa..d4e3cdbf9 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -1409,6 +1409,9 @@ To parse a WebAssembly module given a byte sequence |by 1. Note: The following step only applies when integrating with the JS String Builtins proposal. 1. If [=Find a builtin=] with (|moduleName|, |name|, |type|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=]. 1. [=set/Append=] |moduleName| to |requestedModules|. +1. For each (|name|, type) in [=module_exports=](|module|.\[[Module]]) + 1. If |name| starts with the prefix "wasm:" or "wasm-js:", + 1. Throw a {{LinkError}} exception. 1. Let |moduleRecord| be { \[[Instance]]: ~empty~, @@ -1444,8 +1447,7 @@ The export name list of a WebAssembly Module Record |record| is defin 1. Let |module| be |record|'s \[[ModuleSource]] internal slot. 1. Let |exports| be an empty [=list=]. 1. For each (|name|, type) in [=module_exports=](|module|.\[[Module]]) - 1. If |name| does not start with the prefix "wasm:" or "wasm-js:", - 1. [=list/Append=] |name| to the end of |exports|. + 1. [=list/Append=] |name| to the end of |exports|. 1. Return |exports|. From cf64b4476b948cf2fa2fdc5b66c6f86df5531a1c Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Wed, 2 Jul 2025 07:43:36 -0700 Subject: [PATCH 4/4] also reserve wasm schemes on imported names --- document/js-api/index.bs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index d4e3cdbf9..316d22415 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -1406,6 +1406,8 @@ To parse a WebAssembly module given a byte sequence |by 1. For each (|moduleName|, |name|, |type|) in [=module_imports=](|module|.\[[Module]]), 1. If |moduleName| starts with the prefix "wasm-js:", 1. Throw a {{LinkError}} exception. + 1. If |name| starts with the prefix "wasm:" or "wasm-js:", + 1. Throw a {{LinkError}} exception. 1. Note: The following step only applies when integrating with the JS String Builtins proposal. 1. If [=Find a builtin=] with (|moduleName|, |name|, |type|) and builtins |module|.\[[BuiltinSets]] is not null, then [=iteration/continue=]. 1. [=set/Append=] |moduleName| to |requestedModules|.