-
Notifications
You must be signed in to change notification settings - Fork 472
Stack machine semantics #323
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
Conversation
@rossberg-chromium with stack machine, parenthesis don't carry any function anymore. Require putting them around every instruction sounds like unnecessary decoration. New text stack format better off without parenthesis at all. Mixing two styles in the same file format confuses people. |
@drom, mixing two styles in one format is exactly what is happening currently, what people have complained about, and which I'm suggesting to get rid of. |
The goal for the text format in the MVP seems to be a "linear opcode" format to mirror the binary format. This PR makes fundamental changes to the expression syntax, but still includes some form of it. Is this change an incremental step toward removing expressions, or will expressions remain in WAST? |
@AndrewScheidecker Mozilla appear to have committed to continuing to explore a structured text format, see WebAssembly/design#704 (comment) There is a difference between not standardizing the text format for the MVP which I can understand, and ignoring the use case of a structure text format which I hope will not pass. This PR has a format for testing purposes, so does it really need to be representative? |
@AndrewScheidecker: the decision as mentioned in your link is to ship the wasm MVP with a linear list. The spec repo's s-expression language will be a superset of that, but not part of the wasm spec, and not shown in browsers. However, after the MVP experimentation might lead to further developments and possible spec additions. |
It makes sense for the ml-proto text format to include non-standard functionality for the test suite. But some subset of a future state of the ml-proto text format will be the MVP standard text format, right? Will that subset include expression trees in addition to linear operator sequences, or will expression trees be a non-standard part of the ml-proto syntax? |
I'm in favor of requiring bracketing. In the example @rossberg-chromium gave the bracketed version seems more readable to me (although some more newlines might make the non-bracketed version look better). The parenthesis make it clear which things are meant to be taken as a unit, which I think will be especially helpful for instructions that take a number of optional arguments. |
@AndrewScheidecker: The MVP will only standardize the linear part. In other words, expression trees will be a non-standard thing used in the spec repo. |
Thank you, that's what I was trying to figure out. A big part of the value of ml-proto to other implementations right now is its test suite. If everybody implements the non-standard expression tree syntax to access the test suite, it will be de facto standard. So IMO ml-proto should either remove expression trees (doesn't need to happen all at once), or the standard should include expression trees. |
It seems with the recent change, code like this:
is now accepted. I understand why this makes the text format simpler, but it's also surprising. I wouldn't be comfortable with a language that visually looks like it has one structure, but actually has a very different structure, spreading, which is plausible here. |
@kripken I did not see a decision to 'standardize the linear part' in the MVP rather to not have a standard in this area for the MVP. I would not object to also having a linear presentation of the code. The core issue is surely keeping the design consistent with the use case of a structured presentation. I don't think it matters if a linear code or some macros are used for testing, even if this becomes a de-facto standard format, this is a small matter. |
Since it sounds like the expression tree syntax will stay in ml-proto, it would be nice if there was a stronger separation between it and the stack machine syntax. For example:
I think a syntax like that would be a nice incremental step that exposes the additional flexibility of the stack machine, but without crossing wires in our intuition about the expression syntax: implicit stack operands don't cross parentheses. |
@AndrewScheidecker A semi-colon is not generally used like that in an s-exp, does not fit the representation. For a stronger separation a
It raises the problem of what to do if there are more or less values than expected by the consumer of the When |
I agree, but the format already departs from a standard S-expression syntax. Previously the departure was pretty small: e.g.
That would still not distinguish between an operator expression and an "linear operator". |
Could add another operator |
The names are still pre WebAssembly#297, once that's finalize I can fix this up (after the sync WebAssembly#323). With this change, test/core/run.py passes on all test cases in simd/.
This implements the stack machine semantics for Wasm:
I apologise for the monolithic PR. Breaking the move over to a stack machine semantics into meaningful smaller steps is kind of impossible.
The main downside of this change is that evaluation got much slower, because it is now implemented by term rewriting, literally modelling a small-step reduction semantics as on paper. The upside is that this makes it suitable for explicitly modelling threads later on.