annotate src/share/vm/utilities/copy.hpp @ 8733:9def4075da6d

8008079: G1: Add nextObject routine to CMBitMapRO and replace nextWord Summary: Update the task local finger to the start of the next object when marking aborts, in order to avoid the redundant scanning of all 0's when the marking task restarts, if otherwise updating to the next word. In addition, reuse the routine nextObject() in routine iterate(). Reviewed-by: johnc, ysr Contributed-by: tamao <tao.mao@oracle.com>
author tamao
date Tue, 05 Mar 2013 15:36:56 -0800
parents 1d1603768966
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
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
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
25 #ifndef SHARE_VM_UTILITIES_COPY_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
26 #define SHARE_VM_UTILITIES_COPY_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
28 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
29
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Assembly code for platforms that need it.
a61af66fc99e Initial load
duke
parents:
diff changeset
31 extern "C" {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 void _Copy_conjoint_words(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
33 void _Copy_disjoint_words(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 void _Copy_conjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
36 void _Copy_disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 void _Copy_aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
39 void _Copy_aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 void _Copy_conjoint_bytes(void* from, void* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 void _Copy_conjoint_bytes_atomic (void* from, void* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 void _Copy_conjoint_jints_atomic (jint* from, jint* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 void _Copy_conjoint_jlongs_atomic (jlong* from, jlong* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 void _Copy_conjoint_oops_atomic (oop* from, oop* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void _Copy_arrayof_conjoint_bytes (HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void _Copy_arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void _Copy_arrayof_conjoint_jints (HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void _Copy_arrayof_conjoint_jlongs (HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 void _Copy_arrayof_conjoint_oops (HeapWord* from, HeapWord* to, size_t count);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 class Copy : AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Block copy methods have four attributes. We don't define all possibilities.
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
59 // alignment: aligned to BytesPerLong
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // arrayof: arraycopy operation with both operands aligned on the same
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // boundary as the first element of an array of the copy unit.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // This is currently a HeapWord boundary on all platforms, except
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // for long and double arrays, which are aligned on an 8-byte
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // boundary on all platforms.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // arraycopy operations are implicitly atomic on each array element.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // overlap: disjoint or conjoint.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // copy unit: bytes or words (i.e., HeapWords) or oops (i.e., pointers).
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // atomicity: atomic or non-atomic on the copy unit.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 //
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Names are constructed thusly:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 //
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // [ 'aligned_' | 'arrayof_' ]
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // ('conjoint_' | 'disjoint_')
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // ('words' | 'bytes' | 'jshorts' | 'jints' | 'jlongs' | 'oops')
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // [ '_atomic' ]
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Except in the arrayof case, whatever the alignment is, we assume we can copy
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
78 // whole alignment units. E.g., if BytesPerLong is 2x word alignment, an odd
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // count may copy an extra word. In the arrayof case, we are allowed to copy
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // only the number of copy units specified.
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
81 //
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
82 // All callees check count for 0.
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
83 //
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // HeapWords
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Word-aligned words, conjoint, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
88 static void conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert_params_ok(from, to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 pd_conjoint_words(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Word-aligned words, disjoint, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
94 static void disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 assert_params_ok(from, to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert_disjoint(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 pd_disjoint_words(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Word-aligned words, disjoint, atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
101 static void disjoint_words_atomic(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 assert_params_ok(from, to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert_disjoint(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 pd_disjoint_words_atomic(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Object-aligned words, conjoint, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static void aligned_conjoint_words(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 assert_params_aligned(from, to);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 pd_aligned_conjoint_words(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Object-aligned words, disjoint, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
114 static void aligned_disjoint_words(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 assert_params_aligned(from, to);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 assert_disjoint(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 pd_aligned_disjoint_words(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // bytes, jshorts, jints, jlongs, oops
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // bytes, conjoint, not atomic on each byte (not that it matters)
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
123 static void conjoint_jbytes(void* from, void* to, size_t count) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
124 pd_conjoint_bytes(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // bytes, conjoint, atomic on each byte (not that it matters)
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
128 static void conjoint_jbytes_atomic(void* from, void* to, size_t count) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129 pd_conjoint_bytes(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // jshorts, conjoint, atomic on each jshort
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static void conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert_params_ok(from, to, LogBytesPerShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 pd_conjoint_jshorts_atomic(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // jints, conjoint, atomic on each jint
a61af66fc99e Initial load
duke
parents:
diff changeset
139 static void conjoint_jints_atomic(jint* from, jint* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 assert_params_ok(from, to, LogBytesPerInt);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 pd_conjoint_jints_atomic(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // jlongs, conjoint, atomic on each jlong
a61af66fc99e Initial load
duke
parents:
diff changeset
145 static void conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert_params_ok(from, to, LogBytesPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 pd_conjoint_jlongs_atomic(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // oops, conjoint, atomic on each oop
a61af66fc99e Initial load
duke
parents:
diff changeset
151 static void conjoint_oops_atomic(oop* from, oop* to, size_t count) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
152 assert_params_ok(from, to, LogBytesPerHeapOop);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153 pd_conjoint_oops_atomic(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
156 // overloaded for UseCompressedOops
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
157 static void conjoint_oops_atomic(narrowOop* from, narrowOop* to, size_t count) {
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
158 assert(sizeof(narrowOop) == sizeof(jint), "this cast is wrong");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
159 assert_params_ok(from, to, LogBytesPerInt);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
160 pd_conjoint_jints_atomic((jint*)from, (jint*)to, count);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
161 }
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
162
0
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // Copy a span of memory. If the span is an integral number of aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // longs, words, or ints, copy those units atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // The largest atomic transfer unit is 8 bytes, or the largest power
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // of two which divides all of from, to, and size, whichever is smaller.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 static void conjoint_memory_atomic(void* from, void* to, size_t size);
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // bytes, conjoint array, atomic on each byte (not that it matters)
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1579
diff changeset
170 static void arrayof_conjoint_jbytes(HeapWord* from, HeapWord* to, size_t count) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
171 pd_arrayof_conjoint_bytes(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // jshorts, conjoint array, atomic on each jshort
a61af66fc99e Initial load
duke
parents:
diff changeset
175 static void arrayof_conjoint_jshorts(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 assert_params_ok(from, to, LogBytesPerShort);
a61af66fc99e Initial load
duke
parents:
diff changeset
177 pd_arrayof_conjoint_jshorts(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // jints, conjoint array, atomic on each jint
a61af66fc99e Initial load
duke
parents:
diff changeset
181 static void arrayof_conjoint_jints(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 assert_params_ok(from, to, LogBytesPerInt);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 pd_arrayof_conjoint_jints(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // jlongs, conjoint array, atomic on each jlong
a61af66fc99e Initial load
duke
parents:
diff changeset
187 static void arrayof_conjoint_jlongs(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 assert_params_ok(from, to, LogBytesPerLong);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 pd_arrayof_conjoint_jlongs(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // oops, conjoint array, atomic on each oop
a61af66fc99e Initial load
duke
parents:
diff changeset
193 static void arrayof_conjoint_oops(HeapWord* from, HeapWord* to, size_t count) {
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
194 assert_params_ok(from, to, LogBytesPerHeapOop);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 pd_arrayof_conjoint_oops(from, to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Known overlap methods
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // Copy word-aligned words from higher to lower addresses, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
201 inline static void conjoint_words_to_lower(HeapWord* from, HeapWord* to, size_t byte_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // byte_count is in bytes to check its alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
203 assert_params_ok(from, to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert_byte_count_ok(byte_count, HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 assert(to <= from || from + count <= to, "do not overwrite source data");
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 while (count-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 *to++ = *from++;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Copy word-aligned words from lower to higher addresses, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
215 inline static void conjoint_words_to_higher(HeapWord* from, HeapWord* to, size_t byte_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // byte_count is in bytes to check its alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
217 assert_params_ok(from, to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 assert_byte_count_ok(byte_count, HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 size_t count = (size_t)round_to(byte_count, HeapWordSize) >> LogHeapWordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 assert(from <= to || to + count <= from, "do not overwrite source data");
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 from += count - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 to += count - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 while (count-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 *to-- = *from--;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228 }
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Fill methods
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Fill word-aligned words, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // set_words
a61af66fc99e Initial load
duke
parents:
diff changeset
234 static void fill_to_words(HeapWord* to, size_t count, juint value = 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 assert_params_ok(to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 pd_fill_to_words(to, count, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 static void fill_to_aligned_words(HeapWord* to, size_t count, juint value = 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 assert_params_aligned(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 pd_fill_to_aligned_words(to, count, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Fill bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
245 static void fill_to_bytes(void* to, size_t count, jubyte value = 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 pd_fill_to_bytes(to, count, value);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // Fill a span of memory. If the span is an integral number of aligned
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // longs, words, or ints, store to those units atomically.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // The largest atomic transfer unit is 8 bytes, or the largest power
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // of two which divides both to and size, whichever is smaller.
a61af66fc99e Initial load
duke
parents:
diff changeset
253 static void fill_to_memory_atomic(void* to, size_t size, jubyte value = 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Zero-fill methods
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // Zero word-aligned words, not atomic on each word
a61af66fc99e Initial load
duke
parents:
diff changeset
258 static void zero_to_words(HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 assert_params_ok(to, LogHeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 pd_zero_to_words(to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Zero bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
264 static void zero_to_bytes(void* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 pd_zero_to_bytes(to, count);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
269 static bool params_disjoint(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (from < to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return pointer_delta(to, from) >= count;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 return pointer_delta(from, to) >= count;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 // These methods raise a fatal if they detect a problem.
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 static void assert_disjoint(HeapWord* from, HeapWord* to, size_t count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
280 if (!params_disjoint(from, to, count))
a61af66fc99e Initial load
duke
parents:
diff changeset
281 basic_fatal("source and dest overlap");
a61af66fc99e Initial load
duke
parents:
diff changeset
282 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 static void assert_params_ok(void* from, void* to, intptr_t log_align) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (mask_bits((uintptr_t)from, right_n_bits(log_align)) != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
288 basic_fatal("not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 if (mask_bits((uintptr_t)to, right_n_bits(log_align)) != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
290 basic_fatal("not aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
291 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 static void assert_params_ok(HeapWord* to, intptr_t log_align) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
296 if (mask_bits((uintptr_t)to, right_n_bits(log_align)) != 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
297 basic_fatal("not word aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
298 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300 static void assert_params_aligned(HeapWord* from, HeapWord* to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 #ifdef ASSERT
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
302 if (mask_bits((uintptr_t)from, BytesPerLong-1) != 0)
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
303 basic_fatal("not long aligned");
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
304 if (mask_bits((uintptr_t)to, BytesPerLong-1) != 0)
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
305 basic_fatal("not long aligned");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
306 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 static void assert_params_aligned(HeapWord* to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 #ifdef ASSERT
1571
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
311 if (mask_bits((uintptr_t)to, BytesPerLong-1) != 0)
2d127394260e 6916623: Align object to 16 bytes to use Compressed Oops with java heap up to 64Gb
kvn
parents: 196
diff changeset
312 basic_fatal("not long aligned");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
313 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 static void assert_byte_count_ok(size_t byte_count, size_t unit_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
318 if ((size_t)round_to(byte_count, unit_size) != byte_count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 basic_fatal("byte count must be aligned");
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // Platform dependent implementations of the above methods.
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
325 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
326 # include "copy_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
327 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
328 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
329 # include "copy_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
330 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
331 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
332 # include "copy_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
333 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
334 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
335 # include "copy_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
336 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
337 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
338 # include "copy_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
339 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
340
0
a61af66fc99e Initial load
duke
parents:
diff changeset
341 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
342
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1603
diff changeset
343 #endif // SHARE_VM_UTILITIES_COPY_HPP