OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #if defined(TARGET_ARCH_ARM64) | 9 #if defined(TARGET_ARCH_ARM64) |
10 | 10 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 // Same effect on exclusive access state as a successful STREX. | 1246 // Same effect on exclusive access state as a successful STREX. |
1247 HasExclusiveAccessAndOpen(reinterpret_cast<uword>(address)); | 1247 HasExclusiveAccessAndOpen(reinterpret_cast<uword>(address)); |
1248 } else { | 1248 } else { |
1249 // Same effect on exclusive access state as an LDREX. | 1249 // Same effect on exclusive access state as an LDREX. |
1250 SetExclusiveAccess(reinterpret_cast<uword>(address)); | 1250 SetExclusiveAccess(reinterpret_cast<uword>(address)); |
1251 } | 1251 } |
1252 return value; | 1252 return value; |
1253 } | 1253 } |
1254 | 1254 |
1255 | 1255 |
| 1256 uint32_t Simulator::CompareExchangeUint32(uint32_t* address, |
| 1257 uint32_t compare_value, |
| 1258 uint32_t new_value) { |
| 1259 MutexLocker ml(exclusive_access_lock_); |
| 1260 // We do not get a reservation as it would be guaranteed to be found when |
| 1261 // writing below. No other thread is able to make a reservation while we |
| 1262 // hold the lock. |
| 1263 uint32_t value = *address; |
| 1264 if (value == compare_value) { |
| 1265 *address = new_value; |
| 1266 // Same effect on exclusive access state as a successful STREX. |
| 1267 HasExclusiveAccessAndOpen(reinterpret_cast<uword>(address)); |
| 1268 } else { |
| 1269 // Same effect on exclusive access state as an LDREX. |
| 1270 SetExclusiveAccess(reinterpret_cast<uword>(address)); |
| 1271 } |
| 1272 return value; |
| 1273 } |
| 1274 |
| 1275 |
1256 // Unsupported instructions use Format to print an error and stop execution. | 1276 // Unsupported instructions use Format to print an error and stop execution. |
1257 void Simulator::Format(Instr* instr, const char* format) { | 1277 void Simulator::Format(Instr* instr, const char* format) { |
1258 OS::Print("Simulator found unsupported instruction:\n 0x%p: %s\n", | 1278 OS::Print("Simulator found unsupported instruction:\n 0x%p: %s\n", |
1259 instr, | 1279 instr, |
1260 format); | 1280 format); |
1261 UNIMPLEMENTED(); | 1281 UNIMPLEMENTED(); |
1262 } | 1282 } |
1263 | 1283 |
1264 | 1284 |
1265 // Calculate and set the Negative and Zero flags. | 1285 // Calculate and set the Negative and Zero flags. |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3536 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3556 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
3537 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3557 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
3538 buf->Longjmp(); | 3558 buf->Longjmp(); |
3539 } | 3559 } |
3540 | 3560 |
3541 } // namespace dart | 3561 } // namespace dart |
3542 | 3562 |
3543 #endif // !defined(USING_SIMULATOR) | 3563 #endif // !defined(USING_SIMULATOR) |
3544 | 3564 |
3545 #endif // defined TARGET_ARCH_ARM64 | 3565 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |