src/cpu/sparc/vm/copy_sparc.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef CPU_SPARC_VM_COPY_SPARC_HPP
aoqi@0 26 #define CPU_SPARC_VM_COPY_SPARC_HPP
aoqi@0 27
aoqi@0 28 // Inline functions for memory copy and fill.
aoqi@0 29
aoqi@0 30 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 31 (void)memmove(to, from, count * HeapWordSize);
aoqi@0 32 }
aoqi@0 33
aoqi@0 34 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 35 switch (count) {
aoqi@0 36 case 8: to[7] = from[7];
aoqi@0 37 case 7: to[6] = from[6];
aoqi@0 38 case 6: to[5] = from[5];
aoqi@0 39 case 5: to[4] = from[4];
aoqi@0 40 case 4: to[3] = from[3];
aoqi@0 41 case 3: to[2] = from[2];
aoqi@0 42 case 2: to[1] = from[1];
aoqi@0 43 case 1: to[0] = from[0];
aoqi@0 44 case 0: break;
aoqi@0 45 default: (void)memcpy(to, from, count * HeapWordSize);
aoqi@0 46 break;
aoqi@0 47 }
aoqi@0 48 }
aoqi@0 49
aoqi@0 50 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 51 switch (count) {
aoqi@0 52 case 8: to[7] = from[7];
aoqi@0 53 case 7: to[6] = from[6];
aoqi@0 54 case 6: to[5] = from[5];
aoqi@0 55 case 5: to[4] = from[4];
aoqi@0 56 case 4: to[3] = from[3];
aoqi@0 57 case 3: to[2] = from[2];
aoqi@0 58 case 2: to[1] = from[1];
aoqi@0 59 case 1: to[0] = from[0];
aoqi@0 60 case 0: break;
aoqi@0 61 default: while (count-- > 0) {
aoqi@0 62 *to++ = *from++;
aoqi@0 63 }
aoqi@0 64 break;
aoqi@0 65 }
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 69 (void)memmove(to, from, count * HeapWordSize);
aoqi@0 70 }
aoqi@0 71
aoqi@0 72 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 73 pd_disjoint_words(from, to, count);
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
aoqi@0 77 (void)memmove(to, from, count);
aoqi@0 78 }
aoqi@0 79
aoqi@0 80 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
aoqi@0 81 (void)memmove(to, from, count);
aoqi@0 82 }
aoqi@0 83
aoqi@0 84 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
aoqi@0 85 if (from > to) {
aoqi@0 86 while (count-- > 0) {
aoqi@0 87 // Copy forwards
aoqi@0 88 *to++ = *from++;
aoqi@0 89 }
aoqi@0 90 } else {
aoqi@0 91 from += count - 1;
aoqi@0 92 to += count - 1;
aoqi@0 93 while (count-- > 0) {
aoqi@0 94 // Copy backwards
aoqi@0 95 *to-- = *from--;
aoqi@0 96 }
aoqi@0 97 }
aoqi@0 98 }
aoqi@0 99
aoqi@0 100 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
aoqi@0 101 if (from > to) {
aoqi@0 102 while (count-- > 0) {
aoqi@0 103 // Copy forwards
aoqi@0 104 *to++ = *from++;
aoqi@0 105 }
aoqi@0 106 } else {
aoqi@0 107 from += count - 1;
aoqi@0 108 to += count - 1;
aoqi@0 109 while (count-- > 0) {
aoqi@0 110 // Copy backwards
aoqi@0 111 *to-- = *from--;
aoqi@0 112 }
aoqi@0 113 }
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
aoqi@0 117 #ifdef _LP64
aoqi@0 118 assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
aoqi@0 119 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
aoqi@0 120 #else
aoqi@0 121 // Guarantee use of ldd/std via some asm code, because compiler won't.
aoqi@0 122 // See solaris_sparc.il.
aoqi@0 123 _Copy_conjoint_jlongs_atomic(from, to, count);
aoqi@0 124 #endif
aoqi@0 125 }
aoqi@0 126
aoqi@0 127 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
aoqi@0 128 // Do better than this: inline memmove body NEEDS CLEANUP
aoqi@0 129 if (from > to) {
aoqi@0 130 while (count-- > 0) {
aoqi@0 131 // Copy forwards
aoqi@0 132 *to++ = *from++;
aoqi@0 133 }
aoqi@0 134 } else {
aoqi@0 135 from += count - 1;
aoqi@0 136 to += count - 1;
aoqi@0 137 while (count-- > 0) {
aoqi@0 138 // Copy backwards
aoqi@0 139 *to-- = *from--;
aoqi@0 140 }
aoqi@0 141 }
aoqi@0 142 }
aoqi@0 143
aoqi@0 144 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 145 pd_conjoint_bytes_atomic(from, to, count);
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 149 pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
aoqi@0 150 }
aoqi@0 151
aoqi@0 152 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 153 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
aoqi@0 154 }
aoqi@0 155
aoqi@0 156 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 157 pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
aoqi@0 158 }
aoqi@0 159
aoqi@0 160 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
aoqi@0 161 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
aoqi@0 162 }
aoqi@0 163
aoqi@0 164 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
aoqi@0 165 #ifdef _LP64
aoqi@0 166 guarantee(mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0,
aoqi@0 167 "unaligned fill words");
aoqi@0 168 julong* to = (julong*)tohw;
aoqi@0 169 julong v = ((julong)value << 32) | value;
aoqi@0 170 while (count-- > 0) {
aoqi@0 171 *to++ = v;
aoqi@0 172 }
aoqi@0 173 #else // _LP64
aoqi@0 174 juint* to = (juint*)tohw;
aoqi@0 175 while (count-- > 0) {
aoqi@0 176 *to++ = value;
aoqi@0 177 }
aoqi@0 178 #endif // _LP64
aoqi@0 179 }
aoqi@0 180
aoqi@0 181 typedef void (*_zero_Fn)(HeapWord* to, size_t count);
aoqi@0 182
aoqi@0 183 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
aoqi@0 184 assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation");
aoqi@0 185
aoqi@0 186 if (value == 0 && UseBlockZeroing &&
aoqi@0 187 (count > (size_t)(BlockZeroingLowLimit >> LogHeapWordSize))) {
aoqi@0 188 // Call it only when block zeroing is used
aoqi@0 189 ((_zero_Fn)StubRoutines::zero_aligned_words())(tohw, count);
aoqi@0 190 } else {
aoqi@0 191 julong* to = (julong*)tohw;
aoqi@0 192 julong v = ((julong)value << 32) | value;
aoqi@0 193 // If count is odd, odd will be equal to 1 on 32-bit platform
aoqi@0 194 // and be equal to 0 on 64-bit platform.
aoqi@0 195 size_t odd = count % (BytesPerLong / HeapWordSize) ;
aoqi@0 196
aoqi@0 197 size_t aligned_count = align_object_offset(count - odd) / HeapWordsPerLong;
aoqi@0 198 julong* end = ((julong*)tohw) + aligned_count - 1;
aoqi@0 199 while (to <= end) {
aoqi@0 200 DEBUG_ONLY(count -= BytesPerLong / HeapWordSize ;)
aoqi@0 201 *to++ = v;
aoqi@0 202 }
aoqi@0 203 assert(count == odd, "bad bounds on loop filling to aligned words");
aoqi@0 204 if (odd) {
aoqi@0 205 *((juint*)to) = value;
aoqi@0 206
aoqi@0 207 }
aoqi@0 208 }
aoqi@0 209 }
aoqi@0 210
aoqi@0 211 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
aoqi@0 212 (void)memset(to, value, count);
aoqi@0 213 }
aoqi@0 214
aoqi@0 215 static void pd_zero_to_words(HeapWord* tohw, size_t count) {
aoqi@0 216 pd_fill_to_words(tohw, count, 0);
aoqi@0 217 }
aoqi@0 218
aoqi@0 219 static void pd_zero_to_bytes(void* to, size_t count) {
aoqi@0 220 (void)memset(to, 0, count);
aoqi@0 221 }
aoqi@0 222
aoqi@0 223 #endif // CPU_SPARC_VM_COPY_SPARC_HPP

mercurial