Skip to content
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

Add br_if and br_switch. #403

Closed
wants to merge 1 commit into from
Closed

Add br_if and br_switch. #403

wants to merge 1 commit into from

Conversation

sunfishcode
Copy link
Member

This adds br_if and br_switch to AstSemantics.md, essentially as suggested in #299 . The semantic description here is very brief; for full details see the corresponding spec PR, WebAssembly/spec#131 .

@rossberg
Copy link
Member

Do we actually have consensus on br_switch? As far as I recall the discussion in #299, the only thing people could agree to (and not particularly enthusiastically) was adding break_if/break_continue. But br_switch is a significantly more complicated operator. It's fine changing the switch operator in certain ways (e.g., making it fallthrough by default, and/or making it table switch over a range), but I doubt we should have several switch operators.

In general, I'm still not sure where all this is going, and whether I agree with the direction.

@lukewagner
Copy link
Member

@rossberg-chromium The argument that convinced me in #299 is that the natural way to transform a CFG into structured control flow is to generate tons of if-break's and switch-break's and so it makes sense to have these available as primitives (less ops to decode and no need to pattern-match to fold branches means faster decoding and better performance for dumb compilers). br_if and br_switch seem symmetric in this regard, as they are two pieces of the same algo; it'd be weird to only have one. In terms of engine complexity, I think it will be negligible (both switch and br_switch would decode into the same engine-internal IR op).

Also, with br_switch, you get fallthrough "for free", and so switch could keep its simple, high-level definition.

@sunfishcode
Copy link
Member Author

After several offline discussions, I'm now working on a new hybrid proposal that attempts to merge the best of both approaches. I'll open a new PR when the new plan is ready.

@sunfishcode sunfishcode deleted the br_if branch October 13, 2015 21:04
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

Successfully merging this pull request may close these issues.

3 participants