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

Unified Diff: runtime/vm/simulator_arm64.cc

Issue 1562253002: Add a CompareAndSwapUint32 variant to AtomicOperations so that it is possible to a CAS of a 32 bit … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/simulator_arm64.h ('k') | runtime/vm/simulator_mips.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/simulator_arm64.cc
diff --git a/runtime/vm/simulator_arm64.cc b/runtime/vm/simulator_arm64.cc
index 0f1ed5694e153460f36c87c15f59e4971984be03..e0df11546be4f5d119074b5d8042f3368973bee6 100644
--- a/runtime/vm/simulator_arm64.cc
+++ b/runtime/vm/simulator_arm64.cc
@@ -1253,6 +1253,26 @@ uword Simulator::CompareExchange(uword* address,
}
+uint32_t Simulator::CompareExchangeUint32(uint32_t* address,
+ uint32_t compare_value,
+ uint32_t new_value) {
+ MutexLocker ml(exclusive_access_lock_);
+ // We do not get a reservation as it would be guaranteed to be found when
+ // writing below. No other thread is able to make a reservation while we
+ // hold the lock.
+ uint32_t value = *address;
+ if (value == compare_value) {
+ *address = new_value;
+ // Same effect on exclusive access state as a successful STREX.
+ HasExclusiveAccessAndOpen(reinterpret_cast<uword>(address));
+ } else {
+ // Same effect on exclusive access state as an LDREX.
+ SetExclusiveAccess(reinterpret_cast<uword>(address));
+ }
+ return value;
+}
+
+
// Unsupported instructions use Format to print an error and stop execution.
void Simulator::Format(Instr* instr, const char* format) {
OS::Print("Simulator found unsupported instruction:\n 0x%p: %s\n",
« no previous file with comments | « runtime/vm/simulator_arm64.h ('k') | runtime/vm/simulator_mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698