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
Copy file name to clipboardExpand all lines: document/js-api/index.bs
+75-38Lines changed: 75 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -365,7 +365,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
365
365
</div>
366
366
367
367
<div algorithm>
368
-
To <dfn>create an instance object</dfn> from a WebAssembly module |module| and instance |instance|, perform the following steps:
368
+
To <dfn>create an exports object</dfn> from a WebAssembly module |module| and instance |instance|, perform the following steps:
369
369
1. Let |exportsObject| be ! [=ObjectCreate=](null).
370
370
1. For each pair (|name|, |externtype|) in [=module_exports=](|module|),
371
371
1. Let |externval| be [=instance_export=](|instance|, |name|).
@@ -395,7 +395,15 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
395
395
396
396
Note: the validity and uniqueness checks performed during [=WebAssembly module validation=] ensure that each property name is valid and no properties are defined twice.
1. Return a new {{Instance}} object whose internal \[[Instance]] slot is set to |instance| and the \[[Exports]] slot to |exportsObject|.
398
+
1. Return |exportsObject|.
399
+
</div>
400
+
401
+
<div algorithm>
402
+
To <dfn>initialize an instance object</dfn> |instanceObject| from a WebAssembly module |module| and instance |instance|, perform the following steps:
403
+
404
+
1. [=Create an exports object=] from |module| and |instance| and let |exportsObject| be the result.
405
+
1. Set |instanceObject|.\[[Instance]] to |instance|.
406
+
1. Set |instanceObject|.\[[Exports]] to |exportsObject|.
399
407
</div>
400
408
401
409
<div algorithm>
@@ -420,7 +428,8 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
420
428
1. [=Queue a task=] to perform the following steps:
421
429
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
422
430
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
423
-
1. [=Create an instance object=] from |module| and |instance|, and let the result be |instanceObject|.
431
+
1. Let |instanceObject| be a [=/new=]{{Instance}}.
432
+
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
424
433
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
425
434
1. [=Resolve=] |promise| with |instanceObject|.
426
435
1. Return |promise|.
@@ -431,7 +440,8 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
431
440
1. Let |module| be |moduleObject|.\[[Module]].
432
441
1. [=Read the imports=] of |module| with imports |importObject|, and let |imports| be the result.
433
442
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
434
-
1. [=Create an instance object=] from |module| and |instance|, and let the result be |instanceObject|.
443
+
1. Let |instanceObject| be a [=/new=]{{Instance}}.
444
+
1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
435
445
1. Return |instanceObject|.
436
446
</div>
437
447
@@ -542,7 +552,8 @@ interface Module {
542
552
1. Let |stableBytes| be a [=get a copy of the buffer source|copy of the bytes held by the buffer=] |bytes|.
543
553
1. [=Compile a WebAssembly module|Compile the WebAssembly module=] |stableBytes| and store the result as |module|.
544
554
1. If |module| is [=error=], throw a {{CompileError}} exception.
545
-
1. [=Construct a WebAssembly module object=] from |module| and |stableBytes|, and return the result.
555
+
1. Set **this**.\[[Module]] to |module|.
556
+
1. Set **this**.\[[Bytes]] to |stableBytes|.
546
557
</div>
547
558
548
559
<h3 id="instances">Instances</h3>
@@ -555,11 +566,15 @@ interface Instance {
555
566
</pre>
556
567
557
568
<div algorithm>
558
-
The <dfn constructor for="Instance">Instance(|module|, |importObject|)</dfn> constructor, when invoked, [=instantiate a WebAssembly module|instantiates the WebAssembly module=] |module| importing |importObject| and returns the result.
569
+
The <dfn constructor for="Instance">Instance(|module|, |importObject|)</dfn> constructor, when invoked, runs the following steps:
570
+
1. Let |module| be |module|.\[[Module]].
571
+
1. [=Read the imports=] of |module| with imports |importObject|, and let |imports| be the result.
572
+
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
573
+
1. [=initialize an instance object|Initialize=] **this** from |module| and |instance|.
559
574
</div>
560
575
561
576
<div algorithm>
562
-
The getter of the <dfn attribute for="Instance">exports</dfn> attribute of {{Instance}} returns the receiver's \[[Exports]] internal slot.
577
+
The getter of the <dfn attribute for="Instance">exports</dfn> attribute of {{Instance}} returns **this**.\[[Exports]].
563
578
</div>
564
579
565
580
<h3 id="memories">Memories</h3>
@@ -595,15 +610,24 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
595
610
1. Return |buffer|.
596
611
</div>
597
612
613
+
<div algorithm>
614
+
To <dfn>initialize a memory object</dfn> |memory| from a [=memory address=] |memaddr|, perform the following steps:
615
+
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
0 commit comments