-
Notifications
You must be signed in to change notification settings - Fork 694
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
Steady On: An alternative to Tilt #44
Comments
Getting rid of label variables sounds really good. Is there a downside? |
The downside is that in the worst case, it can generate deeply nested structures which may be too deep for some existing JS parsers to handle. |
Ah, I see. I wasn't sure if you meant that it introduced some sort of nesting with a runtime cost. |
This technique has no runtime cost. |
I think this is a compelling argument that we could remove a significant amount of label variables into this form. I don't think we can remove them all - even if it is possible to do so, it might lead to unpleasant "towers" that cause parsing issues, and are also less readable, as mentioned above. But, given that label variables are rare anyhow, and this seems like a good way to get rid of yet more of them, it definitely reduces the motivation for something like tilt, at least for reducible control flow. A remaining benefit of tilt is that it can represent irreducible control flow in a way that is very easy to optimize. So the question might be, do we care about irreducible control flow yet. I think maybe we don't, although I also don't think that tail calls are a perfect solution to irreducible control flow either, so we might consider multiple options for irreducible control flow later. Overall this, together with @pizlonator's arguments on automatic jump threading, convince me that we can hold off on thinking about irreducible control flow for now. |
At present, there seems to be consensus on the current approach, so there's no need to hold this issue open. |
Here's one of the examples which motivated the Tilt discussion:
It is possible to represent this without label variables, like this:
Furthermore, I have now worked out a constructive proof that it's possible to represent all reducible control flow using our existing structured forms without the use of label variables, by using this general technique as a fallback instead of label variables. In the worst case, it can generate deeply nested structures which may be too deep for some existing JS parsers to handle, so there are tradeoffs to consider when polyfilling to asm.js, but there are many cases where the nesting isn't deep and the technique should work well.
Consequently, I propose we hold off on Tilt for now. A hybrid Relooper implementation extended to use of this technique in situations where it would be beneficial is worth pursuing, as it would allow Emscripten to generate better asm.js code, and allow llvm-wasm to generate better wasm code which polyfills to asm.js for v1.
The text was updated successfully, but these errors were encountered: