summaryrefslogtreecommitdiffstats
path: root/runtime/lock_word-inl.h
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2013-10-25 10:05:23 -0700
committerMathieu Chartier <mathieuc@google.com>2013-10-29 12:14:36 -0700
commitad2541a59c00c2c69e8973088891a2b5257c9780 (patch)
tree523898cf039c5185352978e71a54fa3a2657a04c /runtime/lock_word-inl.h
parent9780099e445884d8bc9444c8c1261b02d80a26c7 (diff)
downloadandroid_art-ad2541a59c00c2c69e8973088891a2b5257c9780.tar.gz
android_art-ad2541a59c00c2c69e8973088891a2b5257c9780.tar.bz2
android_art-ad2541a59c00c2c69e8973088891a2b5257c9780.zip
Fix object identity hash.
The object identity hash is now stored in the monitor word after being computed. Hashes are computed by a pseudo random number generator. When we write the image, we eagerly compute object hashes to prevent pages getting dirtied. Bug: 8981901 Change-Id: Ic8edacbacb0afc7055fd740a52444929f88ed564
Diffstat (limited to 'runtime/lock_word-inl.h')
-rw-r--r--runtime/lock_word-inl.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lock_word-inl.h b/runtime/lock_word-inl.h
index 30bf9bbaa6..59947f5694 100644
--- a/runtime/lock_word-inl.h
+++ b/runtime/lock_word-inl.h
@@ -33,7 +33,7 @@ inline uint32_t LockWord::ThinLockCount() const {
inline Monitor* LockWord::FatLockMonitor() const {
DCHECK_EQ(GetState(), kFatLocked);
- return reinterpret_cast<Monitor*>(value_ << 1);
+ return reinterpret_cast<Monitor*>(value_ << kStateSize);
}
inline LockWord::LockWord() : value_(0) {
@@ -41,10 +41,15 @@ inline LockWord::LockWord() : value_(0) {
}
inline LockWord::LockWord(Monitor* mon)
- : value_((reinterpret_cast<uint32_t>(mon) >> 1) | (kStateFat << kStateShift)) {
+ : value_((reinterpret_cast<uint32_t>(mon) >> kStateSize) | (kStateFat << kStateShift)) {
DCHECK_EQ(FatLockMonitor(), mon);
}
+inline uint32_t LockWord::GetHashCode() const {
+ DCHECK_EQ(GetState(), kHashCode);
+ return (value_ >> kHashShift) & kHashMask;
+}
+
} // namespace art
#endif // ART_RUNTIME_LOCK_WORD_INL_H_