-
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
tableswitch case labels? #439
Comments
I think they should work like an implicit block around each case; i.e. one can only |
|
@AndrewScheidecker's suggestion has the advantage of handling the case in C where one writes |
When trying to branch to a later case, though, we are doing something we can't do otherwise, if I am not mistaken? We can't do the following, can we:
? If I'm not confused here, then that means that tableswitch has multiple special powers - not just a jump table that we switch on, but also basic-block-like cases that can branch to each other (even if just forward). That seems like an odd mixture of a lot of separate stuff to me. |
On Mon, Nov 2, 2015 at 6:15 PM, Alon Zakai [email protected] wrote:
|
Ok. I'm ok keeping it simple for now. Producers can "stackify" for cases reached by goto. I'll prototype this and report back if there are any complications. |
I just created #443, as discussed earlier, which avoids this question. |
A
I thought the original reason for |
I created #444 to address the wording concerns here. @AndrewScheidecker For my part, I'm looking to keep things simple for now. I expect producers will be able to translate C switches with gotos between the cases with stackification -- I haven't implemented it yet, but I don't anticipate major complications. Once the binary format prototyping progresses more, it will be easier to experiment and demonstrate advantages of various variations that we might make. |
Could you explain what 'stackification' means here? How did it work our? Might it be possible to just include two tables, one for the switch entry targets and another to encode the exit paths for each case, and then to verify that they meet the requirements for a single pass SSA parser, making it a validation error if they don't. |
Stackification is what I've been calling the technique for converting arbitrary acyclic control flow into nested blocks with labeled breaks / branches. In JS-style syntax:
Syntactically it looks funny, but it directly corresponds to a valid form in JS, so it satisfies whatever constraints we may have from that. There's a risk that if we stack up too many blocks, it could cause problems for strictly recursive parsers, but if producers can eg. make effective use of In terms of the binary encoding, it's not entirely optimal if taken literally, but that's something that can be refined. |
The original issue here was whether |
Thank you for the explanation. So it looks like any DAG dominated by a switch could be encoded this way, sorting the DAG and emitting nested blocks in the sorted order with the switch-table emitted first. This would seem to handle a switch with multi-way goto's in the cases so long as this created no loops. Cool idea, and seems worthy of a note somewhere, if I understand correctly. |
While implementing tableswitch in wasm-emscripten, I realized that cases have labels. Can they be
br
-ed to? Asking @sunfishcode , there wasn't an obvious answer, so this looks unspecified, opening this for discussion.name: {}
gets to right after those{}
. But @sunfishcode said he thought maybe it should go inside. In other words, inside switches, case blocks couldgoto
to other case blocks?The text was updated successfully, but these errors were encountered: