WebAssembly Stack Machine
docs.google.com
WebAssembly Stack Machine
1–10 of 47 posts
Re: WebAssembly Stack Machine
#2It 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.
Re: WebAssembly Stack Machine
#3If 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.
Re: WebAssembly Stack Machine
#4https://github.com/WebAssembly/design/issues/755
AST was a good idea and parsing as validation was excellent. Having a general stack machine makes validation much more difficult.
This is a bad decision (stacks vs AST or register) made for the wrong reason (code size). That's a 1990s design assumption when memory was expensive and bandwidth was dear. Now memory is cheap; bandwidth is phenomenal; and latency is expensive.
Re: WebAssembly Stack Machine
#5If 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.
The devil's in the details. Exception handling and garbage collection are different enough that a straightforward adaptation won't cut it.
Re: WebAssembly Stack Machine
#6Earlier quoted context omitted.
The devil's in the details. Exception handling and garbage collection are different enough that a straightforward adaptation won't cut it.
Could you build a JVM in WASM?
The question would then be, is the mapping straightforward or you do need to reimplement everything from scratch?
Re: WebAssembly Stack Machine
#7The WA stack machine was added late in the game. Before that it was an AST but they got pushback from browser backend people and pivoted to a stack machine. https://github.com/WebAssembly/design/issues/755 AST was a good idea and parsing as validation was excellent. Having a general stack machine makes validation much more difficult. This is a bad decision (stacks vs AST or register) made for the wrong reason (code s…
Why? This document suggests that it's not that different.
"The main new changes to verification are:
- All branches to the end of a block must have the same arity and same types, including the implicit fall-through to end.
- The true block of if-end constructs must leave the stack at the same height as when the if was entered.
- The true and false blocks of if-else-end constructs must leave the stack at the same height with the same types."
Re: WebAssembly Stack Machine
#8Earlier quoted context omitted.
Could you build a JVM in WASM?
WASM'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?
Re: WebAssembly Stack Machine
#9Earlier quoted context omitted.
WASM'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?
The 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…
Re: WebAssembly Stack Machine
#10The WA stack machine was added late in the game. Before that it was an AST but they got pushback from browser backend people and pivoted to a stack machine. https://github.com/WebAssembly/design/issues/755 AST was a good idea and parsing as validation was excellent. Having a general stack machine makes validation much more difficult. This is a bad decision (stacks vs AST or register) made for the wrong reason (code s…
> AST was a good idea and parsing as validation was excellent. Having a general stack machine makes validation much more difficult. Why? This document suggests that it's not that different. "The main new changes to verification are: - All branches to the end of a block must have the same arity and same types, including the implicit fall-through to end. - The true block of if-end constructs must leave the stack at the…
That's easy to 'document' and harder to do. It's what the JVM did, again, in the 90s. Now the verifier chapter in the JVM spec is now about 160 pages long.