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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // NOTE: OK to use with memory locations that are accessed by generated code | 46 // NOTE: OK to use with memory locations that are accessed by generated code |
47 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); | 47 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
48 static uint32_t CompareAndSwapUint32( | 48 static uint32_t CompareAndSwapUint32( |
49 uint32_t* ptr, uint32_t old_value, uint32_t new_value); | 49 uint32_t* ptr, uint32_t old_value, uint32_t new_value); |
50 | 50 |
51 // Performs a load of a word from 'ptr', but without any guarantees about | 51 // Performs a load of a word from 'ptr', but without any guarantees about |
52 // memory order (i.e., no load barriers/fences). | 52 // memory order (i.e., no load barriers/fences). |
53 static uword LoadRelaxed(uword* ptr) { | 53 static uword LoadRelaxed(uword* ptr) { |
54 return *static_cast<volatile uword*>(ptr); | 54 return *static_cast<volatile uword*>(ptr); |
55 } | 55 } |
| 56 |
| 57 // Performs a load of a word from 'ptr', but without any guarantees about |
| 58 // memory order (i.e., no load barriers/fences). |
| 59 static intptr_t LoadRelaxedIntPtr(intptr_t* ptr) { |
| 60 return *static_cast<volatile intptr_t*>(ptr); |
| 61 } |
56 }; | 62 }; |
57 | 63 |
58 | 64 |
59 } // namespace dart | 65 } // namespace dart |
60 | 66 |
61 // We need to use the simulator to ensure that atomic operations are observed | 67 // We need to use the simulator to ensure that atomic operations are observed |
62 // both in C++ and in generated code if the simulator is active. | 68 // both in C++ and in generated code if the simulator is active. |
63 #include "vm/atomic_simulator.h" | 69 #include "vm/atomic_simulator.h" |
64 | 70 |
65 #if defined(TARGET_OS_ANDROID) | 71 #if defined(TARGET_OS_ANDROID) |
66 #include "vm/atomic_android.h" | 72 #include "vm/atomic_android.h" |
67 #elif defined(TARGET_OS_LINUX) | 73 #elif defined(TARGET_OS_LINUX) |
68 #include "vm/atomic_linux.h" | 74 #include "vm/atomic_linux.h" |
69 #elif defined(TARGET_OS_MACOS) | 75 #elif defined(TARGET_OS_MACOS) |
70 #include "vm/atomic_macos.h" | 76 #include "vm/atomic_macos.h" |
71 #elif defined(TARGET_OS_WINDOWS) | 77 #elif defined(TARGET_OS_WINDOWS) |
72 #include "vm/atomic_win.h" | 78 #include "vm/atomic_win.h" |
73 #else | 79 #else |
74 #error Unknown target os. | 80 #error Unknown target os. |
75 #endif | 81 #endif |
76 | 82 |
77 #endif // VM_ATOMIC_H_ | 83 #endif // VM_ATOMIC_H_ |
OLD | NEW |