summaryrefslogtreecommitdiffstats
path: root/runtime/mirror/object.h
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2014-07-11 09:56:07 -0700
committerHans Boehm <hboehm@google.com>2014-07-11 16:50:37 -0700
commitd8434439dc64add41cdfa69ddf96b960af9050de (patch)
treef1d90394dc3b11fd80397ff702413c8710cf1a65 /runtime/mirror/object.h
parent3d71f321f4b87ba13113dc0457fd9c3470a2b380 (diff)
downloadart-d8434439dc64add41cdfa69ddf96b960af9050de.tar.gz
art-d8434439dc64add41cdfa69ddf96b960af9050de.tar.bz2
art-d8434439dc64add41cdfa69ddf96b960af9050de.zip
Call strong CAS from unsafe. Add more CAS versions.
Adds a number of additional CAS versions. Calls the correct one from sun.misc.unsafe, fixing a recently introduced bug. Avoid unnecessary ordering constraint when installing hash code. Change-Id: I7c09d0c95ceb2a549ec28ee34084198ab3107946
Diffstat (limited to 'runtime/mirror/object.h')
-rw-r--r--runtime/mirror/object.h35
1 files changed, 27 insertions, 8 deletions
diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h
index d29011a4b5..bf952f28d2 100644
--- a/runtime/mirror/object.h
+++ b/runtime/mirror/object.h
@@ -99,19 +99,14 @@ class MANAGED LOCKABLE Object {
return OFFSET_OF_OBJECT_MEMBER(Object, monitor_);
}
- // As volatile can be false if the mutators are suspended. This is an optimization since it
+ // As_volatile can be false if the mutators are suspended. This is an optimization since it
// avoids the barriers.
LockWord GetLockWord(bool as_volatile) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void SetLockWord(LockWord new_val, bool as_volatile) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
- // All Cas operations defined here have C++11 memory_order_seq_cst ordering
- // semantics: Preceding memory operations become visible to other threads
- // before the CAS, and subsequent operations become visible after the CAS.
- // The Cas operations defined here do not fail spuriously, i.e. they
- // have C++11 "strong" semantics.
- // TODO: In most, possibly all, cases, these assumptions are too strong.
- // Confirm and weaken the implementation.
bool CasLockWordWeakSequentiallyConsistent(LockWord old_val, LockWord new_val)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ bool CasLockWordWeakRelaxed(LockWord old_val, LockWord new_val)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
uint32_t GetLockOwnerThreadId();
mirror::Object* MonitorEnter(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
@@ -231,6 +226,12 @@ class MANAGED LOCKABLE Object {
Object* new_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ template<bool kTransactionActive, bool kCheckTransaction = true,
+ VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+ bool CasFieldStrongSequentiallyConsistentObject(MemberOffset field_offset, Object* old_value,
+ Object* new_value)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
HeapReference<Object>* GetFieldObjectReferenceAddr(MemberOffset field_offset);
@@ -258,6 +259,18 @@ class MANAGED LOCKABLE Object {
int32_t new_value) ALWAYS_INLINE
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+ template<bool kTransactionActive, bool kCheckTransaction = true,
+ VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+ bool CasFieldWeakRelaxed32(MemberOffset field_offset, int32_t old_value,
+ int32_t new_value) ALWAYS_INLINE
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+ template<bool kTransactionActive, bool kCheckTransaction = true,
+ VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+ bool CasFieldStrongSequentiallyConsistent32(MemberOffset field_offset, int32_t old_value,
+ int32_t new_value) ALWAYS_INLINE
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, bool kIsVolatile = false>
int64_t GetField64(MemberOffset field_offset) ALWAYS_INLINE
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
@@ -283,6 +296,12 @@ class MANAGED LOCKABLE Object {
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
template<bool kTransactionActive, bool kCheckTransaction = true,
+ VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
+ bool CasFieldStrongSequentiallyConsistent64(MemberOffset field_offset, int64_t old_value,
+ int64_t new_value)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+
+ template<bool kTransactionActive, bool kCheckTransaction = true,
VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags, typename T>
void SetFieldPtr(MemberOffset field_offset, T new_value)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {