src/cpu/zero/vm/copy_zero.hpp

Fri, 12 Feb 2010 10:34:11 -0800

author
kvn
date
Fri, 12 Feb 2010 10:34:11 -0800
changeset 1691
c09ee209b65c
parent 1445
354d3184f6b2
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6926048: Improve Zero performance
Summary: Make Zero figure out result types in a similar way to C++ interpreter implementation.
Reviewed-by: kvn
Contributed-by: gbenson@redhat.com

     1 /*
     2  * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
     3  * Copyright 2007 Red Hat, Inc.
     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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    21  * CA 95054 USA or visit www.sun.com if you need additional information or
    22  * have any questions.
    23  *
    24  */
    26 // Inline functions for memory copy and fill.
    28 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    29   memmove(to, from, count * HeapWordSize);
    30 }
    32 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    33   switch (count) {
    34   case 8:  to[7] = from[7];
    35   case 7:  to[6] = from[6];
    36   case 6:  to[5] = from[5];
    37   case 5:  to[4] = from[4];
    38   case 4:  to[3] = from[3];
    39   case 3:  to[2] = from[2];
    40   case 2:  to[1] = from[1];
    41   case 1:  to[0] = from[0];
    42   case 0:  break;
    43   default:
    44     memcpy(to, from, count * HeapWordSize);
    45     break;
    46   }
    47 }
    49 static void pd_disjoint_words_atomic(HeapWord* from,
    50                                      HeapWord* to,
    51                                      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 }
    70 static void pd_aligned_conjoint_words(HeapWord* from,
    71                                       HeapWord* to,
    72                                       size_t count) {
    73   memmove(to, from, count * HeapWordSize);
    74 }
    76 static void pd_aligned_disjoint_words(HeapWord* from,
    77                                       HeapWord* to,
    78                                       size_t count) {
    79   pd_disjoint_words(from, to, count);
    80 }
    82 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
    83   memmove(to, from, count);
    84 }
    86 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
    87   memmove(to, from, count);
    88 }
    90 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
    91   _Copy_conjoint_jshorts_atomic(from, to, count);
    92 }
    94 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
    95   _Copy_conjoint_jints_atomic(from, to, count);
    96 }
    98 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
    99   _Copy_conjoint_jlongs_atomic(from, to, count);
   100 }
   102 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   103 #ifdef _LP64
   104   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   105   _Copy_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   106 #else
   107   assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
   108   _Copy_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   109 #endif // _LP64
   110 }
   112 static void pd_arrayof_conjoint_bytes(HeapWord* from,
   113                                       HeapWord* to,
   114                                       size_t    count) {
   115   _Copy_arrayof_conjoint_bytes(from, to, count);
   116 }
   118 static void pd_arrayof_conjoint_jshorts(HeapWord* from,
   119                                         HeapWord* to,
   120                                         size_t    count) {
   121   _Copy_arrayof_conjoint_jshorts(from, to, count);
   122 }
   124 static void pd_arrayof_conjoint_jints(HeapWord* from,
   125                                       HeapWord* to,
   126                                       size_t    count) {
   127   _Copy_arrayof_conjoint_jints(from, to, count);
   128 }
   130 static void pd_arrayof_conjoint_jlongs(HeapWord* from,
   131                                        HeapWord* to,
   132                                        size_t    count) {
   133   _Copy_arrayof_conjoint_jlongs(from, to, count);
   134 }
   136 static void pd_arrayof_conjoint_oops(HeapWord* from,
   137                                      HeapWord* to,
   138                                      size_t    count) {
   139 #ifdef _LP64
   140   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
   141   _Copy_arrayof_conjoint_jlongs(from, to, count);
   142 #else
   143   assert(BytesPerInt == BytesPerOop, "jints and oops must be the same size");
   144   _Copy_arrayof_conjoint_jints(from, to, count);
   145 #endif // _LP64
   146 }
   148 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
   149 #ifdef _LP64
   150   julong* to = (julong*) tohw;
   151   julong  v  = ((julong) value << 32) | value;
   152 #else
   153   juint* to = (juint*) tohw;
   154   juint  v  = value;
   155 #endif // _LP64
   157   while (count-- > 0) {
   158     *to++ = v;
   159   }
   160 }
   162 static void pd_fill_to_aligned_words(HeapWord* tohw,
   163                                      size_t    count,
   164                                      juint     value) {
   165   pd_fill_to_words(tohw, count, value);
   166 }
   168 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
   169   memset(to, value, count);
   170 }
   172 static void pd_zero_to_words(HeapWord* tohw, size_t count) {
   173   pd_fill_to_words(tohw, count, 0);
   174 }
   176 static void pd_zero_to_bytes(void* to, size_t count) {
   177   memset(to, 0, count);
   178 }

mercurial