3 ms·
> 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
by muizelaar 10y ago
> 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 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."
- CalChris 10y agoconstructs must leave the stack at the same height with the same types 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.
- titzer 10y agoWe learned our lessons from the JVM, and the verification algorithm for WASM is vastly simpler. It's even been formalized and fits in about 3/4 a page.
- kuschku 10y ago> Why? Because you can also easily transform an AST back into code to reverse engineer? Reverse engineering code for a stack machine is quite a bit more annoying.
- azakai 10y agoSadly it is more complicated - but the document in the link was written before a bunch of problems were found (with things like unreachable code, which is indeed trickier in stack machines than ASTs). (Those problems and their solutions haven't been documented yet AFAIK.)