-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
esm: WebAssembly.namespaceInstance #59024
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
Conversation
|
Review requested:
|
|
@nodejs/loaders |
This comment was marked as resolved.
This comment was marked as resolved.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59024 +/- ##
==========================================
- Coverage 90.07% 90.05% -0.02%
==========================================
Files 645 645
Lines 189128 189145 +17
Branches 37091 37095 +4
==========================================
- Hits 170355 170342 -13
- Misses 11459 11513 +54
+ Partials 7314 7290 -24
🚀 New features to boost your workflow:
|
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.
The WebAssembly API is implemented in V8.
I think this should be categorized like a JavaScript built-in API that should be implemented in V8, instead of polyfilling in Node.js.
Does V8 oppose to the change?
Co-authored-by: James M Snell <[email protected]>
Co-authored-by: Mattias Buelens <[email protected]>
|
@legendecas there are two ESM Integration phases - instance and source phase. V8 has an implementation of the source phase but not an implementation of the instance phase. Ideally, V8 would implement the instance phase with a But without that, we need to maintain our own side table in Node.js for the Wasm Module <=> Wasm Instance link which is the weak map here used to create When we unflag this implementation soon, we thus have two options:
I don't see any reason not to do (2), but if you have strong arguments for (1) I'm happy to reconsider landing this. It would just help to hear a single good reason why not shipping a feature would be truly beneficial in this case. I have a preference to shipping as much correctness as possible even though we can't support live bindings we get everything else, but I'm also open to alternatives here. |
|
We have layers of implementations and their scopes. Node.js is definitely capable of implementing any APIs that are useful. But for a standardized API, which falls in V8's scope of implementation, I think we should pursue implementing it in V8 first. I'm curious about the reason why we should circumvent V8 to implement this API in particular. If V8 or Chromium is not willing to implement it, I'm more worried about the standardization process. If it just needs some volunteers to take the task, I think implementing it in Node.js is just doubling the effort/waste, given that it will eventually be superseded by V8's work. |
It is purely a question of resources.
Are you interested or do you know anyone interested in working on WebAssembly Module Record in V8 here? If so, let's definitely continue this discussion further. |
|
I discussed this some more with @legendecas offline, and he raised the argument that came from experience with While in theory it is a slightly less compatible implementation, I'm happy to rather close this and reconsider it instead at a later point if a real use case comes up strongly with urgency. Otherwise, in the mean time, we can still ship the Wasm ESM Integration as experimental without requiring this feature. Closing for now, further feedback here is welcome. |
This implements the
WebAssembly.namespaceInstancefunction as defined in https://webassembly.github.io/esm-integration/js-api/index.html#dom-webassembly-namespaceinstance-namespace.This function can be used to obtain the underlying
WebAssembly.Instanceobject for a WebAssembly module record module namespace.Ideally this would be implemented in V8, but they are not currently implementing the instance phase, so this is left for us to patch here.
Example:
Internally this then shares the existing weakmap lookup that was already previously implemented.