Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Unified Diff: runtime/platform/utils.cc

Issue 381543002: Tweaks for speed in integer arithmetic runtime. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/utils.cc
===================================================================
--- runtime/platform/utils.cc (revision 38076)
+++ runtime/platform/utils.cc (working copy)
@@ -35,12 +35,16 @@
int Utils::HighestBit(int64_t v) {
- uint64_t t = static_cast<uint64_t>((v > 0) ? v : -v);
- int count = 0;
- while ((t >>= 1) != 0) {
- count++;
- }
- return count;
+ uint64_t x = static_cast<uint64_t>((v > 0) ? v : -v);
+ uint64_t t;
+ int r = 0;
+ if ((t = x >> 32) != 0) { x = t; r += 32; }
+ if ((t = x >> 16) != 0) { x = t; r += 16; }
+ if ((t = x >> 8) != 0) { x = t; r += 8; }
+ if ((t = x >> 4) != 0) { x = t; r += 4; }
+ if ((t = x >> 2) != 0) { x = t; r += 2; }
+ if (x > 1) r += 1;
+ return r;
}
Property changes on: runtime/platform/utils.cc
___________________________________________________________________
Deleted: svn:eol-style
- LF
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698