summaryrefslogtreecommitdiffstats
path: root/runtime/thread-inl.h
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2013-10-01 19:45:43 -0700
committerIan Rogers <irogers@google.com>2013-10-02 09:31:55 -0700
commitd9c4fc94fa618617f94e1de9af5f034549100753 (patch)
tree1305efbbc3d4bc306c0947bb6d4b01553667f98e /runtime/thread-inl.h
parent7ef126ce0593929bcf8fb73d8b1119ce3b95b3f2 (diff)
downloadart-d9c4fc94fa618617f94e1de9af5f034549100753.tar.gz
art-d9c4fc94fa618617f94e1de9af5f034549100753.tar.bz2
art-d9c4fc94fa618617f94e1de9af5f034549100753.zip
Inflate contended lock word by suspending owner.
Bug 6961405. Don't inflate monitors for Notify and NotifyAll. Tidy lock word, handle recursive lock case alongside unlocked case and move assembly out of line (except for ARM quick). Also handle null in out-of-line assembly as the test is quick and the enter/exit code is already a safepoint. To gain ownership of a monitor on behalf of another thread, monitor contenders must not hold the monitor_lock_, so they wait on a condition variable. Reduce size of per mutex contention log. Be consistent in calling thin lock thread ids just thread ids. Fix potential thread death races caused by the use of FindThreadByThreadId, make it invariant that returned threads are either self or suspended now. Code size reduction on ARM boot.oat 0.2%. Old nexus 7 speedup 0.25%, new nexus 7 speedup 1.4%, nexus 10 speedup 2.24%, nexus 4 speedup 2.09% on DeltaBlue. Change-Id: Id52558b914f160d9c8578fdd7fc8199a9598576a
Diffstat (limited to 'runtime/thread-inl.h')
-rw-r--r--runtime/thread-inl.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index 4552062319..7d28785f58 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -80,17 +80,16 @@ inline void Thread::TransitionFromRunnableToSuspended(ThreadState new_state) {
union StateAndFlags new_state_and_flags;
do {
old_state_and_flags = state_and_flags_;
+ if (UNLIKELY((old_state_and_flags.as_struct.flags & kCheckpointRequest) != 0)) {
+ RunCheckpointFunction();
+ continue;
+ }
// Copy over flags and try to clear the checkpoint bit if it is set.
new_state_and_flags.as_struct.flags = old_state_and_flags.as_struct.flags & ~kCheckpointRequest;
new_state_and_flags.as_struct.state = new_state;
// CAS the value without a memory barrier, that will occur in the unlock below.
} while (UNLIKELY(android_atomic_cas(old_state_and_flags.as_int, new_state_and_flags.as_int,
&state_and_flags_.as_int) != 0));
- // If we toggled the checkpoint flag we must have cleared it.
- uint16_t flag_change = new_state_and_flags.as_struct.flags ^ old_state_and_flags.as_struct.flags;
- if (UNLIKELY((flag_change & kCheckpointRequest) != 0)) {
- RunCheckpointFunction();
- }
// Release share on mutator_lock_.
Locks::mutator_lock_->SharedUnlock(this);
}