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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // | 26 // |
27 // NOTE: Not to be used for any atomic operations involving memory locations | 27 // NOTE: Not to be used for any atomic operations involving memory locations |
28 // that are accessed by generated code | 28 // that are accessed by generated code |
29 static uintptr_t FetchAndDecrement(uintptr_t* p); | 29 static uintptr_t FetchAndDecrement(uintptr_t* p); |
30 | 30 |
31 // Atomically compare *ptr to old_value, and if equal, store new_value. | 31 // Atomically compare *ptr to old_value, and if equal, store new_value. |
32 // Returns the original value at ptr. | 32 // Returns the original value at ptr. |
33 // | 33 // |
34 // NOTE: OK to use with memory locations that are accessed by generated code | 34 // NOTE: OK to use with memory locations that are accessed by generated code |
35 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); | 35 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
| 36 static uint32_t CompareAndSwapUint32( |
| 37 uint32_t* ptr, uint32_t old_value, uint32_t new_value); |
36 | 38 |
37 // Performs a load of a word from 'ptr', but without any guarantees about | 39 // Performs a load of a word from 'ptr', but without any guarantees about |
38 // memory order (i.e., no load barriers/fences). | 40 // memory order (i.e., no load barriers/fences). |
39 static uword LoadRelaxed(uword* ptr) { | 41 static uword LoadRelaxed(uword* ptr) { |
40 return *static_cast<volatile uword*>(ptr); | 42 return *static_cast<volatile uword*>(ptr); |
41 } | 43 } |
42 }; | 44 }; |
43 | 45 |
44 | 46 |
45 } // namespace dart | 47 } // namespace dart |
46 | 48 |
47 // We need to use the simulator to ensure that atomic operations are observed | 49 // We need to use the simulator to ensure that atomic operations are observed |
48 // both in C++ and in generated code if the simulator is active. | 50 // both in C++ and in generated code if the simulator is active. |
49 #include "vm/atomic_simulator.h" | 51 #include "vm/atomic_simulator.h" |
50 | 52 |
51 #if defined(TARGET_OS_ANDROID) | 53 #if defined(TARGET_OS_ANDROID) |
52 #include "vm/atomic_android.h" | 54 #include "vm/atomic_android.h" |
53 #elif defined(TARGET_OS_LINUX) | 55 #elif defined(TARGET_OS_LINUX) |
54 #include "vm/atomic_linux.h" | 56 #include "vm/atomic_linux.h" |
55 #elif defined(TARGET_OS_MACOS) | 57 #elif defined(TARGET_OS_MACOS) |
56 #include "vm/atomic_macos.h" | 58 #include "vm/atomic_macos.h" |
57 #elif defined(TARGET_OS_WINDOWS) | 59 #elif defined(TARGET_OS_WINDOWS) |
58 #include "vm/atomic_win.h" | 60 #include "vm/atomic_win.h" |
59 #else | 61 #else |
60 #error Unknown target os. | 62 #error Unknown target os. |
61 #endif | 63 #endif |
62 | 64 |
63 #endif // VM_ATOMIC_H_ | 65 #endif // VM_ATOMIC_H_ |
OLD | NEW |