Repository navigation
[js-api] Add the missing realm argument #2261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
f52985
wants to merge
1
commit into
WebAssembly:main
Choose a base branch
from
kaist-plrg:fix/js-api-new-object-missing-realm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -438,7 +438,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje | |
| <div algorithm> | ||
| To <dfn>construct a WebAssembly module object</dfn> from a module |module|, source bytes |bytes|, enabled builtins |builtinSetNames|, and |importedStringModule|, perform the following steps: | ||
|
|
||
| 1. Let |moduleObject| be a [=/new=] {{Module}}. | ||
| 1. Let |moduleObject| be a [=/new=] {{Module}} in the [=current Realm=]. | ||
| 1. Set |moduleObject|.\[[Module]] to |module|. | ||
| 1. Set |moduleObject|.\[[Bytes]] to |bytes|. | ||
| 1. Set |moduleObject|.\[[BuiltinSets]] to |builtinSetNames|. | ||
|
|
@@ -449,7 +449,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje | |
| <div algorithm> | ||
| To <dfn>asynchronously compile a WebAssembly module</dfn> 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 |promise| be [=a new promise=] in the [=current 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: | ||
|
|
@@ -614,7 +614,7 @@ The verification of WebAssembly type requirements is deferred to the | |
|
|
||
| <div algorithm> | ||
| To <dfn>asynchronously instantiate a WebAssembly module</dfn> from a {{Module}} |moduleObject| and imports |importObject|, perform the following steps: | ||
| 1. Let |promise| be [=a new promise=]. | ||
| 1. Let |promise| be [=a new promise=] in the [=current Realm=]. | ||
| 1. Let |module| be |moduleObject|.\[[Module]]. | ||
| 1. Let |builtinSetNames| be |moduleObject|.\[[BuiltinSets]]. | ||
| 1. Let |importedStringModule| be |moduleObject|.\[[ImportedStringModule]]. | ||
|
|
@@ -625,7 +625,7 @@ 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. Let |instanceObject| be a [=/new=] {{Instance}} in the [=current Realm=]. | ||
| 1. [=initialize an instance object|Initialize=] |instanceObject| from |module| and |instance|. | ||
| If this throws an exception, catch it, [=reject=] |promise| with the exception, and terminate these substeps. | ||
| 1. [=Resolve=] |promise| with |instanceObject|. | ||
|
|
@@ -635,7 +635,7 @@ The verification of WebAssembly type requirements is deferred to the | |
| <div algorithm> | ||
| To <dfn>instantiate a promise of a module</dfn> |promiseOfModule| with imports |importObject|, perform the following steps: | ||
|
|
||
| 1. Let |promise| be [=a new promise=]. | ||
| 1. Let |promise| be [=a new promise=] in the [=current Realm=]. | ||
| 1. [=React=] to |promiseOfModule|: | ||
| * If |promiseOfModule| was fulfilled with value |module|: | ||
| 1. [=asynchronously instantiate a WebAssembly module|Instantiate the WebAssembly module=] |module| importing |importObject|, and let |innerPromise| be the result. | ||
|
|
@@ -867,7 +867,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each | |
| 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 the [=current Realm=]. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the call stacks for this algorithm "create an exports object" → "initialize an instance object" → the bit of "asynchronously instantiate a WebAssembly module" that doesn't have access to the current Realm. So you'll need to pass the realm through explicitly from there. |
||
| 1. [=initialize a memory object|Initialize=] |memory| from |memaddr|. | ||
| 1. Return |memory|. | ||
| </div> | ||
|
|
@@ -1031,7 +1031,7 @@ Each {{Table}} object has a \[[Table]] internal slot, which is a [=table address | |
| 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 the [=current Realm=]. | ||
| 1. [=initialize a table object|Initialize=] |table| from |tableaddr|. | ||
| 1. Return |table|. | ||
| </div> | ||
|
|
@@ -1167,7 +1167,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each | |
| 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 the [=current Realm=]. | ||
| 1. [=initialize a global object|Initialize=] |global| from |globaladdr|. | ||
| 1. Return |global|. | ||
| </div> | ||
|
|
@@ -1547,7 +1547,7 @@ To <dfn>create a Tag object</dfn> from a [=tag address=] |tagAddress|, perform t | |
| 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 the [=current Realm=]. | ||
| 1. [=initialize a Tag object|Initialize=] |tag| from |tagAddress|. | ||
| 1. Return |tag|. | ||
|
|
||
|
|
@@ -1715,7 +1715,7 @@ To <dfn>create an Exception object</dfn> from a [=exception address=] |exnAddres | |
| 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 the [=current Realm=]. | ||
| 1. [=initialize an Exception object|Initialize=] |exn| from |exnAddress|. | ||
| 1. Return |exn|. | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have a current Realm when running the steps in a queued task, I'm afraid. It's only available when you're being called directly from JS. You'll need to capture the realm at the top of this algorithm (assuming it exists there - check the callers) and use the captured variable within the task.