-
Notifications
You must be signed in to change notification settings - Fork 701
Clarify that wasm may be viewed as either an AST or a stack machine. #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,19 @@ | ||
| # Abstract Syntax Tree Semantics | ||
|
|
||
| WebAssembly code is represented as an Abstract Syntax Tree (AST) where each node | ||
| represents an expression. Each function body consists of a list of expressions. | ||
| All expressions and operators are typed, with no implicit conversions or overloading rules. | ||
| This document describes WebAssembly semantics. The description here is written | ||
| in terms of an Abstract Syntax Tree (AST), however it is also possible to | ||
| understand WebAssembly semantics in terms of a stack machine. (In practice, | ||
| implementations need not build an actual AST or maintain an actual stack; they | ||
| need only behave [as if](https://en.wikipedia.org/wiki/As-if_rule) they did so.) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fwiw I don't think describing wasm as a 'stack machine' will help the reader because: the nodes are still expressions and need not represent one value on the stack; and there are some in-order operators that do not fit the 'stack machine' 'instruction' description well. Perhaps after some of the changes under discussion it will fit the 'stack machine' description better, such as removing the |
||
| This document explains the high-level design of the AST: its types, constructs, and | ||
| semantics. For full details consult [the formal Specification](https://github.com/WebAssembly/spec), | ||
| for file-level encoding details consult [Binary Encoding](BinaryEncoding.md), | ||
| and for the human-readable text representation consult [Text Format](TextFormat.md). | ||
|
|
||
| Each function body consists of a list of expressions. All expressions and | ||
| operators are typed, with no implicit conversions or overloading rules. | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may well be more efficient for the encoding to take advantage of implicit conversions and/or to specialize the operators based on the argument types with the post-order encoding. I don't see the rationale for excluding these options.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is preexisting text that this PR is just moving, so I'd like to suggest raising this question in a new issue. |
||
| Verification of WebAssembly code requires only a single pass with constant-time | ||
| type checking and well-formedness checking. | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why "typed stack machine"? if typed is important, why not "typed AST" as well?