Shrink ART Mutex exclusive_owner_ field to Atomic<pid_t>
The old volatile uint64_t version had a data race, and was thus
technically incorrect. Since it's unclear whether volatile uint64_t
updates are actually atomic on 32-bit platforms, even the informal
correctness argument here already effectively assumed that the upper
32 bits were zero. Don't store them. Explicitly complain if a pid_t
might be too big to support lock-free atomic operations.
Remove many explicit references to exclusive_owner to avoid
littering the code with LoadRelaxed calls.
The return convention for GetExclusiveOwnerTid() was unclear
for the shared ownership case. It was previously treated
inconsistently as 0 (pthread locks), (uint64_t)(-1U) and
(uint64_t)(-1). Make it as consistent as easily possible, and
document remaining weirdness.
Bug: 65171052
Test: AOSP builds. Host tests pass.
Change-Id: Ia99aca268952597a90b3c798b714cddbdc2c365e
diff --git a/runtime/thread.h b/runtime/thread.h
index ad4506e..59c4fa9 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -838,7 +838,7 @@
// Is the given obj in this thread's stack indirect reference table?
bool HandleScopeContains(jobject obj) const;
- void HandleScopeVisitRoots(RootVisitor* visitor, uint32_t thread_id)
+ void HandleScopeVisitRoots(RootVisitor* visitor, pid_t thread_id)
REQUIRES_SHARED(Locks::mutator_lock_);
BaseHandleScope* GetTopHandleScope() {