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); |