src/hotspot/os_cpu/linux_x86/copy_linux_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, 2010, 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_LINUX_X86_VM_COPY_LINUX_X86_INLINE_HPP
    25 #ifndef OS_CPU_LINUX_X86_VM_COPY_LINUX_X86_INLINE_HPP
    26 #define OS_CPU_LINUX_X86_VM_COPY_LINUX_X86_INLINE_HPP
    26 #define OS_CPU_LINUX_X86_VM_COPY_LINUX_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 #ifdef AMD64
    29 #ifdef AMD64
    30   (void)memmove(to, from, count * HeapWordSize);
    30   (void)memmove(to, from, count * HeapWordSize);
    31 #else
    31 #else
    32   // Includes a zero-count check.
    32   // Includes a zero-count check.
    33   intx temp = 0;
    33   intx temp = 0;
    68                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
    68                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
    69                    : "memory", "flags");
    69                    : "memory", "flags");
    70 #endif // AMD64
    70 #endif // AMD64
    71 }
    71 }
    72 
    72 
    73 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    73 static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
    74 #ifdef AMD64
    74 #ifdef AMD64
    75   switch (count) {
    75   switch (count) {
    76   case 8:  to[7] = from[7];
    76   case 8:  to[7] = from[7];
    77   case 7:  to[6] = from[6];
    77   case 7:  to[6] = from[6];
    78   case 6:  to[5] = from[5];
    78   case 6:  to[5] = from[5];
   106                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
   106                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
   107                    : "memory", "cc");
   107                    : "memory", "cc");
   108 #endif // AMD64
   108 #endif // AMD64
   109 }
   109 }
   110 
   110 
   111 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
   111 static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
   112 #ifdef AMD64
   112 #ifdef AMD64
   113   switch (count) {
   113   switch (count) {
   114   case 8:  to[7] = from[7];
   114   case 8:  to[7] = from[7];
   115   case 7:  to[6] = from[6];
   115   case 7:  to[6] = from[6];
   116   case 6:  to[5] = from[5];
   116   case 6:  to[5] = from[5];
   130   // pd_disjoint_words is word-atomic in this implementation.
   130   // pd_disjoint_words is word-atomic in this implementation.
   131   pd_disjoint_words(from, to, count);
   131   pd_disjoint_words(from, to, count);
   132 #endif // AMD64
   132 #endif // AMD64
   133 }
   133 }
   134 
   134 
   135 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
   135 static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
   136   pd_conjoint_words(from, to, count);
   136   pd_conjoint_words(from, to, count);
   137 }
   137 }
   138 
   138 
   139 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
   139 static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
   140   pd_disjoint_words(from, to, count);
   140   pd_disjoint_words(from, to, count);
   141 }
   141 }
   142 
   142 
   143 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
   143 static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
   144 #ifdef AMD64
   144 #ifdef AMD64
   145   (void)memmove(to, from, count);
   145   (void)memmove(to, from, count);
   146 #else
   146 #else
   147   // Includes a zero-count check.
   147   // Includes a zero-count check.
   148   intx temp = 0;
   148   intx temp = 0;
   217                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
   217                    : "0"  (from), "1"  (to), "2"  (count), "3"  (temp)
   218                    : "memory", "flags", "%edx");
   218                    : "memory", "flags", "%edx");
   219 #endif // AMD64
   219 #endif // AMD64
   220 }
   220 }
   221 
   221 
   222 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
   222 static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
   223   pd_conjoint_bytes(from, to, count);
   223   pd_conjoint_bytes(from, to, count);
   224 }
   224 }
   225 
   225 
   226 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
   226 static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
   227   _Copy_conjoint_jshorts_atomic(from, to, count);
   227   _Copy_conjoint_jshorts_atomic(from, to, count);
   228 }
   228 }
   229 
   229 
   230 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
   230 static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
   231 #ifdef AMD64
   231 #ifdef AMD64
   232   _Copy_conjoint_jints_atomic(from, to, count);
   232   _Copy_conjoint_jints_atomic(from, to, count);
   233 #else
   233 #else
   234   assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
   234   assert(HeapWordSize == BytesPerInt, "heapwords and jints must be the same size");
   235   // pd_conjoint_words is word-atomic in this implementation.
   235   // pd_conjoint_words is word-atomic in this implementation.
   236   pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
   236   pd_conjoint_words((const HeapWord*)from, (HeapWord*)to, count);
   237 #endif // AMD64
   237 #endif // AMD64
   238 }
   238 }
   239 
   239 
   240 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
   240 static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
   241 #ifdef AMD64
   241 #ifdef AMD64
   242   _Copy_conjoint_jlongs_atomic(from, to, count);
   242   _Copy_conjoint_jlongs_atomic(from, to, count);
   243 #else
   243 #else
   244   // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
   244   // Guarantee use of fild/fistp or xmm regs via some asm code, because compilers won't.
   245   if (from > to) {
   245   if (from > to) {
   260     }
   260     }
   261   }
   261   }
   262 #endif // AMD64
   262 #endif // AMD64
   263 }
   263 }
   264 
   264 
   265 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   265 static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
   266 #ifdef AMD64
   266 #ifdef AMD64
   267   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   267   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   268   _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   268   _Copy_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
   269 #else
   269 #else
   270   assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size");
   270   assert(HeapWordSize == BytesPerOop, "heapwords and oops must be the same size");
   271   // pd_conjoint_words is word-atomic in this implementation.
   271   // pd_conjoint_words is word-atomic in this implementation.
   272   pd_conjoint_words((HeapWord*)from, (HeapWord*)to, count);
   272   pd_conjoint_words((const HeapWord*)from, (HeapWord*)to, count);
   273 #endif // AMD64
   273 #endif // AMD64
   274 }
   274 }
   275 
   275 
   276 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
   276 static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
   277   _Copy_arrayof_conjoint_bytes(from, to, count);
   277   _Copy_arrayof_conjoint_bytes(from, to, count);
   278 }
   278 }
   279 
   279 
   280 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
   280 static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
   281   _Copy_arrayof_conjoint_jshorts(from, to, count);
   281   _Copy_arrayof_conjoint_jshorts(from, to, count);
   282 }
   282 }
   283 
   283 
   284 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
   284 static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
   285 #ifdef AMD64
   285 #ifdef AMD64
   286    _Copy_arrayof_conjoint_jints(from, to, count);
   286    _Copy_arrayof_conjoint_jints(from, to, count);
   287 #else
   287 #else
   288   pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   288   pd_conjoint_jints_atomic((const jint*)from, (jint*)to, count);
   289 #endif // AMD64
   289 #endif // AMD64
   290 }
   290 }
   291 
   291 
   292 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
   292 static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
   293 #ifdef AMD64
   293 #ifdef AMD64
   294   _Copy_arrayof_conjoint_jlongs(from, to, count);
   294   _Copy_arrayof_conjoint_jlongs(from, to, count);
   295 #else
   295 #else
   296   pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   296   pd_conjoint_jlongs_atomic((const jlong*)from, (jlong*)to, count);
   297 #endif // AMD64
   297 #endif // AMD64
   298 }
   298 }
   299 
   299 
   300 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
   300 static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
   301 #ifdef AMD64
   301 #ifdef AMD64
   302   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   302   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   303   _Copy_arrayof_conjoint_jlongs(from, to, count);
   303   _Copy_arrayof_conjoint_jlongs(from, to, count);
   304 #else
   304 #else
   305   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
   305   pd_conjoint_oops_atomic((const oop*)from, (oop*)to, count);
   306 #endif // AMD64
   306 #endif // AMD64
   307 }
   307 }
   308 
   308 
   309 #endif // OS_CPU_LINUX_X86_VM_COPY_LINUX_X86_INLINE_HPP
   309 #endif // OS_CPU_LINUX_X86_VM_COPY_LINUX_X86_INLINE_HPP