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 generated code. | |
koda
2014/10/27 14:05:10
This is a bit vague. "involving memory locations t
Ivan Posva
2014/10/27 17:58:23
Done.
| |
18 static uintptr_t FetchAndIncrement(uintptr_t* p); | 21 static uintptr_t FetchAndIncrement(uintptr_t* p); |
19 | 22 |
20 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); | 23 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
21 }; | 24 }; |
22 | 25 |
23 | 26 |
24 } // namespace dart | 27 } // namespace dart |
25 | 28 |
29 // We need to use the simulator to ensure that atomic operations are observed | |
30 // both in C++ and in generated code if the simulator is active. | |
31 #include "vm/atomic_simulator.h" | |
32 | |
26 #if defined(TARGET_OS_ANDROID) | 33 #if defined(TARGET_OS_ANDROID) |
27 #include "vm/atomic_android.h" | 34 #include "vm/atomic_android.h" |
28 #elif defined(TARGET_OS_LINUX) | 35 #elif defined(TARGET_OS_LINUX) |
29 #include "vm/atomic_linux.h" | 36 #include "vm/atomic_linux.h" |
30 #elif defined(TARGET_OS_MACOS) | 37 #elif defined(TARGET_OS_MACOS) |
31 #include "vm/atomic_macos.h" | 38 #include "vm/atomic_macos.h" |
32 #elif defined(TARGET_OS_WINDOWS) | 39 #elif defined(TARGET_OS_WINDOWS) |
33 #include "vm/atomic_win.h" | 40 #include "vm/atomic_win.h" |
34 #else | 41 #else |
35 #error Unknown target os. | 42 #error Unknown target os. |
36 #endif | 43 #endif |
37 | 44 |
38 #endif // VM_ATOMIC_H_ | 45 #endif // VM_ATOMIC_H_ |
OLD | NEW |