src/os_cpu/windows_x86/vm/copy_windows_x86.inline.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 3206
16f9fa2bf76c
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
stefank@2314 26 #define OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
stefank@2314 27
duke@435 28 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
duke@435 29 (void)memmove(to, from, count * HeapWordSize);
duke@435 30 }
duke@435 31
duke@435 32 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
duke@435 33 #ifdef AMD64
duke@435 34 switch (count) {
duke@435 35 case 8: to[7] = from[7];
duke@435 36 case 7: to[6] = from[6];
duke@435 37 case 6: to[5] = from[5];
duke@435 38 case 5: to[4] = from[4];
duke@435 39 case 4: to[3] = from[3];
duke@435 40 case 3: to[2] = from[2];
duke@435 41 case 2: to[1] = from[1];
duke@435 42 case 1: to[0] = from[0];
duke@435 43 case 0: break;
duke@435 44 default:
duke@435 45 (void)memcpy(to, from, count * HeapWordSize);
duke@435 46 break;
duke@435 47 }
duke@435 48 #else
duke@435 49 (void)memcpy(to, from, count * HeapWordSize);
duke@435 50 #endif // AMD64
duke@435 51 }
duke@435 52
duke@435 53 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
duke@435 54 switch (count) {
duke@435 55 case 8: to[7] = from[7];
duke@435 56 case 7: to[6] = from[6];
duke@435 57 case 6: to[5] = from[5];
duke@435 58 case 5: to[4] = from[4];
duke@435 59 case 4: to[3] = from[3];
duke@435 60 case 3: to[2] = from[2];
duke@435 61 case 2: to[1] = from[1];
duke@435 62 case 1: to[0] = from[0];
duke@435 63 case 0: break;
duke@435 64 default: while (count-- > 0) {
duke@435 65 *to++ = *from++;
duke@435 66 }
duke@435 67 break;
duke@435 68 }
duke@435 69 }
duke@435 70
duke@435 71 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
duke@435 72 (void)memmove(to, from, count * HeapWordSize);
duke@435 73 }
duke@435 74
duke@435 75 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
duke@435 76 pd_disjoint_words(from, to, count);
duke@435 77 }
duke@435 78
duke@435 79 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
duke@435 80 (void)memmove(to, from, count);
duke@435 81 }
duke@435 82
duke@435 83 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
duke@435 84 pd_conjoint_bytes(from, to, count);
duke@435 85 }
duke@435 86
duke@435 87 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
duke@435 88 // FIXME
duke@435 89 (void)memmove(to, from, count << LogBytesPerShort);
duke@435 90 }
duke@435 91
duke@435 92 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
duke@435 93 // FIXME
duke@435 94 (void)memmove(to, from, count << LogBytesPerInt);
duke@435 95 }
duke@435 96
duke@435 97 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
duke@435 98 #ifdef AMD64
duke@435 99 assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
duke@435 100 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
duke@435 101 #else
duke@435 102 // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
duke@435 103 __asm {
duke@435 104 mov eax, from;
duke@435 105 mov edx, to;
duke@435 106 mov ecx, count;
duke@435 107 cmp eax, edx;
duke@435 108 jbe downtest;
duke@435 109 jmp uptest;
duke@435 110 up:
duke@435 111 fild qword ptr [eax];
duke@435 112 fistp qword ptr [edx];
duke@435 113 add eax, 8;
duke@435 114 add edx, 8;
duke@435 115 uptest:
duke@435 116 sub ecx, 1;
duke@435 117 jge up;
duke@435 118 jmp done;
duke@435 119 down:
duke@435 120 fild qword ptr [eax][ecx*8];
duke@435 121 fistp qword ptr [edx][ecx*8];
duke@435 122 downtest:
duke@435 123 sub ecx, 1;
duke@435 124 jge down;
duke@435 125 done:;
duke@435 126 }
duke@435 127 #endif // AMD64
duke@435 128 }
duke@435 129
duke@435 130 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
duke@435 131 // Do better than this: inline memmove body NEEDS CLEANUP
duke@435 132 if (from > to) {
duke@435 133 while (count-- > 0) {
duke@435 134 // Copy forwards
duke@435 135 *to++ = *from++;
duke@435 136 }
duke@435 137 } else {
duke@435 138 from += count - 1;
duke@435 139 to += count - 1;
duke@435 140 while (count-- > 0) {
duke@435 141 // Copy backwards
duke@435 142 *to-- = *from--;
duke@435 143 }
duke@435 144 }
duke@435 145 }
duke@435 146
duke@435 147 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
duke@435 148 #ifdef AMD64
duke@435 149 pd_conjoint_bytes_atomic(from, to, count);
duke@435 150 #else
duke@435 151 pd_conjoint_bytes(from, to, count);
duke@435 152 #endif // AMD64
duke@435 153 }
duke@435 154
duke@435 155 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
duke@435 156 pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
duke@435 157 }
duke@435 158
duke@435 159 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
duke@435 160 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
duke@435 161 }
duke@435 162
duke@435 163 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
duke@435 164 pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
duke@435 165 }
duke@435 166
duke@435 167 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
duke@435 168 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
duke@435 169 }
stefank@2314 170
stefank@2314 171 #endif // OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP

mercurial