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

Open
1 task done
ajklein opened this issue Mar 14, 2024 · 1 comment
Open
1 task done

JS String Builtins for WebAssembly #940

ajklein opened this issue Mar 14, 2024 · 1 comment

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants