3 ms·
can it be run in wasm and output native code (instead of teavm bytecode)?
by singularity2001 7y ago
can it be run in wasm and output native code (instead of teavm bytecode)?
- tom_mellior 7y agoThe GraalVM compiler emits native code. It consumes JVM bytecode, or intermediate representations of other programming languages implemented using the Truffle framework.
- pron 7y agoI assume that a WASM backend could be created for Graal Native Image, so that it could compile Java byteocde to WASM ahead of time, but I wonder what benefits that would have over compiling bytecode to JS (as TeaVM does).
- singularity2001 7y agoThere is now a pure wasm version of TeaVM. My idea was that graal could run in wasm and compile to wasm, the (only) benefits would be faster and smaller code.
- pron 7y agoI'm not sure it would be either. JS has a good JIT that Java code can significantly benefit from (much more than, say, C) -- WASM doesn't, so compiling to JS could actually be faster; JS also has a GC and WASM doesn't, which means that the image must contain a GC, making it larger, not smaller. Either way, it's speculation, but I don't think it's obvious that compiling Java bytecode to WASM is preferable to compiling it to JS, but maybe the TeaVM maintainers can share their experience.