| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Atomically compare *ptr to old_value, and if equal, store new_value. | 44 // Atomically compare *ptr to old_value, and if equal, store new_value. |
| 45 // Returns the original value at ptr. | 45 // Returns the original value at ptr. |
| 46 // | 46 // |
| 47 // NOTE: OK to use with memory locations that are accessed by generated code | 47 // NOTE: OK to use with memory locations that are accessed by generated code |
| 48 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); | 48 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
| 49 static uint32_t CompareAndSwapUint32( | 49 static uint32_t CompareAndSwapUint32( |
| 50 uint32_t* ptr, uint32_t old_value, uint32_t new_value); | 50 uint32_t* ptr, uint32_t old_value, uint32_t new_value); |
| 51 | 51 |
| 52 // Performs a load of a word from 'ptr', but without any guarantees about | 52 // Performs a load of a word from 'ptr', but without any guarantees about |
| 53 // memory order (i.e., no load barriers/fences). | 53 // memory order (i.e., no load barriers/fences). |
| 54 static uword LoadRelaxed(uword* ptr) { | 54 template <typename T> |
| 55 return *static_cast<volatile uword*>(ptr); | 55 static T LoadRelaxed(T* ptr) { |
| 56 } | 56 return *static_cast<volatile T*>(ptr); |
| 57 | |
| 58 // Performs a load of a word from 'ptr', but without any guarantees about | |
| 59 // memory order (i.e., no load barriers/fences). | |
| 60 static intptr_t LoadRelaxedIntPtr(intptr_t* ptr) { | |
| 61 return *static_cast<volatile intptr_t*>(ptr); | |
| 62 } | 57 } |
| 63 }; | 58 }; |
| 64 | 59 |
| 65 | 60 |
| 66 } // namespace dart | 61 } // namespace dart |
| 67 | 62 |
| 68 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) | 63 #if defined(USING_SIMULATOR) && !defined(TARGET_ARCH_DBC) |
| 69 #define USING_SIMULATOR_ATOMICS | 64 #define USING_SIMULATOR_ATOMICS |
| 70 #endif | 65 #endif |
| 71 | 66 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 #include "vm/atomic_linux.h" | 78 #include "vm/atomic_linux.h" |
| 84 #elif defined(TARGET_OS_MACOS) | 79 #elif defined(TARGET_OS_MACOS) |
| 85 #include "vm/atomic_macos.h" | 80 #include "vm/atomic_macos.h" |
| 86 #elif defined(TARGET_OS_WINDOWS) | 81 #elif defined(TARGET_OS_WINDOWS) |
| 87 #include "vm/atomic_win.h" | 82 #include "vm/atomic_win.h" |
| 88 #else | 83 #else |
| 89 #error Unknown target os. | 84 #error Unknown target os. |
| 90 #endif | 85 #endif |
| 91 | 86 |
| 92 #endif // VM_ATOMIC_H_ | 87 #endif // VM_ATOMIC_H_ |
| OLD | NEW |