Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: runtime/vm/atomic.h

Issue 3000803003: Revert "[vm] Implement more efficient CAS in simarm/simarm64 modes" (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/atomic_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 12
12 namespace dart { 13 namespace dart {
13 14
14 class AtomicOperations : public AllStatic { 15 class AtomicOperations : public AllStatic {
15 public: 16 public:
16 // 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.
17 // Returns the original value at p. 18 // Returns the original value at p.
19 //
20 // NOTE: Not to be used for any atomic operations involving memory locations
21 // that are accessed by generated code.
18 static uintptr_t FetchAndIncrement(uintptr_t* p); 22 static uintptr_t FetchAndIncrement(uintptr_t* p);
19 static intptr_t FetchAndIncrement(intptr_t* p); 23 static intptr_t FetchAndIncrement(intptr_t* p);
20 24
21 // Atomically increment the value at p by 'value'. 25 // Atomically increment the value at p by 'value'.
26 //
27 // NOTE: Not to be used for any atomic operations involving memory locations
28 // that are accessed by generated code.
22 static void IncrementBy(intptr_t* p, intptr_t value); 29 static void IncrementBy(intptr_t* p, intptr_t value);
23 static void IncrementInt64By(int64_t* p, int64_t value); 30 static void IncrementInt64By(int64_t* p, int64_t value);
24 31
25 // 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.
26 // Returns the original value at p. 33 // Returns the original value at p.
34 //
35 // NOTE: Not to be used for any atomic operations involving memory locations
36 // that are accessed by generated code.
27 static uintptr_t FetchAndDecrement(uintptr_t* p); 37 static uintptr_t FetchAndDecrement(uintptr_t* p);
28 static intptr_t FetchAndDecrement(intptr_t* p); 38 static intptr_t FetchAndDecrement(intptr_t* p);
29 39
30 // Atomically decrement the value at p by 'value'. 40 // Atomically decrement the value at p by 'value'.
41 //
42 // NOTE: Not to be used for any atomic operations involving memory locations
43 // that are accessed by generated code.
31 static void DecrementBy(intptr_t* p, intptr_t value); 44 static void DecrementBy(intptr_t* p, intptr_t value);
32 45
33 // 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.
34 // Returns the original value at ptr. 47 // Returns the original value at ptr.
48 //
49 // 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); 50 static uword CompareAndSwapWord(uword* ptr, uword old_value, uword new_value);
36 static uint32_t CompareAndSwapUint32(uint32_t* ptr, 51 static uint32_t CompareAndSwapUint32(uint32_t* ptr,
37 uint32_t old_value, 52 uint32_t old_value,
38 uint32_t new_value); 53 uint32_t new_value);
39 54
40 // Performs a load of a word from 'ptr', but without any guarantees about 55 // Performs a load of a word from 'ptr', but without any guarantees about
41 // memory order (i.e., no load barriers/fences). 56 // memory order (i.e., no load barriers/fences).
42 template <typename T> 57 template <typename T>
43 static T LoadRelaxed(T* ptr) { 58 static T LoadRelaxed(T* ptr) {
44 return *static_cast<volatile T*>(ptr); 59 return *static_cast<volatile T*>(ptr);
45 } 60 }
46 }; 61 };
47 62
48 } // namespace dart 63 } // namespace dart
49 64
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
50 #if defined(HOST_OS_ANDROID) 75 #if defined(HOST_OS_ANDROID)
51 #include "vm/atomic_android.h" 76 #include "vm/atomic_android.h"
52 #elif defined(HOST_OS_FUCHSIA) 77 #elif defined(HOST_OS_FUCHSIA)
53 #include "vm/atomic_fuchsia.h" 78 #include "vm/atomic_fuchsia.h"
54 #elif defined(HOST_OS_LINUX) 79 #elif defined(HOST_OS_LINUX)
55 #include "vm/atomic_linux.h" 80 #include "vm/atomic_linux.h"
56 #elif defined(HOST_OS_MACOS) 81 #elif defined(HOST_OS_MACOS)
57 #include "vm/atomic_macos.h" 82 #include "vm/atomic_macos.h"
58 #elif defined(HOST_OS_WINDOWS) 83 #elif defined(HOST_OS_WINDOWS)
59 #include "vm/atomic_win.h" 84 #include "vm/atomic_win.h"
60 #else 85 #else
61 #error Unknown target os. 86 #error Unknown target os.
62 #endif 87 #endif
63 88
64 #endif // RUNTIME_VM_ATOMIC_H_ 89 #endif // RUNTIME_VM_ATOMIC_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/atomic_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698