In fact, I believe one of the Kotlin devs maintains TeaVM which can compile JVM bytecodes to WASM (experimentally) which would include Kotlin
Yes, that’s true. Kotlin works with TeaVM WASM backend, but I tried only with simple examples.
Granted a direct Kotlin-to-(LLVM-to-)WASM compiler would probably be more efficient than going through JVM bytecode first
Remember, that WASM guys are going to include GC support. It’s build upon a thing they called “tuple”, which is similar to LLVM structures. However, structures in LLVM are not collected, nor there’s an instruction (like in WASM) that allocates such tuple. I think new features in WASM (like GC and exception handling) are the things of higher-level than LLVM. Therefore I suppose (it’s my personal opinion, we did not discuss this in JB) that there would be direct Kotlin → WebAssembly translator, without LLVM toolchain.
GC is not the worst thing missing in WebAssembly. The worst thing is inability to debug applications. There’re no source map yet, and there’s no good tools for compiler engineers to debug WebAssembly translators. For example, you can’t conveniently display memory (like x
command in gdb), you can’t install watchpoints.