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

Unified Diff: runtime/vm/atomic_win.h

Issue 1277473004: Safe and efficient stack-limit based interrupt checking in C++. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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/vm/atomic_linux.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/atomic_win.h
diff --git a/runtime/vm/atomic_win.h b/runtime/vm/atomic_win.h
index 24be3b12c8bc33573215d4fe583a94fa22482974..ccec5278351f366388ad60ec6b1ab0cfad81526a 100644
--- a/runtime/vm/atomic_win.h
+++ b/runtime/vm/atomic_win.h
@@ -28,6 +28,19 @@ inline uintptr_t AtomicOperations::FetchAndIncrement(uintptr_t* p) {
}
+inline intptr_t AtomicOperations::FetchAndAdd(intptr_t* p, intptr_t delta) {
+#if defined(TARGET_ARCH_X64)
+ return static_cast<intptr_t>(
+ InterlockedAdd64(reinterpret_cast<LONGLONG*>(p), delta)) - 1;
Ivan Posva 2015/08/07 20:55:46 What does the -1 mean here?
koda 2015/08/07 21:05:22 Fixed to 'delta' (InterlockedAdd returns the value
+#elif defined(TARGET_ARCH_IA32)
+ return static_cast<intptr_t>(
+ InterlockedAdd(reinterpret_cast<LONG*>(p), delta)) - 1;
+#else
+ UNIMPLEMENTED();
+#endif
+}
+
+
#if !defined(USING_SIMULATOR)
inline uword AtomicOperations::CompareAndSwapWord(uword* ptr,
uword old_value,
@@ -48,6 +61,13 @@ inline uword AtomicOperations::CompareAndSwapWord(uword* ptr,
}
#endif // !defined(USING_SIMULATOR)
+
+inline uword AtomicOperations::LoadRelaxed(uword* ptr) {
+ // TODO(koda): Consider using C++11 <atomic> to avoid the barrier on more
+ // compilers/platforms.
+ return FetchAndAdd(reinterpret_cast<intptr_t*>(ptr), 0);
+}
+
} // namespace dart
#endif // VM_ATOMIC_WIN_H_
« no previous file with comments | « runtime/vm/atomic_linux.h ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698