src/cpu/sparc/vm/copy_sparc.hpp

Mon, 25 Feb 2008 15:05:44 -0800

author
kvn
date
Mon, 25 Feb 2008 15:05:44 -0800
changeset 464
d5fc211aea19
parent 435
a61af66fc99e
child 548
ba764ed4b6f2
permissions
-rw-r--r--

6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
Summary: T_ADDRESS size is defined as 'int' size (4 bytes) but C2 use it for raw pointers and as memory type for StoreP and LoadP nodes.
Reviewed-by: jrose

     1 /*
     2  * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     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
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // Inline functions for memory copy and fill.
    27 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    28   (void)memmove(to, from, count * HeapWordSize);
    29 }
    31 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    32   switch (count) {
    33   case 8:  to[7] = from[7];
    34   case 7:  to[6] = from[6];
    35   case 6:  to[5] = from[5];
    36   case 5:  to[4] = from[4];
    37   case 4:  to[3] = from[3];
    38   case 3:  to[2] = from[2];
    39   case 2:  to[1] = from[1];
    40   case 1:  to[0] = from[0];
    41   case 0:  break;
    42   default: (void)memcpy(to, from, count * HeapWordSize);
    43            break;
    44   }
    45 }
    47 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
    48   switch (count) {
    49   case 8:  to[7] = from[7];
    50   case 7:  to[6] = from[6];
    51   case 6:  to[5] = from[5];
    52   case 5:  to[4] = from[4];
    53   case 4:  to[3] = from[3];
    54   case 3:  to[2] = from[2];
    55   case 2:  to[1] = from[1];
    56   case 1:  to[0] = from[0];
    57   case 0:  break;
    58   default: while (count-- > 0) {
    59              *to++ = *from++;
    60            }
    61            break;
    62   }
    63 }
    65 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    66   (void)memmove(to, from, count * HeapWordSize);
    67 }
    69 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
    70   pd_disjoint_words(from, to, count);
    71 }
    73 static void pd_conjoint_bytes(void* from, void* to, size_t count) {
    74   (void)memmove(to, from, count);
    75 }
    77 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) {
    78   (void)memmove(to, from, count);
    79 }
    81 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
    82   // FIXME
    83   (void)memmove(to, from, count << LogBytesPerShort);
    84 }
    86 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
    87   // FIXME
    88   (void)memmove(to, from, count << LogBytesPerInt);
    89 }
    91 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
    92 #ifdef _LP64
    93   assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size");
    94   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
    95 #else
    96   // Guarantee use of ldd/std via some asm code, because compiler won't.
    97   // See solaris_sparc.il.
    98   _Copy_conjoint_jlongs_atomic(from, to, count);
    99 #endif
   100 }
   102 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {
   103   // Do better than this: inline memmove body  NEEDS CLEANUP
   104   if (from > to) {
   105     while (count-- > 0) {
   106       // Copy forwards
   107       *to++ = *from++;
   108     }
   109   } else {
   110     from += count - 1;
   111     to   += count - 1;
   112     while (count-- > 0) {
   113       // Copy backwards
   114       *to-- = *from--;
   115     }
   116   }
   117 }
   119 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) {
   120   pd_conjoint_bytes_atomic(from, to, count);
   121 }
   123 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
   124   pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count);
   125 }
   127 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
   128   pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
   129 }
   131 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
   132   pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count);
   133 }
   135 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
   136   pd_conjoint_oops_atomic((oop*)from, (oop*)to, count);
   137 }
   139 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) {
   140 #if 0
   141   if (HeapWordsPerLong == 1 ||
   142       (HeapWordsPerLong == 2 &&
   143        mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0 &&
   144        ((count & 1) ? false : count >>= 1))) {
   145     julong* to = (julong*)tohw;
   146     julong  v  = ((julong)value << 32) | value;
   147     while (count-- > 0) {
   148       *to++ = v;
   149     }
   150   } else {
   151 #endif
   152     juint* to = (juint*)tohw;
   153     count *= HeapWordSize / BytesPerInt;
   154     while (count-- > 0) {
   155       *to++ = value;
   156     }
   157     //  }
   158 }
   160 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) {
   161   assert(MinObjAlignmentInBytes == BytesPerLong, "need alternate implementation");
   163    julong* to = (julong*)tohw;
   164    julong  v  = ((julong)value << 32) | value;
   165    // If count is odd, odd will be equal to 1 on 32-bit platform
   166    // and be equal to 0 on 64-bit platform.
   167    size_t odd = count % (BytesPerLong / HeapWordSize) ;
   169    size_t aligned_count = align_object_size(count - odd) / HeapWordsPerLong;
   170    julong* end = ((julong*)tohw) + aligned_count - 1;
   171    while (to <= end) {
   172      DEBUG_ONLY(count -= BytesPerLong / HeapWordSize ;)
   173      *to++ = v;
   174    }
   175    assert(count == odd, "bad bounds on loop filling to aligned words");
   176    if (odd) {
   177      *((juint*)to) = value;
   179    }
   180 }
   182 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) {
   183   (void)memset(to, value, count);
   184 }
   186 static void pd_zero_to_words(HeapWord* tohw, size_t count) {
   187   pd_fill_to_words(tohw, count, 0);
   188 }
   190 static void pd_zero_to_bytes(void* to, size_t count) {
   191   (void)memset(to, 0, count);
   192 }

mercurial