|
26 | 26 | #ifndef OS_CPU_WINDOWS_AARCH64_COPY_WINDOWS_AARCH64_HPP |
27 | 27 | #define OS_CPU_WINDOWS_AARCH64_COPY_WINDOWS_AARCH64_HPP |
28 | 28 |
|
| 29 | +#include "runtime/atomic.hpp" |
| 30 | + |
29 | 31 | #include <string.h> |
30 | 32 |
|
| 33 | +template <typename T> |
| 34 | +static void pd_conjoint_atomic_helper(const T* from, T* to, size_t count) { |
| 35 | + if (from > to) { |
| 36 | + while (count-- > 0) { |
| 37 | + // Copy forwards |
| 38 | + Atomic::store(to++, Atomic::load(from++)); |
| 39 | + } |
| 40 | + } else { |
| 41 | + from += count - 1; |
| 42 | + to += count - 1; |
| 43 | + while (count-- > 0) { |
| 44 | + // Copy backwards |
| 45 | + Atomic::store(to--, Atomic::load(from--)); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
31 | 50 | static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) { |
32 | 51 | (void)memmove(to, from, count * HeapWordSize); |
33 | 52 | } |
@@ -71,55 +90,19 @@ static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) { |
71 | 90 | } |
72 | 91 |
|
73 | 92 | static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) { |
74 | | - if (from > to) { |
75 | | - while (count-- > 0) { |
76 | | - // Copy forwards |
77 | | - *to++ = *from++; |
78 | | - } |
79 | | - } else { |
80 | | - from += count - 1; |
81 | | - to += count - 1; |
82 | | - while (count-- > 0) { |
83 | | - // Copy backwards |
84 | | - *to-- = *from--; |
85 | | - } |
86 | | - } |
| 93 | + pd_conjoint_atomic_helper(from, to, count); |
87 | 94 | } |
88 | 95 |
|
89 | 96 | static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) { |
90 | | - if (from > to) { |
91 | | - while (count-- > 0) { |
92 | | - // Copy forwards |
93 | | - *to++ = *from++; |
94 | | - } |
95 | | - } else { |
96 | | - from += count - 1; |
97 | | - to += count - 1; |
98 | | - while (count-- > 0) { |
99 | | - // Copy backwards |
100 | | - *to-- = *from--; |
101 | | - } |
102 | | - } |
| 97 | + pd_conjoint_atomic_helper(from, to, count); |
103 | 98 | } |
104 | 99 |
|
105 | 100 | static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) { |
106 | | - pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count); |
| 101 | + pd_conjoint_atomic_helper(from, to, count); |
107 | 102 | } |
108 | 103 |
|
109 | 104 | static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) { |
110 | | - if (from > to) { |
111 | | - while (count-- > 0) { |
112 | | - // Copy forwards |
113 | | - *to++ = *from++; |
114 | | - } |
115 | | - } else { |
116 | | - from += count - 1; |
117 | | - to += count - 1; |
118 | | - while (count-- > 0) { |
119 | | - // Copy backwards |
120 | | - *to-- = *from--; |
121 | | - } |
122 | | - } |
| 105 | + pd_conjoint_atomic_helper(from, to, count); |
123 | 106 | } |
124 | 107 |
|
125 | 108 | static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) { |
|
0 commit comments