5 ms·
If WASM runs on a stack machine, I wonder how hard it would be to map the instructions to JVM bytecodes? From the example in the document they look similar...
by bcg1 10y ago
If WASM runs on a stack machine, I wonder how hard it would be to map the instructions to JVM bytecodes? From the example in the document they look similar...
It would be interesting to be able to take code compiled with Emscripten for example and run it as part of JVM applications, similar to what NestedVM can do.
- hackcasual 10y agoThe devil's in the details. Exception handling and garbage collection are different enough that a straightforward adaptation won't cut it.
- tdb7893 10y agoCould you build a JVM in WASM?
- striking 10y agoWASM's Turing complete, so yes of course you could. (Maybe minus some features.) The question would then be, is the mapping straightforward or you do need to reimplement everything from scratch?
- tdb7893 10y agoThe horrifying thing about WASM is that you just know like 5 years from now someone will be posting some link here about how they ported the JVM to WASM and are using it to run old Java applets…
- lotyrin 10y agoI'd be surprised if it took that long.
- amelius 10y agoYes, if there's a compiler that compiles from C/C++ to WASM, then it should be possible, I suppose.
- pjmlp 10y agoOr flash
- bbcbasic 10y agoActiveX
- amaranth 10y agoThere is already PyPy.js using asm.js, doppiojvm which is written in JavaScript, and some effort on getting OpenJDK and/or JamVM to work on asm.js. I don't think you'll have to wait 5 years.
- tdb7893 10y agoI imagine people will use it on the desktop apps and soon everything will just be running with WASM! It sounds like it has the potential to unify web development with development on all platforms if it is efficient enough. EDIT: I didn't think I would be excited about WebAssembly but I'm now really curious to see what happens with it.
- baq 10y agothe browser is a game engine with beefed up security, to quote servo. webassembly is the end game of scriptability of that engine. what you say about app development being unified is already true: see atom, steam and all others who embed webkit or similar to create a desktop UI.
- amelius 10y agoHow about threading? And a concurrent garbage collector? Would it be possible to code these things in WASM?
- bcg1 10y agoWhat are the details that you mean? I just skimmed the spec and I don't see anything significant about exceptions or gc... it mostly seems focused on the WASM memory layout and the instruction set. The instruction set seems at least superficially similar to the java instruction set, and operates on a "linear memory" which could easily be implemented in java as a large array of int[] for 32 bit or long[] for 64 bit (although that scheme may need to be more complicated if it is to be shared across threads). Any instruction that doesn't have a direct analog in the jvm could be implemented as a static java method. Also WASM seems to use a static set of labels as branch targets rather than reading its instructions from the program memory (is that called harvard architecture?) which seems to suggest that you could translate WASM functions into java classes/functions to be loaded into the JVM. In any case I don't have time to implement all of that but it seems like it could be any interesting way to run non-java libraries on the JVM