Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/cpu/ppc/copy_ppc.hpp
40930 views
1
/*
2
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2012, 2013 SAP SE. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#ifndef CPU_PPC_COPY_PPC_HPP
27
#define CPU_PPC_COPY_PPC_HPP
28
29
#ifndef PPC64
30
#error "copy currently only implemented for PPC64"
31
#endif
32
33
// Inline functions for memory copy and fill.
34
35
static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
36
(void)memmove(to, from, count * HeapWordSize);
37
}
38
39
static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
40
switch (count) {
41
case 8: to[7] = from[7];
42
case 7: to[6] = from[6];
43
case 6: to[5] = from[5];
44
case 5: to[4] = from[4];
45
case 4: to[3] = from[3];
46
case 3: to[2] = from[2];
47
case 2: to[1] = from[1];
48
case 1: to[0] = from[0];
49
case 0: break;
50
default: (void)memcpy(to, from, count * HeapWordSize);
51
break;
52
}
53
}
54
55
static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
56
switch (count) {
57
case 8: to[7] = from[7];
58
case 7: to[6] = from[6];
59
case 6: to[5] = from[5];
60
case 5: to[4] = from[4];
61
case 4: to[3] = from[3];
62
case 3: to[2] = from[2];
63
case 2: to[1] = from[1];
64
case 1: to[0] = from[0];
65
case 0: break;
66
default: while (count-- > 0) {
67
*to++ = *from++;
68
}
69
break;
70
}
71
}
72
73
static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
74
(void)memmove(to, from, count * HeapWordSize);
75
}
76
77
static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
78
pd_disjoint_words(from, to, count);
79
}
80
81
static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
82
(void)memmove(to, from, count);
83
}
84
85
static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
86
(void)memmove(to, from, count);
87
}
88
89
// Template for atomic, element-wise copy.
90
template <class T>
91
static void copy_conjoint_atomic(const T* from, T* to, size_t count) {
92
if (from > to) {
93
while (count-- > 0) {
94
// Copy forwards
95
*to++ = *from++;
96
}
97
} else {
98
from += count - 1;
99
to += count - 1;
100
while (count-- > 0) {
101
// Copy backwards
102
*to-- = *from--;
103
}
104
}
105
}
106
107
static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
108
// TODO: contribute optimized version.
109
copy_conjoint_atomic<jshort>(from, to, count);
110
}
111
112
static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
113
// TODO: contribute optimized version.
114
copy_conjoint_atomic<jint>(from, to, count);
115
}
116
117
static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
118
copy_conjoint_atomic<jlong>(from, to, count);
119
}
120
121
static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
122
copy_conjoint_atomic<oop>(from, to, count);
123
}
124
125
static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
126
pd_conjoint_bytes_atomic(from, to, count);
127
}
128
129
static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
130
// TODO: contribute optimized version.
131
pd_conjoint_jshorts_atomic((const jshort*)from, (jshort*)to, count);
132
}
133
134
static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
135
// TODO: contribute optimized version.
136
pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count);
137
}
138
139
static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
140
pd_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
141
}
142
143
static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
144
pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
145
}
146
147
static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
148
julong* to = (julong*)tohw;
149
julong v = ((julong)value << 32) | value;
150
while (count-- > 0) {
151
*to++ = v;
152
}
153
}
154
155
static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
156
pd_fill_to_words(tohw, count, value);
157
}
158
159
static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
160
(void)memset(to, value, count);
161
}
162
163
static void pd_zero_to_words(HeapWord* tohw, size_t count) {
164
pd_fill_to_words(tohw, count, 0);
165
}
166
167
static void pd_zero_to_bytes(void* to, size_t count) {
168
(void)memset(to, 0, count);
169
}
170
171
#endif // CPU_PPC_COPY_PPC_HPP
172
173