diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2015-02-09 17:11:42 -0800 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2015-03-03 17:33:18 -0800 |
commit | e15ea086439b41a805d164d2beb07b4ba96aaa97 (patch) | |
tree | 465ee3780acd8b7cb35c8a7f42a1f3c5df3d26ec /runtime/lock_word-inl.h | |
parent | 0b25c71ac93fb10c484dbacb9e23db505a8e2353 (diff) | |
download | android_art-e15ea086439b41a805d164d2beb07b4ba96aaa97.tar.gz android_art-e15ea086439b41a805d164d2beb07b4ba96aaa97.tar.bz2 android_art-e15ea086439b41a805d164d2beb07b4ba96aaa97.zip |
Reserve bits in the lock word for read barriers.
This prepares for the CC collector to use the standard object header
model by storing the read barrier state in the lock word.
Bug: 19355854
Bug: 12687968
Change-Id: Ia7585662dd2cebf0479a3e74f734afe5059fb70f
Diffstat (limited to 'runtime/lock_word-inl.h')
-rw-r--r-- | runtime/lock_word-inl.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/lock_word-inl.h b/runtime/lock_word-inl.h index c52578f8a2..d831bfbee2 100644 --- a/runtime/lock_word-inl.h +++ b/runtime/lock_word-inl.h @@ -24,17 +24,20 @@ namespace art { inline uint32_t LockWord::ThinLockOwner() const { DCHECK_EQ(GetState(), kThinLocked); + CheckReadBarrierState(); return (value_ >> kThinLockOwnerShift) & kThinLockOwnerMask; } inline uint32_t LockWord::ThinLockCount() const { DCHECK_EQ(GetState(), kThinLocked); + CheckReadBarrierState(); return (value_ >> kThinLockCountShift) & kThinLockCountMask; } inline Monitor* LockWord::FatLockMonitor() const { DCHECK_EQ(GetState(), kFatLocked); - MonitorId mon_id = value_ & ~(kStateMask << kStateShift); + CheckReadBarrierState(); + MonitorId mon_id = (value_ >> kMonitorIdShift) & kMonitorIdMask; return MonitorPool::MonitorFromMonitorId(mon_id); } @@ -47,14 +50,20 @@ inline LockWord::LockWord() : value_(0) { DCHECK_EQ(GetState(), kUnlocked); } -inline LockWord::LockWord(Monitor* mon) - : value_(mon->GetMonitorId() | (kStateFat << kStateShift)) { +inline LockWord::LockWord(Monitor* mon, uint32_t rb_state) + : value_(mon->GetMonitorId() | (rb_state << kReadBarrierStateShift) | + (kStateFat << kStateShift)) { +#ifndef __LP64__ + DCHECK_ALIGNED(mon, kMonitorIdAlignment); +#endif DCHECK_EQ(FatLockMonitor(), mon); DCHECK_LE(mon->GetMonitorId(), static_cast<uint32_t>(kMaxMonitorId)); + CheckReadBarrierState(); } inline int32_t LockWord::GetHashCode() const { DCHECK_EQ(GetState(), kHashCode); + CheckReadBarrierState(); return (value_ >> kHashShift) & kHashMask; } |