From fdd513d6c522841e82f1dc144d19a8d60269b9f7 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 1 Jun 2017 11:26:50 -0700 Subject: Move to release CAS for updating object fields Relaxed cas is not sufficient to make sure threads that read the field will see the copied contents of objects. Bug: 37187694 Bug: 62240510 Test: test-art-host (cherry picked from commit a1f20c3f8d0dabb9723acccf3ba760acf3ebe62d) Change-Id: I8bff8a67c2c52eb131714b52e6d842c8c08dd70a --- runtime/class_table-inl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/class_table-inl.h') diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index dfe8949134..35fce4063b 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -93,7 +93,7 @@ inline mirror::Class* ClassTable::TableSlot::Read() const { if (kReadBarrierOption != kWithoutReadBarrier && before_ptr != after_ptr) { // If another thread raced and updated the reference, do not store the read barrier updated // one. - data_.CompareExchangeStrongRelaxed(before, Encode(after_ptr, MaskHash(before))); + data_.CompareExchangeStrongRelease(before, Encode(after_ptr, MaskHash(before))); } return after_ptr.Ptr(); } @@ -108,7 +108,7 @@ inline void ClassTable::TableSlot::VisitRoot(const Visitor& visitor) const { if (before_ptr != after_ptr) { // If another thread raced and updated the reference, do not store the read barrier updated // one. - data_.CompareExchangeStrongRelaxed(before, Encode(after_ptr, MaskHash(before))); + data_.CompareExchangeStrongRelease(before, Encode(after_ptr, MaskHash(before))); } } -- cgit v1.2.3-59-g8ed1b