ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
diff --git a/cmdline/memory_representation.h b/cmdline/memory_representation.h
index 93387de..2619c31 100644
--- a/cmdline/memory_representation.h
+++ b/cmdline/memory_representation.h
@@ -20,24 +20,25 @@
 #include <string>
 #include <assert.h>
 #include <ostream>
-#include "utils.h"
+
+#include "base/bit_utils.h"
 
 namespace art {
 
 // An integral representation of bytes of memory.
 // The underlying runtime size_t value is guaranteed to be a multiple of Divisor.
-template <size_t Divisor = 1024>
+template <size_t kDivisor = 1024>
 struct Memory {
-  static_assert(IsPowerOfTwo(Divisor), "Divisor must be a power of 2");
+  static_assert(IsPowerOfTwo(kDivisor), "Divisor must be a power of 2");
 
-  static Memory<Divisor> FromBytes(size_t bytes) {
-    assert(bytes % Divisor == 0);
-    return Memory<Divisor>(bytes);
+  static Memory<kDivisor> FromBytes(size_t bytes) {
+    assert(bytes % kDivisor == 0);
+    return Memory<kDivisor>(bytes);
   }
 
   Memory() : Value(0u) {}
   Memory(size_t value) : Value(value) {  // NOLINT [runtime/explicit] [5]
-    assert(value % Divisor == 0);
+    assert(value % kDivisor == 0);
   }
   operator size_t() const { return Value; }
 
@@ -45,12 +46,10 @@
     return Value;
   }
 
-  static constexpr size_t kDivisor = Divisor;
-
   static const char* Name() {
     static std::string str;
     if (str.empty()) {
-      str = "Memory<" + std::to_string(Divisor) + '>';
+      str = "Memory<" + std::to_string(kDivisor) + '>';
     }
 
     return str.c_str();
@@ -59,9 +58,9 @@
   size_t Value;
 };
 
-template <size_t Divisor>
-std::ostream& operator<<(std::ostream& stream, Memory<Divisor> memory) {
-  return stream << memory.Value << '*' << Divisor;
+template <size_t kDivisor>
+std::ostream& operator<<(std::ostream& stream, Memory<kDivisor> memory) {
+  return stream << memory.Value << '*' << kDivisor;
 }
 
 using MemoryKiB = Memory<1024>;