src/hotspot/os_cpu/windows_x86/copy_windows_x86.inline.hpp
changeset 48951 950c35ea6237
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
equal deleted inserted replaced
48950:f323537c9b75 48951:950c35ea6237
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    23  */
    23  */
    24 
    24 
    25 #ifndef OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
    25 #ifndef OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
    26 #define OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
    26 #define OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
    27 
    27 
    28 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    28 static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
    29   (void)memmove(to, from, count * HeapWordSize);
    29   (void)memmove(to, from, count * HeapWordSize);
    30 }
    30 }
    31 
    31 
    32 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    32 static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
    33 #ifdef AMD64
    33 #ifdef AMD64
    34   switch (count) {
    34   switch (count) {
    35   case 8:  to[7] = from[7];
    35   case 8:  to[7] = from[7];
    36   case 7:  to[6] = from[6];
    36   case 7:  to[6] = from[6];
    37   case 6:  to[5] = from[5];
    37   case 6:  to[5] = from[5];
    48 #else
    48 #else
    49   (void)memcpy(to, from, count * HeapWordSize);
    49   (void)memcpy(to, from, count * HeapWordSize);
    50 #endif // AMD64
    50 #endif // AMD64
    51 }
    51 }
    52 
    52 
    53 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
    53 static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
    54   switch (count) {
    54   switch (count) {
    55   case 8:  to[7] = from[7];
    55   case 8:  to[7] = from[7];
    56   case 7:  to[6] = from[6];
    56   case 7:  to[6] = from[6];
    57   case 6:  to[5] = from[5];
    57   case 6:  to[5] = from[5];
    58   case 5:  to[4] = from[4];
    58   case 5:  to[4] = from[4];
    66            }
    66            }
    67            break;
    67            break;
    68   }
    68   }
    69 }
    69 }
    70 
    70 
    71 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    71 static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
    72   (void)memmove(to, from, count * HeapWordSize);
    72   (void)memmove(to, from, count * HeapWordSize);
    73 }
    73 }
    74 
    74 
    75 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    75 static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
    76   pd_disjoint_words(from, to, count);
    76   pd_disjoint_words(from, to, count);
    77 }
    77 }
    78 
    78 
    79 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
    79 static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
    80   (void)memmove(to, from, count);
    80   (void)memmove(to, from, count);
    81 }
    81 }
    82 
    82 
    83 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
    83 static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
    84   pd_conjoint_bytes(from, to, count);
    84   pd_conjoint_bytes(from, to, count);
    85 }
    85 }
    86 
    86 
    87 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
    87 static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
    88   if (from > to) {
    88   if (from > to) {
    89     while (count-- > 0) {
    89     while (count-- > 0) {
    90       // Copy forwards
    90       // Copy forwards
    91       *to++ = *from++;
    91       *to++ = *from++;
    92     }
    92     }
    98       *to-- = *from--;
    98       *to-- = *from--;
    99     }
    99     }
   100   }
   100   }
   101 }
   101 }
   102 
   102 
   103 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
   103 static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
   104   if (from > to) {
   104   if (from > to) {
   105     while (count-- > 0) {
   105     while (count-- > 0) {
   106       // Copy forwards
   106       // Copy forwards
   107       *to++ = *from++;
   107       *to++ = *from++;
   108     }
   108     }
   114       *to-- = *from--;
   114       *to-- = *from--;
   115     }
   115     }
   116   }
   116   }
   117 }
   117 }
   118 
   118 
   119 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
   119 static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
   120 #ifdef AMD64
   120 #ifdef AMD64
   121   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   121   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   122   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
   122   pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
   123 #else
   123 #else
   124   // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
   124   // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
   125   __asm {
   125   __asm {
   126     mov    eax, from;
   126     mov    eax, from;
   127     mov    edx, to;
   127     mov    edx, to;
   147   done:;
   147   done:;
   148   }
   148   }
   149 #endif // AMD64
   149 #endif // AMD64
   150 }
   150 }
   151 
   151 
   152 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   152 static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
   153   // Do better than this: inline memmove body  NEEDS CLEANUP
   153   // Do better than this: inline memmove body  NEEDS CLEANUP
   154   if (from > to) {
   154   if (from > to) {
   155     while (count-- > 0) {
   155     while (count-- > 0) {
   156       // Copy forwards
   156       // Copy forwards
   157       *to++ = *from++;
   157       *to++ = *from++;
   164       *to-- = *from--;
   164       *to-- = *from--;
   165     }
   165     }
   166   }
   166   }
   167 }
   167 }
   168 
   168 
   169 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
   169 static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
   170 #ifdef AMD64
   170 #ifdef AMD64
   171   pd_conjoint_bytes_atomic(from, to, count);
   171   pd_conjoint_bytes_atomic(from, to, count);
   172 #else
   172 #else
   173   pd_conjoint_bytes(from, to, count);
   173   pd_conjoint_bytes(from, to, count);
   174 #endif // AMD64
   174 #endif // AMD64
   175 }
   175 }
   176 
   176 
   177 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
   177 static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
   178   pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
   178   pd_conjoint_jshorts_atomic((const jshort*)from, (jshort*)to, count);
   179 }
   179 }
   180 
   180 
   181 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
   181 static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
   182   pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   182   pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count);
   183 }
   183 }
   184 
   184 
   185 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
   185 static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
   186   pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   186   pd_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
   187 }
   187 }
   188 
   188 
   189 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
   189 static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
   190   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
   190   pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
   191 }
   191 }
   192 
   192 
   193 #endif // OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP
   193 #endif // OS_CPU_WINDOWS_X86_VM_COPY_WINDOWS_X86_INLINE_HPP