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
Missed optimizations regarding strings #13114
Comments
This comment was originally written by ngeoffray@google.com Fixing the C.JSString_methods.$add here: https://codereview.chromium.org/23496037/. |
Added this to the M7 milestone. |
This comment was originally written by ngeoffray@google.com No, we are not emitting += for s = s + 'foo'; |
Removed Priority-Unassigned label. |
This comment was originally written by ngeoffray@google.com Set owner to @floitschG. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
The SSA output is now: main: function() {
var x, s;
x = K.returnString(1);
s = "y" + H.S(x) + H.S(K.returnString(0)) + H.S(x);
P.print(s);
s = s + H.S(K.returnString(0)) + H.S(x);
P.print(s);
P.print(s);
} Although the SSA backend will convert
That requires reassociation of The CPS output is main: function() {
var x = K.returnString(1), s = "y" + H.S(x) + H.S(K.returnString(0)) + H.S(x);
P.print(s);
P.print(s = s + H.S(K.returnString(0)) + H.S(x));
P.print(s);
} Generating |
I'm closing this, since the occasional size benefit from reassociation followed by "+=" is small. |
returnString(x) {
if (x == new DateTime.now().millisecondsSinceEpoch) return null;
return 'fisk';
}
main() {
String x = returnString(1);
String s = '';
s += 'y';
s = '$s$x${returnString(0)}$x';
print(s);
s = '$s${returnString(0)}$x';
print(s);
print(s);
}
Becomes:
main: function() {
var x, s;
x = $.returnString(1);
s = C.JSString_methods.$add("", "y") + x + $.returnString(0) + x;
Notice that s += "..." isn't optimized as well as s = "$s..."
$.Primitives_printString(s);
s = s + $.returnString(0) + x;
Notice that this could be: s += $.returnString(0) + x;
$.Primitives_printString(s);
$.Primitives_printString(s);
}
The text was updated successfully, but these errors were encountered: