Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Unified Diff: src/ports/SkBarriers_arm.h

Issue 381143002: Use a consume load in SkLazyPtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: compiler barrier Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkLazyPtr.h ('k') | src/ports/SkBarriers_tsan.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkBarriers_arm.h
diff --git a/src/ports/SkBarriers_arm.h b/src/ports/SkBarriers_arm.h
index 9161cddebcffb1ed0611197066351cc9c80b2db3..386294e9b1fcbde4b9583dc1471fdcc3771dbb6f 100644
--- a/src/ports/SkBarriers_arm.h
+++ b/src/ports/SkBarriers_arm.h
@@ -18,6 +18,16 @@ T sk_acquire_load(T* ptr) {
}
template <typename T>
+T sk_consume_load(T* ptr) {
+ T val = *ptr;
+ // Unlike acquire, consume loads (data-dependent loads) are guaranteed not to reorder on ARM.
+ // No memory barrier is needed, so we just use a compiler barrier.
+ // C.f. http://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/
+ sk_compiler_barrier();
+ return val;
+}
+
+template <typename T>
void sk_release_store(T* ptr, T val) {
__sync_synchronize(); // Issue a full barrier, which is an overkill release barrier.
*ptr = val;
« no previous file with comments | « src/core/SkLazyPtr.h ('k') | src/ports/SkBarriers_tsan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698