Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/os_cpu/bsd_aarch64/copy_bsd_aarch64.hpp
40930 views
1
/*
2
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4
* Copyright (c) 2021, Azul Systems, Inc. All rights reserved.
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
*
7
* This code is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 2 only, as
9
* published by the Free Software Foundation.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*
25
*/
26
27
#ifndef OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP
28
#define OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP
29
30
#define COPY_SMALL(from, to, count) \
31
{ \
32
long tmp0, tmp1, tmp2, tmp3; \
33
long tmp4, tmp5, tmp6, tmp7; \
34
__asm volatile( \
35
" adr %[t0], 0f;\n" \
36
" add %[t0], %[t0], %[cnt], lsl #5;\n" \
37
" br %[t0];\n" \
38
" .align 5;\n" \
39
"0:" \
40
" b 1f;\n" \
41
" .align 5;\n" \
42
" ldr %[t0], [%[s], #0];\n" \
43
" str %[t0], [%[d], #0];\n" \
44
" b 1f;\n" \
45
" .align 5;\n" \
46
" ldp %[t0], %[t1], [%[s], #0];\n" \
47
" stp %[t0], %[t1], [%[d], #0];\n" \
48
" b 1f;\n" \
49
" .align 5;\n" \
50
" ldp %[t0], %[t1], [%[s], #0];\n" \
51
" ldr %[t2], [%[s], #16];\n" \
52
" stp %[t0], %[t1], [%[d], #0];\n" \
53
" str %[t2], [%[d], #16];\n" \
54
" b 1f;\n" \
55
" .align 5;\n" \
56
" ldp %[t0], %[t1], [%[s], #0];\n" \
57
" ldp %[t2], %[t3], [%[s], #16];\n" \
58
" stp %[t0], %[t1], [%[d], #0];\n" \
59
" stp %[t2], %[t3], [%[d], #16];\n" \
60
" b 1f;\n" \
61
" .align 5;\n" \
62
" ldp %[t0], %[t1], [%[s], #0];\n" \
63
" ldp %[t2], %[t3], [%[s], #16];\n" \
64
" ldr %[t4], [%[s], #32];\n" \
65
" stp %[t0], %[t1], [%[d], #0];\n" \
66
" stp %[t2], %[t3], [%[d], #16];\n" \
67
" str %[t4], [%[d], #32];\n" \
68
" b 1f;\n" \
69
" .align 5;\n" \
70
" ldp %[t0], %[t1], [%[s], #0];\n" \
71
" ldp %[t2], %[t3], [%[s], #16];\n" \
72
" ldp %[t4], %[t5], [%[s], #32];\n" \
73
"2:" \
74
" stp %[t0], %[t1], [%[d], #0];\n" \
75
" stp %[t2], %[t3], [%[d], #16];\n" \
76
" stp %[t4], %[t5], [%[d], #32];\n" \
77
" b 1f;\n" \
78
" .align 5;\n" \
79
" ldr %[t6], [%[s], #0];\n" \
80
" ldp %[t0], %[t1], [%[s], #8];\n" \
81
" ldp %[t2], %[t3], [%[s], #24];\n" \
82
" ldp %[t4], %[t5], [%[s], #40];\n" \
83
" str %[t6], [%[d]], #8;\n" \
84
" b 2b;\n" \
85
" .align 5;\n" \
86
" ldp %[t0], %[t1], [%[s], #0];\n" \
87
" ldp %[t2], %[t3], [%[s], #16];\n" \
88
" ldp %[t4], %[t5], [%[s], #32];\n" \
89
" ldp %[t6], %[t7], [%[s], #48];\n" \
90
" stp %[t0], %[t1], [%[d], #0];\n" \
91
" stp %[t2], %[t3], [%[d], #16];\n" \
92
" stp %[t4], %[t5], [%[d], #32];\n" \
93
" stp %[t6], %[t7], [%[d], #48];\n" \
94
"1:" \
95
\
96
: [s]"+r"(from), [d]"+r"(to), [cnt]"+r"(count), \
97
[t0]"=&r"(tmp0), [t1]"=&r"(tmp1), [t2]"=&r"(tmp2), [t3]"=&r"(tmp3), \
98
[t4]"=&r"(tmp4), [t5]"=&r"(tmp5), [t6]"=&r"(tmp6), [t7]"=&r"(tmp7) \
99
: \
100
: "memory", "cc"); \
101
}
102
103
static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
104
__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
105
if (__builtin_expect(count <= 8, 1)) {
106
COPY_SMALL(from, to, count);
107
return;
108
}
109
_Copy_conjoint_words(from, to, count);
110
}
111
112
static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
113
if (__builtin_constant_p(count)) {
114
memcpy(to, from, count * sizeof(HeapWord));
115
return;
116
}
117
__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
118
if (__builtin_expect(count <= 8, 1)) {
119
COPY_SMALL(from, to, count);
120
return;
121
}
122
_Copy_disjoint_words(from, to, count);
123
}
124
125
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
126
__asm volatile( "prfm pldl1strm, [%[s], #0];" :: [s]"r"(from) : "memory");
127
if (__builtin_expect(count <= 8, 1)) {
128
COPY_SMALL(from, to, count);
129
return;
130
}
131
_Copy_disjoint_words(from, to, count);
132
}
133
134
static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
135
pd_conjoint_words(from, to, count);
136
}
137
138
static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
139
pd_disjoint_words(from, to, count);
140
}
141
142
static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
143
(void)memmove(to, from, count);
144
}
145
146
static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
147
pd_conjoint_bytes(from, to, count);
148
}
149
150
static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
151
_Copy_conjoint_jshorts_atomic(from, to, count);
152
}
153
154
static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
155
_Copy_conjoint_jints_atomic(from, to, count);
156
}
157
158
static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
159
_Copy_conjoint_jlongs_atomic(from, to, count);
160
}
161
162
static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
163
assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
164
_Copy_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
165
}
166
167
static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
168
_Copy_arrayof_conjoint_bytes(from, to, count);
169
}
170
171
static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
172
_Copy_arrayof_conjoint_jshorts(from, to, count);
173
}
174
175
static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
176
_Copy_arrayof_conjoint_jints(from, to, count);
177
}
178
179
static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
180
_Copy_arrayof_conjoint_jlongs(from, to, count);
181
}
182
183
static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
184
assert(!UseCompressedOops, "foo!");
185
assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
186
_Copy_arrayof_conjoint_jlongs(from, to, count);
187
}
188
189
#endif // OS_CPU_BSD_AARCH64_COPY_BSD_AARCH64_HPP
190
191