Repository navigation
Replies: 1 comment 1 reply
|
We need this feature too, please |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
The V8 build behind workerd supports the js-string-builtins proposal (shipped by default in V8 / Chrome
≥130), but there's no way to enable it for Wasm loaded as a Worker module. The builtins require a per-module compile-time opt-in (
CompileTimeImports), and neither of workerd's module-compilation paths supply it.Request: a way to enable
builtins: ['js-string']for module-imported Wasm (CompiledWasmmodules and Worker Loader{ wasm }modules).Background
The proposal is opt-in per module. From JS that's
WebAssembly.compile(bytes, { builtins: ['js-string'] }); the engine then resolves imports from the reservedwasm:js-stringnamespace as native builtins instead of treating them as ordinary imports.Problem
In workerd:
Runtime
WebAssembly.compile(bytes, …)the only JS API that accepts thebuiltinsopt-in is blocked:CompileError: WebAssembly.compile(): Wasm code generation disallowed by embedder.Module-imported Wasm is compiled via the C++ API, which passes no
CompileTimeImports:So a
.wasmmodule that importswasm:js-stringhas those imports treated as ordinary (unresolved) imports — they can only be satisfied with hand-written JS glue functions, which defeats the purpose of the proposal (native, inlinable string ops with no JS round-trip).Repro (verified on deployed Workers)
A
CompiledWasmmodule importingwasm:js-stringlength(func (param externref) (result i32)), re-exported aslen:WebAssembly.validate(bytes, { builtins: ['js-string'] })does honor the option (the namespace is recognized and type-checked), confirming the feature is present in the engine — it just can't be turned on for module compilation.Proposed solution
CompileTimeImports(withjs-stringenabled) into the module-compilation path —compileWasmModule/compileWasmGlobal— gated behind a compatibility flagUse case
I'm building a language that compiles to WASM and runs also on CF workers, Strings are currently a WasmGC byte array; js-string-builtins would let us back them with JS strings and get native length/concat/compare/substring without JS glue — but there's no path to enable it today.
All reactions