summaryrefslogtreecommitdiffstats
path: root/runtime/monitor.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/monitor.h
parent9780099e445884d8bc9444c8c1261b02d80a26c7 (diff)
downloadart-ad2541a59c00c2c69e8973088891a2b5257c9780.zip
art-ad2541a59c00c2c69e8973088891a2b5257c9780.tar.gz
art-ad2541a59c00c2c69e8973088891a2b5257c9780.tar.bz2
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/monitor.h')
-rw-r--r--runtime/monitor.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/runtime/monitor.h b/runtime/monitor.h
index 27124a2..c464400 100644
--- a/runtime/monitor.h
+++ b/runtime/monitor.h
@@ -88,8 +88,7 @@ class Monitor {
static bool IsValidLockWord(LockWord lock_word);
- // TODO: SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- mirror::Object* GetObject() const {
+ mirror::Object* GetObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
return obj_;
}
@@ -99,8 +98,17 @@ class Monitor {
return owner_;
}
+ int32_t GetHashCode() const {
+ return hash_code_;
+ }
+
+ bool IsLocked() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+ static void InflateThinLocked(Thread* self, mirror::Object* obj, LockWord lock_word,
+ uint32_t hash_code) NO_THREAD_SAFETY_ANALYSIS;
+
private:
- explicit Monitor(Thread* owner, mirror::Object* obj)
+ explicit Monitor(Thread* owner, mirror::Object* obj, uint32_t hash_code)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Install the monitor into its object, may fail if another thread installs a different monitor
@@ -112,7 +120,7 @@ class Monitor {
void AppendToWaitSet(Thread* thread) EXCLUSIVE_LOCKS_REQUIRED(monitor_lock_);
void RemoveFromWaitSet(Thread* thread) EXCLUSIVE_LOCKS_REQUIRED(monitor_lock_);
- static void Inflate(Thread* self, Thread* owner, mirror::Object* obj)
+ static void Inflate(Thread* self, Thread* owner, mirror::Object* obj, int32_t hash_code)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void LogContentionEvent(Thread* self, uint32_t wait_ms, uint32_t sample_percent,
@@ -171,6 +179,9 @@ class Monitor {
// Threads currently waiting on this monitor.
Thread* wait_set_ GUARDED_BY(monitor_lock_);
+ // Stored object hash code, always generated.
+ const uint32_t hash_code_;
+
// Method and dex pc where the lock owner acquired the lock, used when lock
// sampling is enabled. locking_method_ may be null if the lock is currently
// unlocked, or if the lock is acquired by the system when the stack is empty.
@@ -190,7 +201,7 @@ class MonitorList {
void Add(Monitor* m);
- void SweepMonitorList(RootVisitor visitor, void* arg);
+ void SweepMonitorList(RootVisitor visitor, void* arg) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void DisallowNewMonitors();
void AllowNewMonitors();