1/*
2 * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#ifndef OS_CPU_LINUX_ARM_VM_COPY_LINUX_ARM_INLINE_HPP
26#define OS_CPU_LINUX_ARM_VM_COPY_LINUX_ARM_INLINE_HPP
27
28static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
29#ifdef AARCH64
30  _Copy_conjoint_words(from, to, count * HeapWordSize);
31#else
32   // NOTE: _Copy_* functions on 32-bit ARM expect "to" and "from" arguments in reversed order
33  _Copy_conjoint_words(to, from, count * HeapWordSize);
34#endif
35}
36
37static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
38#ifdef AARCH64
39  _Copy_disjoint_words(from, to, count * HeapWordSize);
40#else
41  _Copy_disjoint_words(to, from, count * HeapWordSize);
42#endif // AARCH64
43}
44
45static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
46  pd_disjoint_words(from, to, count);
47}
48
49static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
50  pd_conjoint_words(from, to, count);
51}
52
53static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
54  pd_disjoint_words(from, to, count);
55}
56
57static void pd_conjoint_bytes(void* from, void* to, size_t count) {
58  memmove(to, from, count);
59}
60
61static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
62  pd_conjoint_bytes(from, to, count);
63}
64
65static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
66#ifdef AARCH64
67  _Copy_conjoint_jshorts_atomic(from, to, count * BytesPerShort);
68#else
69  _Copy_conjoint_jshorts_atomic(to, from, count * BytesPerShort);
70#endif
71}
72
73static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
74#ifdef AARCH64
75  _Copy_conjoint_jints_atomic(from, to, count * BytesPerInt);
76#else
77  assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
78  // pd_conjoint_words is word-atomic in this implementation.
79  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
80#endif
81}
82
83static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
84#ifdef AARCH64
85  assert(HeapWordSize == BytesPerLong, "64-bit architecture");
86  pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
87#else
88  _Copy_conjoint_jlongs_atomic(to, from, count * BytesPerLong);
89#endif
90}
91
92static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
93#ifdef AARCH64
94  if (UseCompressedOops) {
95    assert(BytesPerHeapOop == BytesPerInt, "compressed oops");
96    pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
97  } else {
98    assert(BytesPerHeapOop == BytesPerLong, "64-bit architecture");
99    pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
100  }
101#else
102  assert(BytesPerHeapOop == BytesPerInt, "32-bit architecture");
103  pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
104#endif
105}
106
107static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
108  pd_conjoint_bytes_atomic((void*)from, (void*)to, count);
109}
110
111static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
112  pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
113}
114
115static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
116  pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
117}
118
119static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
120  pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
121}
122
123static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
124  pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
125}
126
127#endif // OS_CPU_LINUX_ARM_VM_COPY_LINUX_ARM_INLINE_HPP
128