https://kotlinlang.org logo
#webassembly
Title
# webassembly
s

sdeleuze

02/22/2019, 9:55 AM
2 questions I have regarding to an hypothetic Kotlin -> Kotlin IR -> Binaryen IR -> WebAssembly toolchain: - How much Kotlin/Native is tide to LLVM? Could we imagine some kind of Kotlin/Native IR not tide to LLVM that could be used to generate Binaryen IR when targeting WASM? - I heard that Kotlin/JS team is working on an IR, is there some kind of generic Kotlin IR effort or is it specific to Kotlin/JS?
s

Svyatoslav Kuzmich [JB]

02/22/2019, 11:24 AM
I heard that Kotlin/JS team is working on an IR, is there some kind of generic Kotlin IR effort or is it specific to Kotlin/JS?
Its a general effort to transition all backends to Kotlin IR. It would enable more code reuse across backends, common library format and common compiler plugin API. Moreover, new Kotlin/JS backend on top of this IR is almost done, stay tuned.
❤️ 6
s

sdeleuze

02/22/2019, 11:24 AM
Awesome ❤️
s

Svyatoslav Kuzmich [JB]

02/22/2019, 12:05 PM
Could we imagine some kind of Kotlin/Native IR not tide to LLVM that could be used to generate Binaryen IR when targeting WASM?
When IR comes out of frontend it is almost backend agnostic for “pure” Kotlin code. Down the road it is lowered somewhat differently for each backend to enable simple Kotlin IR to JVM Bytecode, JS AST or LLVM IR conversions. Almost everything interop related is handled differently. In order to have direct WebAssembly generation one would want to add/delete/tweak some of these later lowering passes to get adequate IR abstraction level for WebAssembly code. I’m not sure how much should be changed in K/N but it would vary greatly depending on number of post-MVP WebAssembly features enabled.
👍 1
s

sdeleuze

02/22/2019, 12:09 PM
I will try to analyze what Kotlin/JS and Kotlin/Native features would map to WebAssembly post-MVP and how
👍 1
s

Svyatoslav Kuzmich [JB]

02/22/2019, 12:24 PM
Another big thing IMO is interop. Future Wasm version might enable interop with JavaScript, unmanaged Wasm and managed Wasm compiled from other languages at the same time. Design of Wasm represenation for Kotlin constructs might affect this a lot.
s

sdeleuze

02/22/2019, 12:25 PM
Yeah I plan to take inspiration on what Rust do
But that's maybe where that would ended up with a mix of Kotlin/JS and Kotlin/Native for a better solution