Skip to content
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

JS String Builtins for WebAssembly #940

Closed
1 task done
ajklein opened this issue Mar 14, 2024 · 2 comments
Closed
1 task done

JS String Builtins for WebAssembly #940

ajklein opened this issue Mar 14, 2024 · 2 comments
Assignees
Labels
Resolution: satisfied The TAG is satisfied with this design Topic: scripting ECMA, Web Assembly bindings, etc. Venue: WebAssembly CG

Comments

@ajklein
Copy link

ajklein commented Mar 14, 2024

こんにちは TAG-さん!

I'm requesting a TAG review of JS String Builtins for WebAssembly.

JavaScript runtimes have a rich set of builtin objects and primitives. Some languages targeting WebAssembly may have compatible primitives and would benefit from being able to use the equivalent JavaScript primitive for their implementation. The most pressing use-case here is for languages who would like to use the JavaScript String type to implement their strings. This proposal aims to provide a minimal and general mechanism for importing specific JavaScript primitives for efficient usage in WebAssembly code.

This is done by first adding a set of wasm builtin functions for performing JavaScript String operations. These builtin functions mirror a subset of the JavaScript String API and adapt it to be efficiently callable without JavaScript glue code. Then a mechanism for importing these wasm builtin functions is added to the WebAssembly JS-API. These two pieces in combination allow runtimes to reliably emit optimal code sequences for JavaScript String operations within WebAssembly modules. In the future, other JS builtin objects or JS primitives can be exposed through new wasm builtins.

Further details:

  • I have reviewed the TAG's Web Platform Design Principles
  • Relevant time constraints or deadlines: Planning to move to Phase 3 by June 2024
  • The group where the work on this specification is currently being done: WebAssembly Community Group
  • The group where standardization of this work is intended to be done (if current group is a community group or other incubation venue): WebAssembly Working Group
  • Major unresolved issues with or opposition to this specification: N/A
  • This work is being funded by: Mozilla, Google

You should also know that...

The current design is a result of extensive discussion in the Wasm CG over the past year (see above meeting notes), and follows a previous approach to dealing with strings directly in core Wasm, https://github.com/WebAssembly/stringref, which faced significant opposition in the CG.

We'd prefer the TAG provide feedback as (please delete all but the desired option):

💬 leave review feedback as a comment in this issue and @-notify eqrion and ajklein

@littledan
Copy link

littledan commented Mar 20, 2024

Some context about this design space and alternatives considered: https://wingolog.org/archives/2023/10/19/requiem-for-a-stringref

Bloomberg previously sponsored work towards the WebAssembly stringref proposal. At this point, we aren’t pushing for one alternative over another. I am just happy to see something moving forward for zero-copy strings in WebAssembly.

@torgo torgo added Venue: WebAssembly CG Topic: scripting ECMA, Web Assembly bindings, etc. and removed Progress: untriaged labels Jun 5, 2024
@torgo torgo added this to the 2024-06-10-week milestone Jun 5, 2024
@plinss plinss modified the milestones: 2024-06-10-week, 2024-06-10-week:c Jun 10, 2024
@torgo torgo modified the milestones: 2024-06-10-week:c, 2024-06-17-week:c Jun 16, 2024
@plinss plinss removed this from the 2024-06-17-week:c milestone Jun 24, 2024
@torgo torgo added this to the 2024-07-01-week:e milestone Jun 30, 2024
@torgo torgo modified the milestones: 2024-08-05-week, 2024-08-19-week Aug 8, 2024
@plinss
Copy link
Member

plinss commented Aug 21, 2024

Thank you for your patience while waiting for us to take a look at this.

The TAG currently lacks domain expertise in the internals of JavaScript and WASM implementations, so we're ill-equiped to do a deep dive here. You've clearly put a ton of effort into this, and your document more than adequately addresses the handful of things that came to our minds while reviewing it. We don't see any obvious issues with the proposal as it stands.

We'll close this review for now. Please let us know if your design substantively changes, and we'll take another look.

@plinss plinss closed this as completed Aug 21, 2024
@plinss plinss added the Resolution: satisfied The TAG is satisfied with this design label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: satisfied The TAG is satisfied with this design Topic: scripting ECMA, Web Assembly bindings, etc. Venue: WebAssembly CG
Projects
None yet
Development

No branches or pull requests

6 participants