Refactor Object CAS with and without write barrier
Removes duplicated logic.
Test: test-art-host
Change-Id: I1f5df417c59312f224e0a448c7bd6358912bba07
diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h
index 5035ba0..640fa7e 100644
--- a/runtime/read_barrier-inl.h
+++ b/runtime/read_barrier-inl.h
@@ -64,8 +64,11 @@
// If kAlwaysUpdateField is true, update the field atomically. This may fail if mutator
// updates before us, but it's OK.
if (kAlwaysUpdateField && ref != old_ref) {
- obj->CasFieldStrongReleaseObjectWithoutWriteBarrier<false, false>(
- offset, old_ref, ref);
+ obj->CasFieldObjectWithoutWriteBarrier<false, false>(offset,
+ old_ref,
+ ref,
+ CASMode::kStrong,
+ std::memory_order_release);
}
}
AssertToSpaceInvariant(obj, offset, ref);
@@ -82,8 +85,11 @@
ref = reinterpret_cast<MirrorType*>(Mark(old_ref));
// Update the field atomically. This may fail if mutator updates before us, but it's ok.
if (ref != old_ref) {
- obj->CasFieldStrongReleaseObjectWithoutWriteBarrier<false, false>(
- offset, old_ref, ref);
+ obj->CasFieldObjectWithoutWriteBarrier<false, false>(offset,
+ old_ref,
+ ref,
+ CASMode::kStrong,
+ std::memory_order_release);
}
}
AssertToSpaceInvariant(obj, offset, ref);