| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkOnce_DEFINED | 8 #ifndef SkOnce_DEFINED |
| 9 #define SkOnce_DEFINED | 9 #define SkOnce_DEFINED |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 _ReadWriteBarrier(); | 57 _ReadWriteBarrier(); |
| 58 } | 58 } |
| 59 #else | 59 #else |
| 60 inline static void compiler_barrier() { | 60 inline static void compiler_barrier() { |
| 61 asm volatile("" : : : "memory"); | 61 asm volatile("" : : : "memory"); |
| 62 } | 62 } |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 inline static void full_barrier_on_arm() { | 65 inline static void full_barrier_on_arm() { |
| 66 #ifdef SK_CPU_ARM | 66 #ifdef SK_CPU_ARM |
| 67 #if SK_ARM_ARCH >= 7 |
| 67 asm volatile("dmb" : : : "memory"); | 68 asm volatile("dmb" : : : "memory"); |
| 69 #else |
| 70 asm volatile("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); |
| 71 #endif |
| 68 #endif | 72 #endif |
| 69 } | 73 } |
| 70 | 74 |
| 71 // On every platform, we issue a compiler barrier to prevent it from reordering | 75 // On every platform, we issue a compiler barrier to prevent it from reordering |
| 72 // code. That's enough for platforms like x86 where release and acquire | 76 // code. That's enough for platforms like x86 where release and acquire |
| 73 // barriers are no-ops. On other platforms we may need to be more careful; | 77 // barriers are no-ops. On other platforms we may need to be more careful; |
| 74 // ARM, in particular, needs real code for both acquire and release. We use a | 78 // ARM, in particular, needs real code for both acquire and release. We use a |
| 75 // full barrier, which acts as both, because that the finest precision ARM | 79 // full barrier, which acts as both, because that the finest precision ARM |
| 76 // provides. | 80 // provides. |
| 77 | 81 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // | 146 // |
| 143 // The release barrier in sk_once_slow guaranteed that once->done = true | 147 // The release barrier in sk_once_slow guaranteed that once->done = true |
| 144 // happens after f(arg), so by syncing to once->done = true here we're | 148 // happens after f(arg), so by syncing to once->done = true here we're |
| 145 // forcing ourselves to also wait until the effects of f(arg) are readble. | 149 // forcing ourselves to also wait until the effects of f(arg) are readble. |
| 146 acquire_barrier(); | 150 acquire_barrier(); |
| 147 } | 151 } |
| 148 | 152 |
| 149 #undef ANNOTATE_BENIGN_RACE | 153 #undef ANNOTATE_BENIGN_RACE |
| 150 | 154 |
| 151 #endif // SkOnce_DEFINED | 155 #endif // SkOnce_DEFINED |
| OLD | NEW |