Mercurial > hg > truffle
annotate src/cpu/sparc/vm/copy_sparc.hpp @ 614:3db67f76d308
Merge
author | acorn |
---|---|
date | Thu, 05 Mar 2009 22:07:29 -0500 |
parents | d1605aabd0a1 |
children | c18cbe5936b8 2d127394260e |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 */ | |
24 | |
25 // Inline functions for memory copy and fill. | |
26 | |
27 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
28 (void)memmove(to, from, count * HeapWordSize); | |
29 } | |
30 | |
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 } | |
46 | |
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 } | |
64 | |
65 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
66 (void)memmove(to, from, count * HeapWordSize); | |
67 } | |
68 | |
69 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
70 pd_disjoint_words(from, to, count); | |
71 } | |
72 | |
73 static void pd_conjoint_bytes(void* from, void* to, size_t count) { | |
74 (void)memmove(to, from, count); | |
75 } | |
76 | |
77 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { | |
78 (void)memmove(to, from, count); | |
79 } | |
80 | |
81 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { | |
82 // FIXME | |
83 (void)memmove(to, from, count << LogBytesPerShort); | |
84 } | |
85 | |
86 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) { | |
87 // FIXME | |
88 (void)memmove(to, from, count << LogBytesPerInt); | |
89 } | |
90 | |
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 } | |
101 | |
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 } | |
118 | |
119 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) { | |
120 pd_conjoint_bytes_atomic(from, to, count); | |
121 } | |
122 | |
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 } | |
126 | |
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 } | |
130 | |
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 } | |
134 | |
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 } | |
138 | |
139 static void pd_fill_to_words(HeapWord* tohw, size_t count, juint value) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
140 #ifdef _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
141 guarantee(mask_bits((uintptr_t)tohw, right_n_bits(LogBytesPerLong)) == 0, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
142 "unaligned fill words"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
143 julong* to = (julong*)tohw; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
144 julong v = ((julong)value << 32) | value; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
145 while (count-- > 0) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
146 *to++ = v; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
147 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
148 #else // _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
149 juint* to = (juint*)tohw; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
150 while (count-- > 0) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
151 *to++ = value; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
152 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
153 #endif // _LP64 |
0 | 154 } |
155 | |
156 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) { | |
157 assert(MinObjAlignmentInBytes == BytesPerLong, "need alternate implementation"); | |
158 | |
159 julong* to = (julong*)tohw; | |
160 julong v = ((julong)value << 32) | value; | |
161 // If count is odd, odd will be equal to 1 on 32-bit platform | |
162 // and be equal to 0 on 64-bit platform. | |
163 size_t odd = count % (BytesPerLong / HeapWordSize) ; | |
164 | |
165 size_t aligned_count = align_object_size(count - odd) / HeapWordsPerLong; | |
166 julong* end = ((julong*)tohw) + aligned_count - 1; | |
167 while (to <= end) { | |
168 DEBUG_ONLY(count -= BytesPerLong / HeapWordSize ;) | |
169 *to++ = v; | |
170 } | |
171 assert(count == odd, "bad bounds on loop filling to aligned words"); | |
172 if (odd) { | |
173 *((juint*)to) = value; | |
174 | |
175 } | |
176 } | |
177 | |
178 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) { | |
179 (void)memset(to, value, count); | |
180 } | |
181 | |
182 static void pd_zero_to_words(HeapWord* tohw, size_t count) { | |
183 pd_fill_to_words(tohw, count, 0); | |
184 } | |
185 | |
186 static void pd_zero_to_bytes(void* to, size_t count) { | |
187 (void)memset(to, 0, count); | |
188 } |