summaryrefslogtreecommitdiff
path: root/runtime/mirror/object.h
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2023-04-10 23:25:19 +0000
committer Hans Boehm <hboehm@google.com> 2023-08-14 13:47:49 -0700
commit2caa640269faabd2455ec29cfe6ad330d442b715 (patch)
treeda8f0aa24a829573c51c4c0abedd9b567586265e /runtime/mirror/object.h
parent15de3b7e4f69d0d9b7cea3c8f06d6aafad6de0f3 (diff)
Revert^10 "Thread suspension cleanup and deadlock fix"""
This reverts commit 63af30b8fe8d4e1dc32db4dcb5e5dae1efdc7f31. master (aosp/2530206) PS1 is identical to aosp/2377951 . master (aosp/2530206) PS2 is a rebase. At this point, master branch was replaced by main, and this CL moved. PS1: Restructure documentation for the IncrementSuspendCount handshake to install a suspend barrier. Document a couple of additional mutator lock assumptions. Add some DCHECKs to check that suspended threads really are suspended. Weaken seq_cst memory order in a couple of places where it really didn't make sense here. Clearly not a correctness fix. Includes a rebase and merge with aosp/2587606. PS2: Another rebase. Fix thumb assembler test to compensate for Thread structure layout changes. PS3: Messy rebase, primarily to handle aosp/2670108, which included both new fixes around this and a few small snippets of this CL. Call EnsureFlipFunctionStarted without a state-and-flags argument only when we actually hold the mutator lock, as promised. PS4: Minor rebase, some lint fixes. PS5: Another minor lint fix that I had missed in PS4. PS6: Fix for RunCheckpoint bug introduced around PS3. Fix expectations in jni_cfi_test to compensate for thread structure layout changes. PS7: In PS3+, EnsureFlipFunctionStarted could access a destroyed "this" thread. Fix that, and make the function static to make this constraint more explicit. (And running a method on a potentially destroyed object just seemed unclean.) PS8: Address reviewer comments. The major issue was that we released the suspend_count_lock too early in FlipThreadRoots, potentially allowing an intervening SuspendAll to block us. The fix involved a very minor extention of the mutex API. PS9: Comment typo fix. PS10: Address new reviewer comments. Rebase. MUST_SLEEP for 129_ThreadGetId debug output. Test: Treehugger. Bug: 240742796 Bug: 203363895 Bug: 238032384 Bug: 253671779 Bug: 276660630 (and more) Change-Id: I0f2450e394c03c17eece3698286b2f3e45727967
Diffstat (limited to 'runtime/mirror/object.h')
-rw-r--r--runtime/mirror/object.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index 95b9f86a4b..5e770f45a5 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -137,11 +137,16 @@ class MANAGED LOCKABLE Object {
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Roles::uninterruptible_);
+ // Returns a nonzero value that fits into lockword slot.
int32_t IdentityHashCode()
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!Locks::thread_list_lock_,
!Locks::thread_suspend_count_lock_);
+ // Identical to the above, but returns 0 if monitor inflation would otherwise be needed.
+ int32_t IdentityHashCodeNoInflation() REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
+
static constexpr MemberOffset MonitorOffset() {
return OFFSET_OF_OBJECT_MEMBER(Object, monitor_);
}
@@ -726,6 +731,10 @@ class MANAGED LOCKABLE Object {
REQUIRES_SHARED(Locks::mutator_lock_);
private:
+ template <bool kAllowInflation>
+ int32_t IdentityHashCodeHelper() REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(!Locks::thread_list_lock_, !Locks::thread_suspend_count_lock_);
+
// Get a field with acquire semantics.
template<typename kSize>
ALWAYS_INLINE kSize GetFieldAcquire(MemberOffset field_offset)