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

Unified Diff: runtime/vm/simulator_arm.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
« no previous file with comments | « no previous file | runtime/vm/simulator_arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_arm.cc
===================================================================
--- runtime/vm/simulator_arm.cc (revision 43532)
+++ runtime/vm/simulator_arm.cc (working copy)
@@ -811,9 +811,18 @@
: external_function_(external_function),
call_kind_(call_kind),
argument_count_(argument_count),
- svc_instruction_(Instr::kSimulatorRedirectInstruction),
- next_(list_) {
- list_ = this;
+ svc_instruction_(Instr::kSimulatorRedirectInstruction) {
+ // 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;
Cutch 2015/02/06 00:47:10 consider renaming "old_list" to "list_head".
koda 2015/02/06 15:50:22 Done.
+ 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_;
« no previous file with comments | « no previous file | runtime/vm/simulator_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698