| 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 #include "vm/simulator.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 class AtomicOperations : public AllStatic { | 15 class AtomicOperations : public AllStatic { |
| 16 public: | 16 public: |
| 17 // 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. |
| 18 // Returns the original value at p. | 18 // Returns the original value at p. |
| 19 // | 19 // |
| 20 // NOTE: Not to be used for any atomic operations involving memory locations | 20 // NOTE: Not to be used for any atomic operations involving memory locations |
| 21 // that are accessed by generated code | 21 // that are accessed by generated code. |
| 22 static uintptr_t FetchAndIncrement(uintptr_t* p); | 22 static uintptr_t FetchAndIncrement(uintptr_t* p); |
| 23 static uintptr_t FetchAndIncrementBy(intptr_t* p, intptr_t value); |
| 23 | 24 |
| 24 // Atomically fetch the value at p and decrement the value at p. | 25 // Atomically fetch the value at p and decrement the value at p. |
| 25 // Returns the original value at p. | 26 // Returns the original value at p. |
| 26 // | 27 // |
| 27 // NOTE: Not to be used for any atomic operations involving memory locations | 28 // NOTE: Not to be used for any atomic operations involving memory locations |
| 28 // that are accessed by generated code | 29 // that are accessed by generated code. |
| 29 static uintptr_t FetchAndDecrement(uintptr_t* p); | 30 static uintptr_t FetchAndDecrement(uintptr_t* p); |
| 31 static uintptr_t FetchAndDecrementBy(intptr_t* p, intptr_t value); |
| 30 | 32 |
| 31 // Atomically compare *ptr to old_value, and if equal, store new_value. | 33 // Atomically compare *ptr to old_value, and if equal, store new_value. |
| 32 // Returns the original value at ptr. | 34 // Returns the original value at ptr. |
| 33 // | 35 // |
| 34 // NOTE: OK to use with memory locations that are accessed by generated code | 36 // 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); | 37 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value); |
| 36 static uint32_t CompareAndSwapUint32( | 38 static uint32_t CompareAndSwapUint32( |
| 37 uint32_t* ptr, uint32_t old_value, uint32_t new_value); | 39 uint32_t* ptr, uint32_t old_value, uint32_t new_value); |
| 38 | 40 |
| 39 // Performs a load of a word from 'ptr', but without any guarantees about | 41 // Performs a load of a word from 'ptr', but without any guarantees about |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 #include "vm/atomic_linux.h" | 58 #include "vm/atomic_linux.h" |
| 57 #elif defined(TARGET_OS_MACOS) | 59 #elif defined(TARGET_OS_MACOS) |
| 58 #include "vm/atomic_macos.h" | 60 #include "vm/atomic_macos.h" |
| 59 #elif defined(TARGET_OS_WINDOWS) | 61 #elif defined(TARGET_OS_WINDOWS) |
| 60 #include "vm/atomic_win.h" | 62 #include "vm/atomic_win.h" |
| 61 #else | 63 #else |
| 62 #error Unknown target os. | 64 #error Unknown target os. |
| 63 #endif | 65 #endif |
| 64 | 66 |
| 65 #endif // VM_ATOMIC_H_ | 67 #endif // VM_ATOMIC_H_ |
| OLD | NEW |