Mercurial > hg > truffle
annotate src/cpu/sparc/vm/copy_sparc.hpp @ 7216:5a95c784febf
fixed windows make files and VS2012-specific compilation issues
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Tue, 04 Dec 2012 11:14:23 +0100 |
parents | 16f9fa2bf76c |
children | 7f1743e1a14e |
rev | line source |
---|---|
0 | 1 /* |
4010
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
196
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef CPU_SPARC_VM_COPY_SPARC_HPP |
26 #define CPU_SPARC_VM_COPY_SPARC_HPP | |
27 | |
0 | 28 // Inline functions for memory copy and fill. |
29 | |
30 static void pd_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
31 (void)memmove(to, from, count * HeapWordSize); | |
32 } | |
33 | |
34 static void pd_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
35 switch (count) { | |
36 case 8: to[7] = from[7]; | |
37 case 7: to[6] = from[6]; | |
38 case 6: to[5] = from[5]; | |
39 case 5: to[4] = from[4]; | |
40 case 4: to[3] = from[3]; | |
41 case 3: to[2] = from[2]; | |
42 case 2: to[1] = from[1]; | |
43 case 1: to[0] = from[0]; | |
44 case 0: break; | |
45 default: (void)memcpy(to, from, count * HeapWordSize); | |
46 break; | |
47 } | |
48 } | |
49 | |
50 static void pd_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) { | |
51 switch (count) { | |
52 case 8: to[7] = from[7]; | |
53 case 7: to[6] = from[6]; | |
54 case 6: to[5] = from[5]; | |
55 case 5: to[4] = from[4]; | |
56 case 4: to[3] = from[3]; | |
57 case 3: to[2] = from[2]; | |
58 case 2: to[1] = from[1]; | |
59 case 1: to[0] = from[0]; | |
60 case 0: break; | |
61 default: while (count-- > 0) { | |
62 *to++ = *from++; | |
63 } | |
64 break; | |
65 } | |
66 } | |
67 | |
68 static void pd_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
69 (void)memmove(to, from, count * HeapWordSize); | |
70 } | |
71 | |
72 static void pd_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) { | |
73 pd_disjoint_words(from, to, count); | |
74 } | |
75 | |
76 static void pd_conjoint_bytes(void* from, void* to, size_t count) { | |
77 (void)memmove(to, from, count); | |
78 } | |
79 | |
80 static void pd_conjoint_bytes_atomic(void* from, void* to, size_t count) { | |
81 (void)memmove(to, from, count); | |
82 } | |
83 | |
84 static void pd_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { | |
4010
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
85 if (from > to) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
86 while (count-- > 0) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
87 // Copy forwards |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
88 *to++ = *from++; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
89 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
90 } else { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
91 from += count - 1; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
92 to += count - 1; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
93 while (count-- > 0) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
94 // Copy backwards |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
95 *to-- = *from--; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
96 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
97 } |
0 | 98 } |
99 | |
100 static void pd_conjoint_jints_atomic(jint* from, jint* to, size_t count) { | |
4010
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
101 if (from > to) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
102 while (count-- > 0) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
103 // Copy forwards |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
104 *to++ = *from++; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
105 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
106 } else { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
107 from += count - 1; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
108 to += count - 1; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
109 while (count-- > 0) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
110 // Copy backwards |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
111 *to-- = *from--; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
112 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
3892
diff
changeset
|
113 } |
0 | 114 } |
115 | |
116 static void pd_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { | |
117 #ifdef _LP64 | |
118 assert(BytesPerLong == BytesPerOop, "jlongs and oops must be the same size"); | |
119 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count); | |
120 #else | |
121 // Guarantee use of ldd/std via some asm code, because compiler won't. | |
122 // See solaris_sparc.il. | |
123 _Copy_conjoint_jlongs_atomic(from, to, count); | |
124 #endif | |
125 } | |
126 | |
127 static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) { | |
128 // Do better than this: inline memmove body NEEDS CLEANUP | |
129 if (from > to) { | |
130 while (count-- > 0) { | |
131 // Copy forwards | |
132 *to++ = *from++; | |
133 } | |
134 } else { | |
135 from += count - 1; | |
136 to += count - 1; | |
137 while (count-- > 0) { | |
138 // Copy backwards | |
139 *to-- = *from--; | |
140 } | |
141 } | |
142 } | |
143 | |
144 static void pd_arrayof_conjoint_bytes(HeapWord* from, HeapWord* to, size_t count) { | |
145 pd_conjoint_bytes_atomic(from, to, count); | |
146 } | |
147 | |
148 static void pd_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) { | |
149 pd_conjoint_jshorts_atomic((jshort*)from, (jshort*)to, count); | |
150 } | |
151 | |
152 static void pd_arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) { | |
153 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count); | |
154 } | |
155 | |
156 static void pd_arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) { | |
157 pd_conjoint_jlongs_atomic((jlong*)from, (jlong*)to, count); | |
158 } | |
159 | |
160 static void pd_arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) { | |
161 pd_conjoint_oops_atomic((oop*)from, (oop*)to, count); | |
162 } | |
163 | |
164 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
|
165 #ifdef _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
166 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
|
167 "unaligned fill words"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
168 julong* to = (julong*)tohw; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
169 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
|
170 while (count-- > 0) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
171 *to++ = v; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
172 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
173 #else // _LP64 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
174 juint* to = (juint*)tohw; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
175 while (count-- > 0) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
176 *to++ = value; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
177 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
178 #endif // _LP64 |
0 | 179 } |
180 | |
3892 | 181 typedef void (*_zero_Fn)(HeapWord* to, size_t count); |
182 | |
0 | 183 static void pd_fill_to_aligned_words(HeapWord* tohw, size_t count, juint value) { |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
196
diff
changeset
|
184 assert(MinObjAlignmentInBytes >= BytesPerLong, "need alternate implementation"); |
0 | 185 |
3892 | 186 if (value == 0 && UseBlockZeroing && |
187 (count > (BlockZeroingLowLimit >> LogHeapWordSize))) { | |
188 // Call it only when block zeroing is used | |
189 ((_zero_Fn)StubRoutines::zero_aligned_words())(tohw, count); | |
190 } else { | |
0 | 191 julong* to = (julong*)tohw; |
192 julong v = ((julong)value << 32) | value; | |
193 // If count is odd, odd will be equal to 1 on 32-bit platform | |
194 // and be equal to 0 on 64-bit platform. | |
195 size_t odd = count % (BytesPerLong / HeapWordSize) ; | |
196 | |
1571
2d127394260e
6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents:
196
diff
changeset
|
197 size_t aligned_count = align_object_offset(count - odd) / HeapWordsPerLong; |
0 | 198 julong* end = ((julong*)tohw) + aligned_count - 1; |
199 while (to <= end) { | |
200 DEBUG_ONLY(count -= BytesPerLong / HeapWordSize ;) | |
201 *to++ = v; | |
202 } | |
203 assert(count == odd, "bad bounds on loop filling to aligned words"); | |
204 if (odd) { | |
205 *((juint*)to) = value; | |
206 | |
207 } | |
3892 | 208 } |
0 | 209 } |
210 | |
211 static void pd_fill_to_bytes(void* to, size_t count, jubyte value) { | |
212 (void)memset(to, value, count); | |
213 } | |
214 | |
215 static void pd_zero_to_words(HeapWord* tohw, size_t count) { | |
216 pd_fill_to_words(tohw, count, 0); | |
217 } | |
218 | |
219 static void pd_zero_to_bytes(void* to, size_t count) { | |
220 (void)memset(to, 0, count); | |
221 } | |
1972 | 222 |
223 #endif // CPU_SPARC_VM_COPY_SPARC_HPP |