-
Notifications
You must be signed in to change notification settings - Fork 701
Description
This section:
https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#serialized-ast
could use some more rationale as to why a pre-order encoding is being used.
It also says "Allows context-dependent index spaces (described above)", which is not obvious what that refers to, nor do I see how that would depend on it being pre-order.
In fact, I can see advantages to post-order representation:
- Allows things like validation or building up a tree by using nothing but a temporary node stack, and
an otherwise very linear parser. Pre-order can be equally efficient if you want, but it fits recursive
parsing more naturally. - Closer fit to backends that use stack-machines in some way.
Related to that, some more rationale on requiring backends to use a relooper-like algorithm to produce a limited set of control structures. I understand it results in the absolutely smallest binary, but the algorithm is not entirely non-trivial, and it feels.. less elegant to require this when most backends will have a branch/graph based representation they're working from, and V8 etc presumably also needing to convert this back to a more general representation.
What alternatives have been considered? If the top level of a block is a list of "statements", could a (conditional) branch node that refers to a statement index work also, at a small cost in binary size, but be more generic in what kind of structures it represents, being easier to generate and decode etc.?