-
Notifications
You must be signed in to change notification settings - Fork 384
Improve constant folding for method calls #10255
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
base: main
Are you sure you want to change the base?
Conversation
Somehow this suite was permenently disabled, and one test has broken in the meantime due to String.contains being simplified to the point it can more easily be inlined. When gwtproject#10147 is fixed, this can be re-enabled. Fixes gwtproject#10253
|
Some specific improvements noted in the Showcase app: NumberFormat.format() references group/decimal separator characters gwt/user/src/com/google/gwt/i18n/client/NumberFormat.java Lines 1142 to 1148 in 2a8b571
Previously the charAt() was inlined before it could be DCE'd, leaving a call to NativeString.charCodeAt which can't be optimized out in this way, but now the compiler knows what the char is and can clean it up: Later in the same method, format() defaults to having '0' as its zeroChar gwt/user/src/com/google/gwt/i18n/client/NumberFormat.java Lines 1175 to 1178 in 2a8b571
Same charAt optimization: Character.digit is often only called with radix of 10 - knowing that this is a constant lets the compiler now rewrite away the Math.min() call gwt/user/super/com/google/gwt/emul/java/lang/Character.java Lines 196 to 203 in 2a8b571
MultiWordSuggestOracle's constructor takes a string gwt/user/src/com/google/gwt/user/client/ui/MultiWordSuggestOracle.java Lines 200 to 205 in 2a8b571
The critical check for the inlined charAt(i) with a variable as a param can't be validated automatically - but with range checks or unrolling the loop that could go away in the future. |
Generalized DCE's ability to run certain String methods at compile time to other classes specifically decorated with a new annotation. This patch delays inlining those methods at all until after no further Java optimizations have an impact, then removes inlining limitations and tries one more time to inline methods.
Currently has a small size regression (.02%) from inlining specialized methods after no other improvements can take place. Should be dealt with by #10241, might be worth waiting for that fix to land this.
Fixes #10147