src/cpu/ppc/vm/copy_ppc.hpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 6876
710a3c8b516e
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2013 SAP AG. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #ifndef CPU_PPC_VM_COPY_PPC_HPP
    27 #define CPU_PPC_VM_COPY_PPC_HPP
    29 #ifndef PPC64
    30 #error "copy currently only implemented for PPC64"
    31 #endif
    33 // Inline functions for memory copy and fill.
    35 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    36   (void)memmove(to, from, count * HeapWordSize);
    37 }
    39 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    40   switch (count) {
    41   case 8:  to[7] = from[7];
    42   case 7:  to[6] = from[6];
    43   case 6:  to[5] = from[5];
    44   case 5:  to[4] = from[4];
    45   case 4:  to[3] = from[3];
    46   case 3:  to[2] = from[2];
    47   case 2:  to[1] = from[1];
    48   case 1:  to[0] = from[0];
    49   case 0:  break;
    50   default: (void)memcpy(to, from, count * HeapWordSize);
    51            break;
    52   }
    53 }
    55 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
    56   switch (count) {
    57   case 8:  to[7] = from[7];
    58   case 7:  to[6] = from[6];
    59   case 6:  to[5] = from[5];
    60   case 5:  to[4] = from[4];
    61   case 4:  to[3] = from[3];
    62   case 3:  to[2] = from[2];
    63   case 2:  to[1] = from[1];
    64   case 1:  to[0] = from[0];
    65   case 0:  break;
    66   default: while (count-- > 0) {
    67              *to++ = *from++;
    68            }
    69            break;
    70   }
    71 }
    73 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    74   (void)memmove(to, from, count * HeapWordSize);
    75 }
    77 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    78   pd_disjoint_words(from, to, count);
    79 }
    81 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
    82   (void)memmove(to, from, count);
    83 }
    85 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
    86   (void)memmove(to, from, count);
    87 }
    89 // Template for atomic, element-wise copy.
    90 template <class T>
    91 static void copy_conjoint_atomic(T* from, T* to, size_t count) {
    92   if (from > to) {
    93     while (count-- > 0) {
    94       // Copy forwards
    95       *to++ = *from++;
    96     }
    97   } else {
    98     from += count - 1;
    99     to   += count - 1;
   100     while (count-- > 0) {
   101       // Copy backwards
   102       *to-- = *from--;
   103     }
   104   }
   105 }
   107 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
   108   // TODO: contribute optimized version.
   109   copy_conjoint_atomic<jshort>(from, to, count);
   110 }
   112 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
   113   // TODO: contribute optimized version.
   114   copy_conjoint_atomic<jint>(from, to, count);
   115 }
   117 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
   118   copy_conjoint_atomic<jlong>(from, to, count);
   119 }
   121 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   122   copy_conjoint_atomic<oop>(from, to, count);
   123 }
   125 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
   126   pd_conjoint_bytes_atomic(from, to, count);
   127 }
   129 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
   130   // TODO: contribute optimized version.
   131   pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
   132 }
   134 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
   135   // TODO: contribute optimized version.
   136   pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   137 }
   139 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
   140   pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   141 }
   143 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
   144   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
   145 }
   147 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
   148   julong* to = (julong*)tohw;
   149   julong  v  = ((julong)value << 32) | value;
   150   while (count-- > 0) {
   151     *to++ = v;
   152   }
   153 }
   155 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
   156   pd_fill_to_words(tohw, count, value);
   157 }
   159 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
   160   (void)memset(to, value, count);
   161 }
   163 static void pd_zero_to_words(HeapWord* tohw, size_t count) {
   164   pd_fill_to_words(tohw, count, 0);
   165 }
   167 static void pd_zero_to_bytes(void* to, size_t count) {
   168   (void)memset(to, 0, count);
   169 }
   171 #endif // CPU_PPC_VM_COPY_PPC_HPP

mercurial