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

Unified Diff: runtime/vm/simulator_mips.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
« runtime/vm/simulator_arm.cc ('K') | « runtime/vm/simulator_arm64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_mips.cc
===================================================================
--- runtime/vm/simulator_mips.cc (revision 43532)
+++ runtime/vm/simulator_mips.cc (working copy)
@@ -795,7 +795,17 @@
argument_count_(argument_count),
break_instruction_(Instr::kSimulatorRedirectInstruction),
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_;
« runtime/vm/simulator_arm.cc ('K') | « runtime/vm/simulator_arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698