src/cpu/zero/vm/copy_zero.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cpu/zero/vm/copy_zero.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,183 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright 2007 Red Hat, Inc.
     1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 + *
     1.9 + * This code is free software; you can redistribute it and/or modify it
    1.10 + * under the terms of the GNU General Public License version 2 only, as
    1.11 + * published by the Free Software Foundation.
    1.12 + *
    1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 + * version 2 for more details (a copy is included in the LICENSE file that
    1.17 + * accompanied this code).
    1.18 + *
    1.19 + * You should have received a copy of the GNU General Public License version
    1.20 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 + *
    1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 + * or visit www.oracle.com if you need additional information or have any
    1.25 + * questions.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +#ifndef CPU_ZERO_VM_COPY_ZERO_HPP
    1.30 +#define CPU_ZERO_VM_COPY_ZERO_HPP
    1.31 +
    1.32 +// Inline functions for memory copy and fill.
    1.33 +
    1.34 +static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    1.35 +  memmove(to, from, count * HeapWordSize);
    1.36 +}
    1.37 +
    1.38 +static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    1.39 +  switch (count) {
    1.40 +  case 8:  to[7] = from[7];
    1.41 +  case 7:  to[6] = from[6];
    1.42 +  case 6:  to[5] = from[5];
    1.43 +  case 5:  to[4] = from[4];
    1.44 +  case 4:  to[3] = from[3];
    1.45 +  case 3:  to[2] = from[2];
    1.46 +  case 2:  to[1] = from[1];
    1.47 +  case 1:  to[0] = from[0];
    1.48 +  case 0:  break;
    1.49 +  default:
    1.50 +    memcpy(to, from, count * HeapWordSize);
    1.51 +    break;
    1.52 +  }
    1.53 +}
    1.54 +
    1.55 +static void pd_disjoint_words_atomic(HeapWord* from,
    1.56 +                                     HeapWord* to,
    1.57 +                                     size_t count) {
    1.58 +  switch (count) {
    1.59 +  case 8:  to[7] = from[7];
    1.60 +  case 7:  to[6] = from[6];
    1.61 +  case 6:  to[5] = from[5];
    1.62 +  case 5:  to[4] = from[4];
    1.63 +  case 4:  to[3] = from[3];
    1.64 +  case 3:  to[2] = from[2];
    1.65 +  case 2:  to[1] = from[1];
    1.66 +  case 1:  to[0] = from[0];
    1.67 +  case 0:  break;
    1.68 +  default:
    1.69 +    while (count-- > 0) {
    1.70 +      *to++ = *from++;
    1.71 +    }
    1.72 +    break;
    1.73 +  }
    1.74 +}
    1.75 +
    1.76 +static void pd_aligned_conjoint_words(HeapWord* from,
    1.77 +                                      HeapWord* to,
    1.78 +                                      size_t count) {
    1.79 +  memmove(to, from, count * HeapWordSize);
    1.80 +}
    1.81 +
    1.82 +static void pd_aligned_disjoint_words(HeapWord* from,
    1.83 +                                      HeapWord* to,
    1.84 +                                      size_t count) {
    1.85 +  pd_disjoint_words(from, to, count);
    1.86 +}
    1.87 +
    1.88 +static void pd_conjoint_bytes(void* from, void* to, size_t count) {
    1.89 +  memmove(to, from, count);
    1.90 +}
    1.91 +
    1.92 +static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
    1.93 +  memmove(to, from, count);
    1.94 +}
    1.95 +
    1.96 +static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
    1.97 +  _Copy_conjoint_jshorts_atomic(from, to, count);
    1.98 +}
    1.99 +
   1.100 +static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
   1.101 +  _Copy_conjoint_jints_atomic(from, to, count);
   1.102 +}
   1.103 +
   1.104 +static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
   1.105 +  _Copy_conjoint_jlongs_atomic(from, to, count);
   1.106 +}
   1.107 +
   1.108 +static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   1.109 +#ifdef _LP64
   1.110 +  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   1.111 +  _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   1.112 +#else
   1.113 +  assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
   1.114 +  _Copy_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   1.115 +#endif // _LP64
   1.116 +}
   1.117 +
   1.118 +static void pd_arrayof_conjoint_bytes(HeapWord* from,
   1.119 +                                      HeapWord* to,
   1.120 +                                      size_t    count) {
   1.121 +  _Copy_arrayof_conjoint_bytes(from, to, count);
   1.122 +}
   1.123 +
   1.124 +static void pd_arrayof_conjoint_jshorts(HeapWord* from,
   1.125 +                                        HeapWord* to,
   1.126 +                                        size_t    count) {
   1.127 +  _Copy_arrayof_conjoint_jshorts(from, to, count);
   1.128 +}
   1.129 +
   1.130 +static void pd_arrayof_conjoint_jints(HeapWord* from,
   1.131 +                                      HeapWord* to,
   1.132 +                                      size_t    count) {
   1.133 +  _Copy_arrayof_conjoint_jints(from, to, count);
   1.134 +}
   1.135 +
   1.136 +static void pd_arrayof_conjoint_jlongs(HeapWord* from,
   1.137 +                                       HeapWord* to,
   1.138 +                                       size_t    count) {
   1.139 +  _Copy_arrayof_conjoint_jlongs(from, to, count);
   1.140 +}
   1.141 +
   1.142 +static void pd_arrayof_conjoint_oops(HeapWord* from,
   1.143 +                                     HeapWord* to,
   1.144 +                                     size_t    count) {
   1.145 +#ifdef _LP64
   1.146 +  assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   1.147 +  _Copy_arrayof_conjoint_jlongs(from, to, count);
   1.148 +#else
   1.149 +  assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
   1.150 +  _Copy_arrayof_conjoint_jints(from, to, count);
   1.151 +#endif // _LP64
   1.152 +}
   1.153 +
   1.154 +static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
   1.155 +#ifdef _LP64
   1.156 +  julong* to = (julong*) tohw;
   1.157 +  julong  v  = ((julong) value << 32) | value;
   1.158 +#else
   1.159 +  juint* to = (juint*) tohw;
   1.160 +  juint  v  = value;
   1.161 +#endif // _LP64
   1.162 +
   1.163 +  while (count-- > 0) {
   1.164 +    *to++ = v;
   1.165 +  }
   1.166 +}
   1.167 +
   1.168 +static void pd_fill_to_aligned_words(HeapWord* tohw,
   1.169 +                                     size_t    count,
   1.170 +                                     juint     value) {
   1.171 +  pd_fill_to_words(tohw, count, value);
   1.172 +}
   1.173 +
   1.174 +static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
   1.175 +  memset(to, value, count);
   1.176 +}
   1.177 +
   1.178 +static void pd_zero_to_words(HeapWord* tohw, size_t count) {
   1.179 +  pd_fill_to_words(tohw, count, 0);
   1.180 +}
   1.181 +
   1.182 +static void pd_zero_to_bytes(void* to, size_t count) {
   1.183 +  memset(to, 0, count);
   1.184 +}
   1.185 +
   1.186 +#endif // CPU_ZERO_VM_COPY_ZERO_HPP

mercurial