summaryrefslogtreecommitdiffstats
path: root/runtime/monitor_pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/monitor_pool.h')
-rw-r--r--runtime/monitor_pool.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/monitor_pool.h b/runtime/monitor_pool.h
index 27678dcbdd..8ae5a54fe7 100644
--- a/runtime/monitor_pool.h
+++ b/runtime/monitor_pool.h
@@ -45,7 +45,9 @@ class MonitorPool {
static Monitor* CreateMonitor(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_code)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
#ifndef __LP64__
- return new Monitor(self, owner, obj, hash_code);
+ Monitor* mon = new Monitor(self, owner, obj, hash_code);
+ DCHECK_ALIGNED(mon, LockWord::kMonitorIdAlignment);
+ return mon;
#else
return GetMonitorPool()->CreateMonitorInPool(self, owner, obj, hash_code);
#endif
@@ -71,7 +73,7 @@ class MonitorPool {
static Monitor* MonitorFromMonitorId(MonitorId mon_id) {
#ifndef __LP64__
- return reinterpret_cast<Monitor*>(mon_id << 3);
+ return reinterpret_cast<Monitor*>(mon_id << LockWord::kMonitorIdAlignmentShift);
#else
return GetMonitorPool()->LookupMonitor(mon_id);
#endif
@@ -79,7 +81,7 @@ class MonitorPool {
static MonitorId MonitorIdFromMonitor(Monitor* mon) {
#ifndef __LP64__
- return reinterpret_cast<MonitorId>(mon) >> 3;
+ return reinterpret_cast<MonitorId>(mon) >> LockWord::kMonitorIdAlignmentShift;
#else
return mon->GetMonitorId();
#endif