Lazily compute object identity hash codes.

Before, we computed identity hashcodes whenever we inflated a monitor.
This caused issues since it meant that we would have all of these
hash codes in the image, causing locks to excessively inflate during
application run time.

This change makes it so that we lazily compute hash codes. When a
thin lock gets inflated, we assign a hash code of 0 assigned to it.
This value signifies no hash code. When we try to get the identity
hash code of an object with an inflated monitor, it gets computed if
it is 0.

Change-Id: Iae6acd1960515a36e74644e5b1323ff336731806
diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc
index 49bad4c..bd187c1 100644
--- a/runtime/mirror/object.cc
+++ b/runtime/mirror/object.cc
@@ -84,14 +84,14 @@
   return copy.get();
 }
 
-uint32_t Object::GenerateIdentityHashCode() {
+int32_t Object::GenerateIdentityHashCode() {
   static AtomicInteger seed(987654321 + std::time(nullptr));
-  uint32_t expected_value, new_value;
+  int32_t expected_value, new_value;
   do {
     expected_value = static_cast<uint32_t>(seed.load());
     new_value = expected_value * 1103515245 + 12345;
-  } while (!seed.compare_and_swap(static_cast<int32_t>(expected_value),
-                                  static_cast<int32_t>(new_value)));
+  } while ((expected_value & LockWord::kHashMask) == 0 ||
+      !seed.compare_and_swap(expected_value, new_value));
   return expected_value & LockWord::kHashMask;
 }