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

Unified Diff: runtime/vm/atomic.h

Issue 1287853005: Compatible atomics: volatile for LoadRelaxed, replace FetchAndAdd with FetchAndDecrement. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Additional comments. Created 5 years, 4 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 | « runtime/tests/vm/vm.status ('k') | runtime/vm/atomic_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/atomic.h
diff --git a/runtime/vm/atomic.h b/runtime/vm/atomic.h
index 769aad67ae4106596dcac56018bc3282cbd7d78c..9d1fd1375fa3bca49a9250cd0e9e9893b1fefc83 100644
--- a/runtime/vm/atomic.h
+++ b/runtime/vm/atomic.h
@@ -21,14 +21,23 @@ class AtomicOperations : public AllStatic {
// that are accessed by generated code
static uintptr_t FetchAndIncrement(uintptr_t* p);
- static intptr_t FetchAndAdd(intptr_t* p, intptr_t delta);
+ // Atomically fetch the value at p and decrement the value at p.
+ // Returns the original value at p.
+ //
+ // NOTE: Not to be used for any atomic operations involving memory locations
+ // that are accessed by generated code
+ static uintptr_t FetchAndDecrement(uintptr_t* p);
+ // Atomically compare *ptr to old_value, and if equal, store new_value.
+ // Returns the original value at ptr.
+ //
+ // NOTE: OK to use with memory locations that are accessed by generated code
static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value);
+ // Performs a load of a word from 'ptr', but without any guarantees about
+ // memory order (i.e., no load barriers/fences).
static uword LoadRelaxed(uword* ptr) {
- uword result;
- memcpy(&result, ptr, sizeof(result));
- return result;
+ return *static_cast<volatile uword*>(ptr);
}
};
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | runtime/vm/atomic_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698