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

Unified Diff: runtime/platform/utils.h

Issue 712993005: Infer range for BIT_XOR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/utils.h
diff --git a/runtime/platform/utils.h b/runtime/platform/utils.h
index a46db44cb79a5f7c4668b85d827f704c91233172..8eff2f47062049572ef32b983763daa8f6f04343 100644
--- a/runtime/platform/utils.h
+++ b/runtime/platform/utils.h
@@ -81,6 +81,12 @@ class Utils {
static int HighestBit(int64_t v);
+ static int BitLength(int64_t value) {
+ // Flip bits if negative (-1 becomes 0).
+ value ^= value >> (8 * sizeof(value) - 1);
+ return (value == 0) ? 0 : (Utils::HighestBit(value) + 1);
+ }
+
static int CountLeadingZeros(uword x);
static int CountTrailingZeros(uword x);
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/vm/flow_graph_compiler_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698