WebAssembly String References
- Category
- WebAssembly
- Type
- New or changed feature
- Status
- In developer trial (Behind a flag) (Chrome In developer trial (Behind a flag))
- Intent stage
- Dev trials
Summary
Allows WebAssembly module developers to create and use string references as a native data type. These string references are compatible with JavaScript strings and allow an easy interaction with JavaScript functions without the need to create copies or re-encoding at the language boundary. Specifically, these references are useful in conjunction with garbage collected WebAssembly (WasmGC) where the references nicely tie into the heap-based memory model. https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md
Motivation
Crossing the language boundary between WebAssembly and JavaScript often requires expensive re-encoding of strings making the crossings very expensive. By providing a copy-free mechanism, we can speed up applications that interact heavily with the JavaScript world. This also allow re-using existing JavaScript functionality like locale-aware string transformations or regular expressions that would otherwise be complex to implement.
Standards & signals
- Specification: https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=webassembly-string-references
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+WebAssembly%20String%20References
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=WebAssembly%20String%20References
- Baseline status: https://webstatus.dev/?q=WebAssembly%20String%20References
Explainers: https://github.com/WebAssembly/stringref/blob/main/proposals/stringref/Overview.md