asm.js is in coming. Now there is even rumors of Chrome soon supporting it fully.
But so far it has been used to compile C/C++ source into JavaScript that would run with near native speed (depends on how you define near native ...)
I have been planning to use GWT to turn my Java code to JavaScript, but now I was wondering if there is currently an existing path/procedure to compile plain Java source code to ASM.JS, and what would that be?
One more reason why one might want that: Java-to-ASM.js might very well run faster then Java-to-Dalvik on some Android phone!
asm.js (currently) is designed as a target for languages that manually manage memory allocation and release -- like C/C++. It cannot currently handle languages with garbage collection semantics, silly as that may seem given that it is JavaScript which is a garbage collected runtime.
If you really wanted to go the round way about, pass the Java code through j2c and then pass that C++ output through emscripten which will compile to asm.js.
Another possibility would be to pass the Java code through the LLVM compiler using the VMKit and pass that through the emscripten asm.js llvm backend...
As of 2020, you probably want to transpile to web assembly instead of asm.js. These tools are currently available:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With