-
Notifications
You must be signed in to change notification settings - Fork 695
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
Eliminate continue
statement
#310
Comments
Labels are implicit? That's interesting, when did we decide on that? If that's the case, I agree that |
At least that was my understanding wrt to the binary encoding. It's what the V8 prototype does -- break and continue just take a relative depth parameter. |
This does look like it's an improvement over the current design. It slightly obscures backedges in the case of That said, I also have an open proposal for a much broader redesign of the control constructs in #299. |
I'm not sure we're gaining anything by reducing the number of control flow No one even has a completely functional pipeline and we're changing On Mon, Aug 24, 2015 at 8:23 PM, Dan Gohman [email protected]
|
Would it help if I put a wasm backend in my personal compiler so we have a test corpus to play with until LLVM is ready? |
On Mon, Aug 24, 2015 at 9:05 PM, Katelyn Gadd [email protected]
Yeah, let's see what comes out :-)
|
@titzer, this is not taking away any pattern. A producer just literally replaces |
No, they need to have another block inside the loop order to do so. On Mon, Aug 24, 2015 at 9:40 PM, rossberg-chromium <[email protected]
|
@titzer, in asm.js |
In v8-native, a loop is just like a block in that it contains multiple If so, I think that's a lot of aggravation for no gain anywhere. On Mon, Aug 24, 2015 at 10:14 PM, rossberg-chromium <
|
I see. I hadn't noticed that about v8-native. The AST semantics doesn't say anything to the contrary, so I have been assuming the obvious C statement structure so far. Has this actually been discussed? |
I think the primary benefit to eliminating the continue operation is that it simplifies the AST context; e.g. the context to mimic the JavaScript break and continue semantics as the binary encoding from the polyfill prototype requires is annoying. Another way to simplify the context (and eliminate continue) without requiring extra label nodes is to give loop nodes two branch targets: one for break, and one for continue. e.g. this WebAssembly: Incidentally, I also think the text format should eventually require referencing labels, locals, and globals by name; that would mean only consumers of the binary format need to understand indexing. With rules like loops introducing two labels, or separate index spaces for locals by type, that's potentially a lot of complexity that could be isolated to the binary format. It makes sense to keep the indexing in the text format for prototyping, but once the reference interpreter also implements a binary format, it would be nice to get rid of it. |
This would address my concerns. I like it.
That would be great, since I basically don't understand how the numeric indexes work right now despite trying to :-) |
On Mon, Aug 31, 2015 at 6:11 PM, Andrew Scheidecker <
|
The main change to v8-native to implement this would be that each label on the stack only has a single target instead of a break target and a possibly null continue target. It also eliminates an edge case to verify that the stack index parameter of a continue operation has a non-null continue target. |
sgtm.
I think it would be unfortunate if the text format were to diverge too much from the binary format - people learning about webassembly will naturally assume that the text format is conceptually the same as the binary one. If the text format supports both names and indices, documentation will naturally introduce both and explain how one is syntactic sugar for the other. Such information is likely to be left out, or not explained as well, if the text format is not allowed to reflect the binary format. |
On Mon, Aug 31, 2015 at 11:29 PM, David Piepgrass [email protected]
|
I don't feel too strongly one way or the other about continue. Just wanted to point out you can do it without requiring extra label nodes.
I agree in general, but the text format already lets you name things where I assume the binary format will be all indices: non-exported functions, globals, locals, parameters, labels, etc. IMO that's justifiable because it makes it much easier for a human to read (the whole point of the text format) without changing the semantics. I don't see why anybody other than people writing an encoder or decoder need to even know that the binary format uses indices. How many people with a functional knowledge of x86 assembly know how it's encoded? |
You have a point there... but just to be clear, I didn't immediately find the issue id, but I remember we were talking about (and I advocate) having a place for names (of parameters, locals, etc.) to be stored in the binary format, so that text and binary will round-trip and other reasons (e.g. having a good debugging experience in the absence of source code.) The names could be stripped to save space, which makes me think the text format needs a way to represent indices in that scenario. |
On Tue, Sep 1, 2015 at 5:45 PM, David Piepgrass [email protected]
Engines should produce low-level stack traces that should be interpreted by
|
The consensus there was that stripped names would be bare symbols, i.e. And as Ben says, the names are a human concern, not something that affects the engine. They just live in a table and are used for human-facing stuff like a debugger or a disassembler. |
Polling this issue to see if there is a consensus: text format aside, continue stays or goes? |
If I understand the recent resolution of the control structure discussion correctly (not sure about that), then |
Yes, I think we all agree now that we don't want |
I think so. There is a distinction at the v8-native binary level since |
Yes, I'd argue that's an encoding issue. |
I see how we can do this with a v8-native change; just push two labels onto the stack for loop and then break and br_if can pick which one based on the nesting depth. Closing. Remove continue. |
In a language with break-from-block, the
continue
statement is redundant. Any loop of the formcan equivalently be rewritten to
While a separate
continue
statement is useful in user-facing syntax, I see no benefit in having it in Wasm. In particular, since labels are implicit, so there isn't even any encoding overhead in the second form.I propose removing
continue
.The text was updated successfully, but these errors were encountered: