src/cpu/zero/vm/copy_zero.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 2314
f95d63e2154a
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

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

mercurial