[turbofan] Optimize String#slice(-1) calls.
In TurboFan we can easily recognize calls to String.prototype.slice where the start parameter is -1 and the end parameter is either undefined or not present. These calls either return an empty string if the input string is empty, or the last character of the input string as a single character string. So we can just make use of the existing StringCharAt operator. This reduces the overhead of the String.prototype.slice calls from optimized code in the chai test of the web-tooling-benchmark significantly. We observe a 2-3% improvement on the test. Bug: v8:6936, v8:7137 Change-Id: Iebe02667446880f5760e3e8c80f8b7cc712df663 Reviewed-on: https://chromium-review.googlesource.com/795726 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#49704}
Showing
Please
register
or
sign in
to comment