diff options
author | nikolay serdjuk <nikolay.y.serdjuk@intel.com> | 2014-07-28 17:40:16 +0700 |
---|---|---|
committer | nikolay serdjuk <nikolay.y.serdjuk@intel.com> | 2014-08-14 11:08:35 +0700 |
commit | d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc (patch) | |
tree | 3752efc80c5666d6d844ffcccf6df77683e217d3 | |
parent | e8bf3df2bcc61c12a7e66b4995a083f9ed3939e0 (diff) | |
download | art-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.tar.gz art-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.tar.bz2 art-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.zip |
ART: A couple of checks were missed in class LockWord
Change-Id: I1fc2d77f78f49741c1316ccc76b02357158dfdbe
-rw-r--r-- | runtime/lock_word-inl.h | 1 | ||||
-rw-r--r-- | runtime/lock_word.h | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lock_word-inl.h b/runtime/lock_word-inl.h index 414b3bb3e1..cf6f83cb62 100644 --- a/runtime/lock_word-inl.h +++ b/runtime/lock_word-inl.h @@ -50,6 +50,7 @@ inline LockWord::LockWord() : value_(0) { inline LockWord::LockWord(Monitor* mon) : value_(mon->GetMonitorId() | (kStateFat << kStateShift)) { DCHECK_EQ(FatLockMonitor(), mon); + DCHECK_LE(mon->GetMonitorId(), static_cast<uint32_t>(kMaxMonitorId)); } inline int32_t LockWord::GetHashCode() const { diff --git a/runtime/lock_word.h b/runtime/lock_word.h index e585412d03..13cc3b0bcb 100644 --- a/runtime/lock_word.h +++ b/runtime/lock_word.h @@ -63,6 +63,7 @@ class LockWord { kThinLockOwnerShift = 0, kThinLockOwnerMask = (1 << kThinLockOwnerSize) - 1, + kThinLockMaxOwner = kThinLockOwnerMask, // Count in higher bits. kThinLockCountShift = kThinLockOwnerSize + kThinLockOwnerShift, kThinLockCountMask = (1 << kThinLockCountSize) - 1, @@ -80,10 +81,13 @@ class LockWord { kHashShift = 0, kHashSize = 32 - kStateSize, kHashMask = (1 << kHashSize) - 1, + kMaxHash = kHashMask, + kMaxMonitorId = kMaxHash }; static LockWord FromThinLockId(uint32_t thread_id, uint32_t count) { - CHECK_LE(thread_id, static_cast<uint32_t>(kThinLockOwnerMask)); + CHECK_LE(thread_id, static_cast<uint32_t>(kThinLockMaxOwner)); + CHECK_LE(count, static_cast<uint32_t>(kThinLockMaxCount)); return LockWord((thread_id << kThinLockOwnerShift) | (count << kThinLockCountShift) | (kStateThinOrUnlocked << kStateShift)); } @@ -94,7 +98,7 @@ class LockWord { } static LockWord FromHashCode(uint32_t hash_code) { - CHECK_LE(hash_code, static_cast<uint32_t>(kHashMask)); + CHECK_LE(hash_code, static_cast<uint32_t>(kMaxHash)); return LockWord((hash_code << kHashShift) | (kStateHash << kStateShift)); } |