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 intptr_t FetchAndIncrement(intptr_t* p); |
23 | 24 |
24 // Atomically increment the value at p by 'value'. | 25 // Atomically increment the value at p by 'value'. |
25 // | 26 // |
26 // 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 |
27 // that are accessed by generated code. | 28 // that are accessed by generated code. |
28 static void IncrementBy(intptr_t* p, intptr_t value); | 29 static void IncrementBy(intptr_t* p, intptr_t value); |
29 static void IncrementInt64By(int64_t* p, int64_t value); | 30 static void IncrementInt64By(int64_t* p, int64_t value); |
30 | 31 |
31 // Atomically fetch the value at p and decrement the value at p. | 32 // Atomically fetch the value at p and decrement the value at p. |
32 // Returns the original value at p. | 33 // Returns the original value at p. |
33 // | 34 // |
34 // NOTE: Not to be used for any atomic operations involving memory locations | 35 // NOTE: Not to be used for any atomic operations involving memory locations |
35 // that are accessed by generated code. | 36 // that are accessed by generated code. |
36 static uintptr_t FetchAndDecrement(uintptr_t* p); | 37 static uintptr_t FetchAndDecrement(uintptr_t* p); |
| 38 static intptr_t FetchAndDecrement(intptr_t* p); |
37 | 39 |
38 // Atomically decrement the value at p by 'value'. | 40 // Atomically decrement the value at p by 'value'. |
39 // | 41 // |
40 // NOTE: Not to be used for any atomic operations involving memory locations | 42 // NOTE: Not to be used for any atomic operations involving memory locations |
41 // that are accessed by generated code. | 43 // that are accessed by generated code. |
42 static void DecrementBy(intptr_t* p, intptr_t value); | 44 static void DecrementBy(intptr_t* p, intptr_t value); |
43 | 45 |
44 // Atomically compare *ptr to old_value, and if equal, store new_value. | 46 // Atomically compare *ptr to old_value, and if equal, store new_value. |
45 // Returns the original value at ptr. | 47 // Returns the original value at ptr. |
46 // | 48 // |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "vm/atomic_linux.h" | 80 #include "vm/atomic_linux.h" |
79 #elif defined(TARGET_OS_MACOS) | 81 #elif defined(TARGET_OS_MACOS) |
80 #include "vm/atomic_macos.h" | 82 #include "vm/atomic_macos.h" |
81 #elif defined(TARGET_OS_WINDOWS) | 83 #elif defined(TARGET_OS_WINDOWS) |
82 #include "vm/atomic_win.h" | 84 #include "vm/atomic_win.h" |
83 #else | 85 #else |
84 #error Unknown target os. | 86 #error Unknown target os. |
85 #endif | 87 #endif |
86 | 88 |
87 #endif // VM_ATOMIC_H_ | 89 #endif // VM_ATOMIC_H_ |
OLD | NEW |