Live data from Hacker News

WebAssembly Stack Machine

docs.google.com

11–20 of 47 posts

Re: WebAssembly Stack Machine

#11
post #8
post #6

Earlier 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…

Or flash

Re: WebAssembly Stack Machine

#12
post #4

The 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…

I always liked the simplicity of Register based machines.

Re: WebAssembly Stack Machine

#15
post #4

The 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…

I've implemented the stack-machine validation rules, and they're very similar to the postorder AST validation rules. In some areas, they're actually simpler, because the stack-machine rules accept roughly a superset of the AST rules, so there are fewer constraints to enforce.

The stack-machine rules were indeed added late, and it's reasonable to ask whether they might have been improved if there had been more time to iterate. It's also reasonable to ask whether a simple register-machine design with a compression layer on top would have been a better overall design.

However, code size is important for wasm. Smaller code size means less to download between a user clicking a link and viewing content. Networks have gotten faster on average, but bandwidth still matters in many contexts.

Re: WebAssembly Stack Machine

#16
post #9
post #8

Earlier quoted context omitted.

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…

I'd be surprised if it took that long.

Yes, if there's a compiler that compiles from C/C++ to WASM, then it should be possible, I suppose.

Re: WebAssembly Stack Machine

#17
post #6
post #5

Earlier 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?

How about threading? And a concurrent garbage collector? Would it be possible to code these things in WASM?

Re: WebAssembly Stack Machine

#19

I'm confused about all of this - is WebAssembly related to the Google Native Client stuff they did and are now deprecating? Is there a write-up of how it works?

No other than that it's meant to be used in much the same way and has some of the same developers working on it.

This might help you:

https://github.com/WebAssembly/design/blob/master/FAQ.md

Re: WebAssembly Stack Machine

#20

I'm confused about all of this - is WebAssembly related to the Google Native Client stuff they did and are now deprecating? Is there a write-up of how it works?

Google Native Client is not deprecated, it is still supported in Chrome, and in many ways exceeds the capabilities of WebAssembly.

WebAssembly is very different, and in Chrome it is implemented on top of TurboFan, V8's code generator, rather than Native Client.

Post reply on HN