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 RUNTIME_VM_ATOMIC_H_ | 5 #ifndef RUNTIME_VM_ATOMIC_H_ |
6 #define RUNTIME_VM_ATOMIC_H_ | 6 #define RUNTIME_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" | |
12 | 11 |
13 namespace dart { | 12 namespace dart { |
14 | 13 |
15 class AtomicOperations : public AllStatic { | 14 class AtomicOperations : public AllStatic { |
16 public: | 15 public: |
17 // Atomically fetch the value at p and increment the value at p. | 16 // Atomically fetch the value at p and increment the value at p. |
18 // Returns the original value at p. | 17 // Returns the original value at p. |
19 // | 18 // |
20 // NOTE: Not to be used for any atomic operations involving memory locations | 19 // NOTE: Not to be used for any atomic operations involving memory locations |
rmacnak
2017/08/11 23:44:46
These comments about generated code can be removed
alexmarkov
2017/08/12 00:34:55
Done.
| |
21 // that are accessed by generated code. | 20 // that are accessed by generated code. |
22 static uintptr_t FetchAndIncrement(uintptr_t* p); | 21 static uintptr_t FetchAndIncrement(uintptr_t* p); |
23 static intptr_t FetchAndIncrement(intptr_t* p); | 22 static intptr_t FetchAndIncrement(intptr_t* p); |
24 | 23 |
25 // Atomically increment the value at p by 'value'. | 24 // Atomically increment the value at p by 'value'. |
26 // | 25 // |
27 // NOTE: Not to be used for any atomic operations involving memory locations | 26 // NOTE: Not to be used for any atomic operations involving memory locations |
28 // that are accessed by generated code. | 27 // that are accessed by generated code. |
29 static void IncrementBy(intptr_t* p, intptr_t value); | 28 static void IncrementBy(intptr_t* p, intptr_t value); |
30 static void IncrementInt64By(int64_t* p, int64_t value); | 29 static void IncrementInt64By(int64_t* p, int64_t value); |
(...skipping 24 matching lines...) Expand all Loading... | |
55 // Performs a load of a word from 'ptr', but without any guarantees about | 54 // Performs a load of a word from 'ptr', but without any guarantees about |
56 // memory order (i.e., no load barriers/fences). | 55 // memory order (i.e., no load barriers/fences). |
57 template <typename T> | 56 template <typename T> |
58 static T LoadRelaxed(T* ptr) { | 57 static T LoadRelaxed(T* ptr) { |
59 return *static_cast<volatile T*>(ptr); | 58 return *static_cast<volatile T*>(ptr); |
60 } | 59 } |
61 }; | 60 }; |
62 | 61 |
63 } // namespace dart | 62 } // namespace dart |
64 | 63 |
65 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) | |
66 #define USING_SIMULATOR_ATOMICS | |
67 #endif | |
68 | |
69 #if defined(USING_SIMULATOR_ATOMICS) | |
70 // We need to use the simulator to ensure that atomic operations are observed | |
71 // both in C++ and in generated code if the simulator is active. | |
72 #include "vm/atomic_simulator.h" | |
73 #endif | |
74 | |
75 #if defined(HOST_OS_ANDROID) | 64 #if defined(HOST_OS_ANDROID) |
76 #include "vm/atomic_android.h" | 65 #include "vm/atomic_android.h" |
77 #elif defined(HOST_OS_FUCHSIA) | 66 #elif defined(HOST_OS_FUCHSIA) |
78 #include "vm/atomic_fuchsia.h" | 67 #include "vm/atomic_fuchsia.h" |
79 #elif defined(HOST_OS_LINUX) | 68 #elif defined(HOST_OS_LINUX) |
80 #include "vm/atomic_linux.h" | 69 #include "vm/atomic_linux.h" |
81 #elif defined(HOST_OS_MACOS) | 70 #elif defined(HOST_OS_MACOS) |
82 #include "vm/atomic_macos.h" | 71 #include "vm/atomic_macos.h" |
83 #elif defined(HOST_OS_WINDOWS) | 72 #elif defined(HOST_OS_WINDOWS) |
84 #include "vm/atomic_win.h" | 73 #include "vm/atomic_win.h" |
85 #else | 74 #else |
86 #error Unknown target os. | 75 #error Unknown target os. |
87 #endif | 76 #endif |
88 | 77 |
89 #endif // RUNTIME_VM_ATOMIC_H_ | 78 #endif // RUNTIME_VM_ATOMIC_H_ |
OLD | NEW |