diff --git a/document/js-api/index.bs b/document/js-api/index.bs
index 2e03669ad9..ab4c3dce57 100644
--- a/document/js-api/index.bs
+++ b/document/js-api/index.bs
@@ -436,9 +436,9 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
* \[[ImportedStringModule]] : an optional module specifier string where any string constant can be imported from.
- To
construct a WebAssembly module object from a module |module|, source bytes |bytes|, enabled builtins |builtinSetNames|, and |importedStringModule|, perform the following steps:
+ To
construct a WebAssembly module object from a module |module|, source bytes |bytes|, enabled builtins |builtinSetNames|, and |importedStringModule|, in a [=realm=] |realm|, perform the following steps:
- 1. Let |moduleObject| be a [=/new=] {{Module}}.
+ 1. Let |moduleObject| be a [=/new=] {{Module}} in |realm|.
1. Set |moduleObject|.\[[Module]] to |module|.
1. Set |moduleObject|.\[[Bytes]] to |bytes|.
1. Set |moduleObject|.\[[BuiltinSets]] to |builtinSetNames|.
@@ -449,7 +449,8 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
To asynchronously compile a WebAssembly module from source bytes |bytes| and {{WebAssemblyCompileOptions}} |options| using optional [=task source=] |taskSource|, perform the following steps:
- 1. Let |promise| be [=a new promise=].
+ 1. Let |realm| be the [=current Realm=].
+ 1. Let |promise| be [=a new promise=] in |realm|.
1. Run the following steps [=in parallel=]:
1. [=compile a WebAssembly module|Compile the WebAssembly module=] |bytes| and store the result as |module|.
1. [=Queue a task=] on |taskSource|, if provided, to perform the following steps:
@@ -458,7 +459,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje
1. Let |importedStringModule| be |options|["importedStringConstants"].
1. If [=validate builtins and imported string for a WebAssembly module|validating builtins and imported strings=] for |module| with |builtinSetNames| and |importedStringModule| is false, [=reject=] |promise| with a {{CompileError}} exception.
1. Otherwise,
- 1. [=Construct a WebAssembly module object=] from |module|, |bytes|, |builtinSetNames|, |importedStringModule|, and let |moduleObject| be the result.
+ 1. [=Construct a WebAssembly module object=] from |module|, |bytes|, |builtinSetNames|, |importedStringModule| in |realm|, and let |moduleObject| be the result.
1. [=Resolve=] |promise| with |moduleObject|.
1. Return |promise|.
@@ -554,7 +555,7 @@ The verification of WebAssembly type requirements is deferred to the
- To create an exports object from a WebAssembly module |module| and instance |instance|, perform the following steps:
+ To create an exports object from a WebAssembly module |module| and instance |instance| in a [=realm=] |realm|, perform the following steps:
1. Let |exportsObject| be [$OrdinaryObjectCreate$](null).
1. [=list/iterate|For each=] (|name|, |externtype|) of [=module_exports=](|module|),
1. Let |externval| be [=instance_export=](|instance|, |name|).
@@ -562,27 +563,27 @@ The verification of WebAssembly type requirements is deferred to the
1. If |externtype| is of the form [=external-type/func=] functype,
1. Assert: |externval| is of the form [=external value/func=] |funcaddr|.
1. Let [=external value/func=] |funcaddr| be |externval|.
- 1. Let |func| be the result of creating [=a new Exported Function=] from |funcaddr|.
+ 1. Let |func| be the result of creating [=a new Exported Function=] from |funcaddr| in |realm|.
1. Let |value| be |func|.
1. If |externtype| is of the form [=external-type/global=] mut globaltype,
1. Assert: |externval| is of the form [=external value/global=] |globaladdr|.
1. Let [=external value/global=] |globaladdr| be |externval|.
- 1. Let |global| be [=create a global object|a new Global object=] created from |globaladdr|.
+ 1. Let |global| be [=create a global object|a new Global object=] created from |globaladdr| in |realm|.
1. Let |value| be |global|.
1. If |externtype| is of the form [=external-type/mem=] memtype,
1. Assert: |externval| is of the form [=external value/mem=] |memaddr|.
1. Let [=external value/mem=] |memaddr| be |externval|.
- 1. Let |memory| be [=create a memory object|a new Memory object=] created from |memaddr|.
+ 1. Let |memory| be [=create a memory object|a new Memory object=] created from |memaddr| in |realm|.
1. Let |value| be |memory|.
1. If |externtype| is of the form [=external-type/table=] tabletype,
1. Assert: |externval| is of the form [=external value/table=] |tableaddr|.
1. Let [=external value/table=] |tableaddr| be |externval|.
- 1. Let |table| be [=create a Table object|a new Table object=] created from |tableaddr|.
+ 1. Let |table| be [=create a Table object|a new Table object=] created from |tableaddr| in |realm|.
1. Let |value| be |table|.
1. If |externtype| is of the form [=external-type/tag=] functype,
1. Assert: |externval| is of the form [=external value/tag=] |tagaddr|.
1. Let [=external value/tag=] |tagaddr| be |externval|.
- 1. Let |tag| be [=create a Tag object|a new Tag object=] created from |tagaddr|.
+ 1. Let |tag| be [=create a Tag object|a new Tag object=] created from |tagaddr| in |realm|.
1. Let |value| be |tag|.
1. Let |status| be [=!=] [$CreateDataProperty$](|exportsObject|, |name|, |value|).
1. Assert: |status| is true.
@@ -593,9 +594,9 @@ The verification of WebAssembly type requirements is deferred to the
- To initialize an instance object |instanceObject| from a WebAssembly module |module| and instance |instance|, perform the following steps:
+ To initialize an instance object |instanceObject| from a WebAssembly module |module| and instance |instance| in a [=realm=] |realm|, perform the following steps:
- 1. [=Create an exports object=] from |module| and |instance| and let |exportsObject| be the result.
+ 1. [=Create an exports object=] from |module| and |instance| in |realm| and let |exportsObject| be the result.
1. Set |instanceObject|.\[[Instance]] to |instance|.
1. Set |instanceObject|.\[[Exports]] to |exportsObject|.
@@ -614,7 +615,8 @@ The verification of WebAssembly type requirements is deferred to the
To
asynchronously instantiate a WebAssembly module from a {{Module}} |moduleObject| and imports |importObject|, perform the following steps:
- 1. Let |promise| be [=a new promise=].
+ 1. Let |realm| be the [=current Realm=].
+ 1. Let |promise| be [=a new promise=] in |realm|.
1. Let |module| be |moduleObject|.\[[Module]].
1. Let |builtinSetNames| be |moduleObject|.\[[BuiltinSets]].
1. Let |importedStringModule| be |moduleObject|.\[[ImportedStringModule]].
@@ -625,8 +627,8 @@ The verification of WebAssembly type requirements is deferred to the
Note: Implementation-specific work may be performed here.
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
- 1. Let |instanceObject| be a [=/new=] {{Instance}}.
- 1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|.
+ 1. Let |instanceObject| be a [=/new=] {{Instance}} in |realm|.
+ 1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance| in |realm|.
If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps.
1. [=Resolve=] |promise| with |instanceObject|.
1. Return |promise|.
@@ -635,7 +637,7 @@ The verification of WebAssembly type requirements is deferred to the
@@ -792,7 +794,7 @@ interface Instance {
1. Let |module| be |moduleObject|.\[[Module]].
1. [=Read the imports=] of |module| with imports |importObject|, |builtinSetNames|, and |importedStringModule|, and let |imports| be the result.
1. [=Instantiate the core of a WebAssembly module=] |module| with |imports|, and let |instance| be the result.
- 1. [=initialize an instance object|Initialize=] **this** from |module| and |instance|.
+ 1. [=initialize an instance object|Initialize=] **this** from |module| and |instance| in the [=current Realm=].
Note: The use of this synchronous API is discouraged, as some implementations sometimes do long-running compilation work when instantiating.
@@ -862,12 +864,12 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
- To create a memory object from a [=memory address=] |memaddr|, perform the following steps:
+ To create a memory object from a [=memory address=] |memaddr| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Memory object cache=].
1. If |map|[|memaddr|] [=map/exists=],
1. Return |map|[|memaddr|].
- 1. Let |memory| be a [=/new=] {{Memory}}.
+ 1. Let |memory| be a [=/new=] {{Memory}} in |realm|.
1. [=initialize a memory object|Initialize=] |memory| from |memaddr|.
1. Return |memory|.
@@ -1027,11 +1029,11 @@ Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address
- To create a table object from a [=table address=] |tableaddr|, perform the following steps:
+ To create a table object from a [=table address=] |tableaddr| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Table object cache=].
1. If |map|[|tableaddr|] [=map/exists=],
1. Return |map|[|tableaddr|].
- 1. Let |table| be a [=/new=] {{Table}}.
+ 1. Let |table| be a [=/new=] {{Table}} in |realm|.
1. [=initialize a table object|Initialize=] |table| from |tableaddr|.
1. Return |table|.
@@ -1163,11 +1165,11 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
- To create a global object from a [=global address=] |globaladdr|, perform the following steps:
+ To create a global object from a [=global address=] |globaladdr| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Global object cache=].
1. If |map|[|globaladdr|] [=map/exists=],
1. Return |map|[|globaladdr|].
- 1. Let |global| be a [=/new=] {{Global}}.
+ 1. Let |global| be a [=/new=] {{Global}} in |realm|.
1. [=initialize a global object|Initialize=] |global| from |globaladdr|.
1. Return |global|.
@@ -1263,13 +1265,12 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
- To create a new Exported Function from a WebAssembly [=function address=] |funcaddr|, perform the following steps:
+ To create a new Exported Function from a WebAssembly [=function address=] |funcaddr| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Exported Function cache=].
1. If |map|[|funcaddr|] [=map/exists=],
1. Return |map|[|funcaddr|].
1. Let |steps| be "[=call an Exported Function|call the Exported Function=] |funcaddr| with arguments."
- 1. Let |realm| be the [=current Realm=].
1. Let |store| be the [=surrounding agent=]'s [=associated store=].
1. Let |functype| be [=func_type=](|store|, |funcaddr|).
1. Let [|paramTypes|] → [resultTypes] be |functype|.
@@ -1307,7 +1308,7 @@ This slot holds a [=function address=] relative to the [=surrounding agent=]'s [
1. If |tagaddr| is equal to |jsTagAddr|,
1. Throw [=ToJSValue=](|payload|[0]).
1. Otherwise,
- 1. Let |exception| be [=create an Exception object|a new Exception=] created from |exnaddr|.
+ 1. Let |exception| be [=create an Exception object|a new Exception=] created from |exnaddr| in the [=current Realm=].
1. Throw |exception|.
1. Let |outArity| be the [=list/size=] of |ret|.
1. If |outArity| is 0, return undefined.
@@ -1403,7 +1404,7 @@ The algorithm ToJSValue(|w|) coerces a [=WebAssembly value=] to a Jav
1. Return [=𝔽=](|i31| interpreted as a [=mathematical value=]).
1. If |w| is of the form [=ref.struct=] |structaddr|, return the result of creating [=a new Exported GC Object=] from |structaddr| and "struct".
1. If |w| is of the form [=ref.array=] |arrayaddr|, return the result of creating [=a new Exported GC Object=] from |arrayaddr| and "array".
-1. If |w| is of the form [=ref.func=] |funcaddr|, return the result of creating [=a new Exported Function=] from |funcaddr|.
+1. If |w| is of the form [=ref.func=] |funcaddr|, return the result of creating [=a new Exported Function=] from |funcaddr| in the [=current Realm=].
1. If |w| is of the form [=ref.host=] |hostaddr|, return the result of [=retrieving a host value=] from |hostaddr|.
1. If |w| is of the form [=ref.extern=] |ref|, return [=ToJSValue=](|ref|).
@@ -1542,12 +1543,12 @@ To initialize a Tag object |tag| from a [=tag address=] |tagAddress|,
-To
create a Tag object from a [=tag address=] |tagAddress|, perform the following steps:
+To
create a Tag object from a [=tag address=] |tagAddress| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Tag object cache=].
1. If |map|[|tagAddress|] [=map/exists=],
1. Return |map|[|tagAddress|].
-1. Let |tag| be a [=/new=] {{Tag}}.
+1. Let |tag| be a [=/new=] {{Tag}} in |realm|.
1. [=initialize a Tag object|Initialize=] |tag| from |tagAddress|.
1. Return |tag|.
@@ -1710,12 +1711,12 @@ To
initialize an Exception object |exn| from an [=Exception address=]
-To create an Exception object from a [=exception address=] |exnAddress|, perform the following steps:
+To create an Exception object from a [=exception address=] |exnAddress| in a [=realm=] |realm|, perform the following steps:
1. Let |map| be the [=surrounding agent=]'s associated [=Exception object cache=].
1. If |map|[|exnAddress|] [=map/exists=],
1. Return |map|[|exnAddress|].
-1. Let |exn| be a [=/new=] {{Exception}}.
+1. Let |exn| be a [=/new=] {{Exception}} in |realm|.
1. [=initialize an Exception object|Initialize=] |exn| from |exnAddress|.
1. Return |exn|.
@@ -1890,7 +1891,7 @@ To instantiate a builtin set with name |builtinSetName|, perform the
1. Let |exportsObject| be [$OrdinaryObjectCreate$](null).
1. [=list/iterate|For each=] (|name|, |funcType|, |steps|) of |builtins|,
1. Let |funcaddr| be the result of [=create a builtin function=] with |funcType| and |steps|.
- 1. Let |func| be the result of creating [=a new Exported Function=] from |funcaddr|.
+ 1. Let |func| be the result of creating [=a new Exported Function=] from |funcaddr| in the [=current Realm=].
1. Let |value| be |func|.
1. Let |status| be [=!=] [$CreateDataProperty$](|exportsObject|, |name|, |value|).
1. Assert: |status| is true.
diff --git a/document/web-api/index.bs b/document/web-api/index.bs
index aa58250d5c..e124a0715e 100644
--- a/document/web-api/index.bs
+++ b/document/web-api/index.bs
@@ -117,7 +117,7 @@ Note: This algorithm accepts a {{Response}} object, or a
{{CompileError}} or other relevant error type, depending on the cause of failure.
- 1. Let |returnValue| be [=a new promise=].
+ 1. Let |returnValue| be [=a new promise=] in the [=current Realm=].
1. [=React=] to |source|:
* If |source| was fulfilled with value |unwrappedSource|:
1. Let |response| be |unwrappedSource|'s [=Response/response=].