diff options
author | Dan Gohman <sunfish@google.com> | 2013-10-02 16:11:34 -0700 |
---|---|---|
committer | Dan Gohman <sunfish@google.com> | 2013-10-02 16:11:34 -0700 |
commit | 4b8ff3fb5dcbc1ef61b17f1d7a7ca4bdb3f0b811 (patch) | |
tree | 2b4b27227fb69f4fe66ff3b198664d37a4cab12f /src/runtime.js | |
parent | 4f6975f249d2f8eaabe66dd8bee5146cd9d74d28 (diff) |
Optimize alignment rounding.
Replace x>>2<<2 and x>>3<<3 with x&-4 and x&-8, respectively, since
an and is cheaper than two shifts.
Diffstat (limited to 'src/runtime.js')
-rw-r--r-- | src/runtime.js | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/runtime.js b/src/runtime.js index a281045b..dd395826 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -112,8 +112,7 @@ var Runtime = { if (isNumber(target) && isNumber(quantum)) { return Math.ceil(target/quantum)*quantum; } else if (isNumber(quantum) && isPowerOfTwo(quantum)) { - var logg = log2(quantum); - return '((((' +target + ')+' + (quantum-1) + ')>>' + logg + ')<<' + logg + ')'; + return '(((' +target + ')+' + (quantum-1) + ')&' + -quantum + ')'; } return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum; }, |