summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornikolay serdjuk <nikolay.y.serdjuk@intel.com>2014-07-28 17:40:16 +0700
committernikolay serdjuk <nikolay.y.serdjuk@intel.com>2014-08-14 11:08:35 +0700
commitd8481ccad5b33aa9783cd8f7c614ee083a4f1ccc (patch)
tree3752efc80c5666d6d844ffcccf6df77683e217d3
parente8bf3df2bcc61c12a7e66b4995a083f9ed3939e0 (diff)
downloadart-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.zip
art-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.tar.gz
art-d8481ccad5b33aa9783cd8f7c614ee083a4f1ccc.tar.bz2
ART: A couple of checks were missed in class LockWord
Change-Id: I1fc2d77f78f49741c1316ccc76b02357158dfdbe
-rw-r--r--runtime/lock_word-inl.h1
-rw-r--r--runtime/lock_word.h8
2 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lock_word-inl.h b/runtime/lock_word-inl.h
index 414b3bb..cf6f83c 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 e585412..13cc3b0 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));
}