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

Unified Diff: runtime/vm/simulator_arm64.cc

Issue 898123002: Fix race condition in Redirection global list using CAS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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
Index: runtime/vm/simulator_arm64.cc
===================================================================
--- runtime/vm/simulator_arm64.cc (revision 43532)
+++ runtime/vm/simulator_arm64.cc (working copy)
@@ -850,7 +850,17 @@
argument_count_(argument_count),
hlt_instruction_(kRedirectInstruction),
next_(list_) {
- list_ = this;
+ // Atomically prepend this element to the front of the global list.
+ // Note: Since elements are never removed, there is no ABA issue.
+ Redirection* old_list = list_;
+ do {
+ next_ = old_list;
+ old_list = reinterpret_cast<Redirection*>(
+ AtomicOperations::CompareAndSwapWord(
+ reinterpret_cast<uword*>(&list_),
+ reinterpret_cast<uword>(next_),
+ reinterpret_cast<uword>(this)));
+ } while (old_list != next_);
}
uword external_function_;

Powered by Google App Engine
This is Rietveld 408576698