Always log the value when an alignment check fails.

And move checking that the alignment is a power of two to compile-time.

Change-Id: I551f364af05912958ed2d4d095b1ce35b6abaf6e
diff --git a/src/utils.h b/src/utils.h
index 35b350b..dd597e9 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -25,17 +25,23 @@
   return (x & (x - 1)) == 0;
 }
 
-template<typename T>
-static inline bool IsAligned(T x, int n) {
-  CHECK(IsPowerOfTwo(n));
+template<int n, typename T>
+static inline bool IsAligned(T x) {
+  COMPILE_ASSERT((n & (n - 1)) == 0, n_not_power_of_two);
   return (x & (n - 1)) == 0;
 }
 
-template<typename T>
-static inline bool IsAligned(T* x, int n) {
-  return IsAligned(reinterpret_cast<uintptr_t>(x), n);
+template<int n, typename T>
+static inline bool IsAligned(T* x) {
+  return IsAligned<n>(reinterpret_cast<uintptr_t>(x));
 }
 
+#define CHECK_ALIGNED(value, alignment) \
+  CHECK(::art::IsAligned<alignment>(value)) << reinterpret_cast<void*>(value)
+
+#define DCHECK_ALIGNED(value, alignment) \
+  DCHECK(::art::IsAligned<alignment>(value)) << reinterpret_cast<void*>(value)
+
 // Check whether an N-bit two's-complement representation can hold value.
 static inline bool IsInt(int N, word value) {
   CHECK_LT(0, N);