1 /*
   2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
   4  * Copyright (c) 2015, Linaro Ltd. All rights reserved.
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * This code is free software; you can redistribute it and/or modify it
   8  * under the terms of the GNU General Public License version 2 only, as
   9  * published by the Free Software Foundation.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  *
  25  */
  26 
  27 #ifndef OS_CPU_LINUX_AARCH32_VM_COPY_LINUX_AARCH32_INLINE_HPP
  28 #define OS_CPU_LINUX_AARCH32_VM_COPY_LINUX_AARCH32_INLINE_HPP
  29 
  30 static void pd_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
  31   (void)memmove(to, from, count * HeapWordSize);
  32 }
  33 
  34 static void pd_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
  35   switch (count) {
  36   case 8:  to[7] = from[7];
  37   case 7:  to[6] = from[6];
  38   case 6:  to[5] = from[5];
  39   case 5:  to[4] = from[4];
  40   case 4:  to[3] = from[3];
  41   case 3:  to[2] = from[2];
  42   case 2:  to[1] = from[1];
  43   case 1:  to[0] = from[0];
  44   case 0:  break;
  45   default:
  46     (void)memcpy(to, from, count * HeapWordSize);
  47     break;
  48   }
  49 }
  50 
  51 static void pd_disjoint_words_atomic(const HeapWord* from, HeapWord* to, size_t count) {
  52   switch (count) {
  53   case 8:  to[7] = from[7];
  54   case 7:  to[6] = from[6];
  55   case 6:  to[5] = from[5];
  56   case 5:  to[4] = from[4];
  57   case 4:  to[3] = from[3];
  58   case 3:  to[2] = from[2];
  59   case 2:  to[1] = from[1];
  60   case 1:  to[0] = from[0];
  61   case 0:  break;
  62   default:
  63     while (count-- > 0) {
  64       *to++ = *from++;
  65     }
  66     break;
  67   }
  68 }
  69 
  70 static void pd_aligned_conjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
  71   pd_conjoint_words(from, to, count);
  72 }
  73 
  74 static void pd_aligned_disjoint_words(const HeapWord* from, HeapWord* to, size_t count) {
  75   pd_disjoint_words(from, to, count);
  76 }
  77 
  78 static void pd_conjoint_bytes(const void* from, void* to, size_t count) {
  79   (void)memmove(to, from, count);
  80 }
  81 
  82 static void pd_conjoint_bytes_atomic(const void* from, void* to, size_t count) {
  83   pd_conjoint_bytes(from, to, count);
  84 }
  85 
  86 static void pd_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
  87   _Copy_conjoint_jshorts_atomic(from, to, count);
  88 }
  89 
  90 static void pd_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
  91   _Copy_conjoint_jints_atomic(from, to, count);
  92 }
  93 
  94 static void pd_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
  95   _Copy_conjoint_jlongs_atomic(from, to, count);
  96 }
  97 
  98 static void pd_conjoint_oops_atomic(const oop* from, oop* to, size_t count) {
  99   assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
 100   _Copy_conjoint_jints_atomic((jint*)from, (jint*)to, count);
 101 }
 102 
 103 static void pd_arrayof_conjoint_bytes(const HeapWord* from, HeapWord* to, size_t count) {
 104   _Copy_arrayof_conjoint_bytes(from, to, count);
 105 }
 106 
 107 static void pd_arrayof_conjoint_jshorts(const HeapWord* from, HeapWord* to, size_t count) {
 108   _Copy_arrayof_conjoint_jshorts(from, to, count);
 109 }
 110 
 111 static void pd_arrayof_conjoint_jints(const HeapWord* from, HeapWord* to, size_t count) {
 112    _Copy_arrayof_conjoint_jints(from, to, count);
 113 }
 114 
 115 static void pd_arrayof_conjoint_jlongs(const HeapWord* from, HeapWord* to, size_t count) {
 116   _Copy_arrayof_conjoint_jlongs(from, to, count);
 117 }
 118 
 119 static void pd_arrayof_conjoint_oops(const HeapWord* from, HeapWord* to, size_t count) {
 120   assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
 121   _Copy_arrayof_conjoint_jints(from, to, count);
 122 }
 123 
 124 #endif // OS_CPU_LINUX_AARCH32_VM_COPY_LINUX_AARCH32_INLINE_HPP