Skip to content

Commit fcbb8c8

Browse files
author
Guy Bedford
authored
layering: HostGetModuleSourceName host hook replacing internal slot (#83)
1 parent 44870b3 commit fcbb8c8

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

document/js-api/index.bs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Date: now
1717

1818
<pre class='biblio'>
1919
{
20-
"TLA": {
21-
"href": "https://tc39.github.io/proposal-top-level-await/",
20+
"SOURCEPHASEIMPORTS": {
21+
"href": "https://tc39.es/proposal-source-phase-imports/",
2222
"title": "Top-Level Await"
2323
},
2424
"WEBASSEMBLY": {
@@ -61,6 +61,12 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT
6161
text: GetImportedModule; url: url-GetImportedModule
6262
text: NewModuleEnvironment; url: sec-newmoduleenvironment
6363
text: OrdinaryObjectCreate; url: sec-ordinaryobjectcreate
64+
urlPrefix: https://tc39.github.io/proposal-source-phase-imports/; spec: SOURCEPHASEIMPORTS
65+
type: dfn
66+
text: %AbstractModuleSource%; url: sec-%abstractmodulesource%-constructor
67+
text: %AbstractModuleSource%.prototype; url: sec-properties-of-the-%abstractmodulesource%-prototype-object
68+
type: abstract-op
69+
text: HostGetModuleSourceName; url: sec-HostGetModuleSourceName
6470
urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: dfn
6571
url: valid/modules.html#valid-module
6672
text: valid
@@ -303,15 +309,13 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
303309

304310
* \[[Module]] : a WebAssembly [=/module=]
305311
* \[[Bytes]] : the source bytes of \[[Module]].
306-
* \[[ModuleSourceClassName]] : the string "WebAssembly.Module"
307312

308313
<div algorithm>
309314
To <dfn>construct a WebAssembly module object</dfn> from a module |module| and source bytes |bytes|, perform the following steps:
310315

311316
1. Let |moduleObject| be a new {{Module}} object.
312317
1. Set |moduleObject|.\[[Module]] to |module|.
313318
1. Set |moduleObject|.\[[Bytes]] to |bytes|.
314-
1. Set |moduleObject|.\[[ModuleSourceClassName]] to "WebAssembly.Module".
315319
1. Return |moduleObject|.
316320
</div>
317321

@@ -520,8 +524,8 @@ interface Module {
520524
};
521525
</pre>
522526

523-
Per ECMA-262 requirements for source phase import integration, the interface object for {{Module}} must have as its \[[Prototype]] be %AbstractModuleSource%, created as if by ObjectCreate(%AbstractModuleSource%), instead of %ObjectPrototype%.
524-
In addition, the interface prototype object for {{Module}} must have as its \[[Prototype]] be %AbstractModuleSource.prototype%, created as if by ObjectCreate(%AbstractModuleSource.prototype%), instead of %ObjectPrototype%.
527+
Per ECMA-262 requirements for Source Phase Imports ([[!SOURCEPHASEIMPORTS]]) integration, the interface prototype object for {{Module}} must have as its \[[Prototype]] set to [=%AbstractModuleSource%.prototype=], as if created by [$OrdinaryObjectCreate$]([=%AbstractModuleSource%.prototype=]), instead of [=%ObjectPrototype%=].
528+
In addition, the interface object for {{Module}} should have as its \[[Prototype]] set to [=%AbstractModuleSource%=], as if created by [$OrdinaryObjectCreate$]([=%AbstractModuleSource%=]), instead of [=%ObjectPrototype%=].
525529

526530
<div algorithm>
527531
The <dfn>string value of the extern type</dfn> |type| is
@@ -1325,11 +1329,9 @@ This document defines a host environment for WebAssembly. It enables a WebAssemb
13251329

13261330
<h2 id="esm-integration">Integration with ECMAScript modules</h2>
13271331

1328-
Note: It is possible to implement the Wasm-ESM integration in two stages. In the first stage only source phase imports of Wasm are supported (`import source fibModule from "./fib.wasm"`). In the second stage, evaluation phase imports would be supported too (`import { fib } from "./fib.wasm"`). If initially implementing just source phase imports, the `GetExportedNames`, `ResolveExport`, `InitializeEnvironment`, and `ExecuteModule` abstract operations can be implemented as abstract operations unconditionally throwing a `SyntaxError` exception. In this case, module fetch and CSP integration is still required to be implemented as specified in this proposal. Implementers are encouraged to ship both stages at once, but it is deemed OK for implementers to initially ship the first stage and then quickly follow up with the second stage, if this aids "time to ship" in implementations.
1329-
1330-
WebAssembly modules can be used in a module graph with ECMAScript modules.
1332+
WebAssembly modules can be used in a module graph with ECMAScript modules and Source Phase Imports.
13311333

1332-
Because WebAssembly module instantiation is asynchronous, these semantics are built on the top-level await TC39 JavaScript proposal. [[!TLA]]
1334+
Note: It is possible to implement the Wasm-ESM integration in two stages. In the first stage only source phase imports of Wasm are supported (`import source fibModule from "./fib.wasm"`). In the second stage, evaluation phase imports would be supported too (`import { fib } from "./fib.wasm"`). If initially implementing just source phase imports, the `GetExportedNames`, `ResolveExport`, `InitializeEnvironment`, and `ExecuteModule` abstract operations can be implemented as abstract operations unconditionally throwing a `SyntaxError` exception. In this case, module fetch and CSP integration is still required to be implemented as specified in this proposal. Implementers are encouraged to ship both stages at once, but it is deemed OK for implementers to initially ship the first stage and then quickly follow up with the second stage, if this aids "time to ship" in implementations.
13331335

13341336
<dfn export>WebAssembly Module Record</dfn>s are a subclass of [=Cyclic Module Record=] which contain WebAssembly code. WebAssembly Module Records have one additional internal slot:
13351337
* \[[WebAssemblyModule]] : a WebAssembly {{Module}} object
@@ -1446,4 +1448,8 @@ WebAssembly Module Records have the following methods:
14461448

14471449
</div>
14481450

1451+
<h3 id="hostgetmodulesourcename">HostGetModuleSourceName</h3>
1452+
1453+
Hosts should implement [$HostGetModuleSourceName$] such that whenever a WebAssembly {{Module}} object is provided with a \[[Module]] internal slot, the string "<code data-x="">WebAssembly.Module</code>" is always returned.
1454+
14491455
Note: See corresponding modifications to HTML in <a href="https://github.com/whatwg/html/pull/4372">PR #4372</a>.

0 commit comments

Comments
 (0)