I begin to work on WASI preview 2 and takes inspir...
# webassembly
I begin to work on WASI preview 2 and takes inspiration of the WIT based interfaces for exposing my WASI preview 1 implementation. I will automate the conversion later and will likely create a specification doc to discuss how WIT translate to Kotlin constructs and the other way around. I will ask my some related question in this thread as I progress.
🔥 1
@bashor @Svyatoslav Kuzmich [JB] Should
like used in https://github.com/WebAssembly/wasi-clocks/blob/main/wasi-clocks.wit.md#expiration translate to
or something else?
Do you know if there are any docs of the
or maybe examples of bindings? From discord discussions it seems that
are likely to be removed from preview 2 It would make sense for high-level APIs to expose it as
, but it could also have some lower-level type to avoid dependency on kotlinx.coroutines. Something like what we have with
in JavaScript interop, where you can convert
and back.
Thanks for your feedback, I will check and let you know.
So far, WebAssembly Component Model translation to Kotlin looks like a smooth process. I am not surprised since Kotlin and Rust share some common idioms. https://github.com/sdeleuze/kowasm/blob/main/wasi/src/wasmMain/kotlin/org/kowasm/wasi/WasiClock.kt
After the feedback from Kotlin side, I will reach the Wasm Component Model group to confirm/refine.
Looks good overall! I left some github comments to this commit. Please let me know if this answers open questions, or if you will have more. Anyway, we could start with some initial API design and refine it along the way.
Thanks I will take those feedback in account, perform a step of comparison with what is generated for Rust and ask insights to the Component Model team for the remaining open questions.
I think I saw Chrome is going to ship support for both WasmGC and stringref proposal, and that Dart leverages stringref (I think for now Kotlin/Wasm does not). Could stringref improves Kotlin/Wasm interrop with JavaScript and WIT strings? If part of let say WebAssembly 3.0, would stringref potentially impact with how WebAssembly Component Model deals with strings, or are those 2 independant (implementation detail)?
We have experimented with stringref and it does improve performance of JS interop. We plan to use it when it is closer to being standardised. In think it could improve WIT strings interop, especially if other components would adopt it as their internal representation and engines would optimise cases of UTF-8 <-> UTF-16 conversions.
would stringref potentially impact with how WebAssembly Component Model deals with strings, or are those 2 independant (implementation detail)
Mostly an implementation detail, but it would allow a sharing reference to immutable string memory without copy (which is currently always required in a linear memory-based CM ABI). But even without copy, Wasm engines would need to make sure that stringref is valid unicode string (which is not always the case with WTF-16 strings in Kotlin, JS, etc.) before passing it to other component. Hopefully, this bit of information could be cached in the stringref once computed. This is based on my assumption that CM would include stringref as a choice for CM canonical ABI, but I haven’t seen any opinions regarding stringref from CM folks yet.
I can ask in the next CM meeting and share their feedback.