Skip to content

Text format: named expressions instead of push/pop? #693

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

Closed
qwertie opened this issue May 23, 2016 · 8 comments
Closed

Text format: named expressions instead of push/pop? #693

qwertie opened this issue May 23, 2016 · 8 comments

Comments

@qwertie
Copy link

qwertie commented May 23, 2016

Reviewing this proposal I would propose, instead of a strict push-pop regime, a simple way of naming trees. That is, instead of

   push:0 call $foo($x)
   push:1 call $bar($y)
   call $qux(pop:0, pop:1)

let's use

   expr #0 call $foo($x)
   expr #1 call $bar($y)
   call $qux(#0, #1)

This is potentially better when writing code by hand because you can give a name to each subtree, and you can use a tree more than once:

```
expr #halve0 ($0 = $0 * 0x0.8p+0) // parens optional
call $foo(#halve0, #halve0)
```
@sunfishcode
Copy link
Member

That document is an experiment. Please file issues pertaning to it on the repo which contains it, rather than the WebAssembly repo.

@ghost
Copy link

ghost commented May 23, 2016

@sunfishcode It's not immediately obvious how to file an issue in that repo? Might this need to be enabled.

@qwertie Would your proposal be a pre-processor layer that expands the named expression into its use point, so that the named expression might be evaluated multiple times and would be evaluated where it is used? Or would it be similar to my proposed extension in #685 where an expression result can be named and the result reused which would be the same as using a value up the value stack?

If an expression result is used multiple times then this would need an extension to wasm, except in some restricted cases.

@qwertie
Copy link
Author

qwertie commented May 23, 2016

@sunfishcode I assumed that since issues were disabled in your copy of the repo, that discussion should take place here. It made sense to me.

@JSStats the former. push/pop has nothing to do with the binary format, so likewise for expr.

@ghost
Copy link

ghost commented May 23, 2016

@qwertie It was not, and is still not, clear to me that push / pop work on a pre-processor stack. They are described as 'These rules reflect how the current wasm binary format works.'. It might be an attempt to annotate the implicit pushing and popping of the values stack in the post-order decoder.

@sunfishcode
Copy link
Member

I didn't realize the issue tracker was not enabled. It is now. Please do keep in mind that this is an experiment.

@dschuff
Copy link
Member

dschuff commented May 23, 2016

@sunfishcode It's a personal strawman experiment right up until it gets implemented in a browser. After that it's something more. I actually think it's fine to have an experimental text format (and other experimental stuff) in a browser too, but at that point I think it's also fair to say you can no longer avoid public discussion (including bikeshedding). :)

Having said that I like the format quite a bit. I agree with you that we don't want re-usable subtrees and, more generally, that the text format should explicitly mirror the wasm semantics and binary encoding. In other words no macro layers, and no reusable subtrees unless we get them in the semantics. There's only one tree, and push and pop are a way to express the structure of the tree. It's not the only possible way, but any other way should be isomorphic (e.g. having push and pop without the numbers would be fine if less readable; allowing them to have names instead of the numbers would be ok, but allowing re-use would mean that the instructions in the text would be different than what is executed or encoded in the binary).

@dschuff
Copy link
Member

dschuff commented May 23, 2016

@sunfishcode Sorry I raced with you. https://bugzilla.mozilla.org/show_bug.cgi?id=1274618 says that you're looking to get feedback from users. What forum would that feedback be in? I'm sympathetic to the idea that since this is an experiment we don't need to be having discussion here, but since Mozilla is implementing it I'd like there to be a bit more visibility than just discussion on your github. On the other hand, now that we've had all this noise, maybe that's sufficient if someone opens another discussion on some Moz forum or wherever and links to it here?

@sunfishcode
Copy link
Member

@dschuff I'd like to get our initial implementation up and running before we get too far into this, because I believe that with WebAssembly's unique nature, experiments in context on real code will inform the discussion better than just design docs and a few small examples.

In the meantime, any questions, concerns, suggestions, opinions, etc. are welcome on my repo's issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants