-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
constant folding and PolymerRenamer #2594
Comments
cc @robliao |
I would love for some pressure to help push forward alternatives to all this string reflection: Polymer/polymer#4543 |
If you disable foldConstants, it should only be when |
why? |
Because Inside Google, you are going to need to switch to a different approach for renaming polymer elements. Such as https://github.com/Banno/polymer-rename. I think @jart was also working on a solution. |
Is there a way to disable constant folding for specific sections of code, or specific files rather than for the whole binary? |
Not that I know of. We don't really support avoiding optimizations at micro levels like that. It would be easier if Polymer Renamer recognized this alternate syntax - specifically because that's really the only optimization that can occur on that type of code. For reference, the optimization won't trigger unless it saves bytes so you'll only see it on longer arrays of strings. |
I suspect other optimization can get on the way as well. |
The Polymer Renamer is essentially destaffed at the moment. I agree with @ChadKillingsworth that for Polymer v2 the prepass, compile, and postpass is the way to go until Polymer stops using string based expressions. Having said that, I'm happy to review a pull request to the Polymer Renamer. |
If you really want to address this properly, then we need to add the ability to parse observers and paths and emit the appropriate reflection calls to the PolymerPass. Someone would just need to add that ability. Doing that would enable us to also add the necessary sink calls to prevent dead code elimination of the methods. I'd be happy to assist or review and test the changes. cc @azakus |
@maximermilov in the internal version of the compiler, you can enable/disable passes individually, so you can disable constant folding if you wish. As Chad said, the changes to avoid this issue should happen in Polymer Renamer and/or the Polymer pass in the compiler, not in the optimizations. |
Chad tells me that Polymer Renamer is also incompatible with the compiler's type-based optimizations, so it sounds like some more work is needed to make Polymer Renamer compatible with advanced mode. |
Code snippet from https://github.com/PolymerElements/app-route.git
got compiled to
PolymerRenamer expect observers to be array of strings (to rename function names)
I suggest disabling foldConstants if PolymerPass is enabled.
The text was updated successfully, but these errors were encountered: