Skip to content

Commit 14114c2

Browse files
committed
8301005: Clean up Copy::conjoint_*_atomic on windows
Reviewed-by: aboldtch, stefank, tschatzl
1 parent 973f741 commit 14114c2

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

src/hotspot/os_cpu/windows_x86/copy_windows_x86.hpp

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,43 +25,36 @@
2525
#ifndef OS_CPU_WINDOWS_X86_COPY_WINDOWS_X86_HPP
2626
#define OS_CPU_WINDOWS_X86_COPY_WINDOWS_X86_HPP
2727

28+
#include "runtime/atomic.hpp"
2829

29-
static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
30+
template <typename T>
31+
static void pd_conjoint_atomic_helper(const T* from, T* to, size_t count) {
3032
if (from > to) {
3133
while (count-- > 0) {
3234
// Copy forwards
33-
*to++ = *from++;
35+
Atomic::store(to++, Atomic::load(from++));
3436
}
3537
} else {
3638
from += count - 1;
3739
to += count - 1;
3840
while (count-- > 0) {
3941
// Copy backwards
40-
*to-- = *from--;
42+
Atomic::store(to--, Atomic::load(from--));
4143
}
4244
}
4345
}
4446

47+
static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
48+
pd_conjoint_atomic_helper(from, to, count);
49+
}
50+
4551
static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
46-
if (from > to) {
47-
while (count-- > 0) {
48-
// Copy forwards
49-
*to++ = *from++;
50-
}
51-
} else {
52-
from += count - 1;
53-
to += count - 1;
54-
while (count-- > 0) {
55-
// Copy backwards
56-
*to-- = *from--;
57-
}
58-
}
52+
pd_conjoint_atomic_helper(from, to, count);
5953
}
6054

6155
static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
6256
#ifdef AMD64
63-
assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
64-
pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
57+
pd_conjoint_atomic_helper(from, to, count);
6558
#else
6659
// Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
6760
__asm {
@@ -92,20 +85,7 @@ static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count
9285
}
9386

9487
static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
95-
// Do better than this: inline memmove body NEEDS CLEANUP
96-
if (from > to) {
97-
while (count-- > 0) {
98-
// Copy forwards
99-
*to++ = *from++;
100-
}
101-
} else {
102-
from += count - 1;
103-
to += count - 1;
104-
while (count-- > 0) {
105-
// Copy backwards
106-
*to-- = *from--;
107-
}
108-
}
88+
pd_conjoint_atomic_helper(from, to, count);
10989
}
11090

11191
static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {

0 commit comments

Comments
 (0)