OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #ifndef VM_ATOMIC_H_ | 5 #ifndef VM_ATOMIC_H_ |
6 #define VM_ATOMIC_H_ | 6 #define VM_ATOMIC_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| 11 #include "vm/simulator.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 class AtomicOperations : public AllStatic { | 15 class AtomicOperations : public AllStatic { |
15 public: | 16 public: |
16 // Atomically fetch the value at p and increment the value at p. | 17 // Atomically fetch the value at p and increment the value at p. |
17 // Returns the original value at p. | 18 // Returns the original value at p. |
| 19 // |
| 20 // NOTE: Not to be used for any atomic operations involving memory locations |
| 21 // that are accessed by generated code |
18 static uintptr_t FetchAndIncrement(uintptr_t* p); | 22 static uintptr_t FetchAndIncrement(uintptr_t* p); |
19 | 23 |
20 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); | 24 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
21 }; | 25 }; |
22 | 26 |
23 | 27 |
24 } // namespace dart | 28 } // namespace dart |
25 | 29 |
| 30 // We need to use the simulator to ensure that atomic operations are observed |
| 31 // both in C++ and in generated code if the simulator is active. |
| 32 #include "vm/atomic_simulator.h" |
| 33 |
26 #if defined(TARGET_OS_ANDROID) | 34 #if defined(TARGET_OS_ANDROID) |
27 #include "vm/atomic_android.h" | 35 #include "vm/atomic_android.h" |
28 #elif defined(TARGET_OS_LINUX) | 36 #elif defined(TARGET_OS_LINUX) |
29 #include "vm/atomic_linux.h" | 37 #include "vm/atomic_linux.h" |
30 #elif defined(TARGET_OS_MACOS) | 38 #elif defined(TARGET_OS_MACOS) |
31 #include "vm/atomic_macos.h" | 39 #include "vm/atomic_macos.h" |
32 #elif defined(TARGET_OS_WINDOWS) | 40 #elif defined(TARGET_OS_WINDOWS) |
33 #include "vm/atomic_win.h" | 41 #include "vm/atomic_win.h" |
34 #else | 42 #else |
35 #error Unknown target os. | 43 #error Unknown target os. |
36 #endif | 44 #endif |
37 | 45 |
38 #endif // VM_ATOMIC_H_ | 46 #endif // VM_ATOMIC_H_ |
OLD | NEW |