Mercurial > hg > graal-jvmci-8
comparison test/compiler/8004867/TestIntUnsafeCAS.java @ 8079:ad736b4683b4
8004867: VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
Summary: Added few checks and early bailout from Superword optimization to avoid such cases in a future.
Reviewed-by: roland, twisti
author | kvn |
---|---|
date | Mon, 18 Feb 2013 16:47:15 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
8078:a2bc322ca273 | 8079:ad736b4683b4 |
---|---|
1 /* | |
2 * Copyright (c) 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 /** | |
26 * @test | |
27 * @bug 8004867 | |
28 * @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob" | |
29 * | |
30 * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS | |
31 * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS | |
32 */ | |
33 | |
34 import sun.misc.Unsafe; | |
35 import java.lang.reflect.*; | |
36 | |
37 public class TestIntUnsafeCAS { | |
38 private static final int ARRLEN = 97; | |
39 private static final int ITERS = 11000; | |
40 private static final int OFFSET = 3; | |
41 private static final int SCALE = 2; | |
42 private static final int ALIGN_OFF = 8; | |
43 private static final int UNALIGN_OFF = 5; | |
44 | |
45 private static final Unsafe unsafe; | |
46 private static final int BASE; | |
47 static { | |
48 try { | |
49 Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe"); | |
50 Field f = c.getDeclaredField("theUnsafe"); | |
51 f.setAccessible(true); | |
52 unsafe = (Unsafe)f.get(c); | |
53 BASE = unsafe.arrayBaseOffset(int[].class); | |
54 } catch (Exception e) { | |
55 InternalError err = new InternalError(); | |
56 err.initCause(e); | |
57 throw err; | |
58 } | |
59 } | |
60 | |
61 public static void main(String args[]) { | |
62 System.out.println("Testing Integer array unsafe CAS operations"); | |
63 int errn = test(false); | |
64 if (errn > 0) { | |
65 System.err.println("FAILED: " + errn + " errors"); | |
66 System.exit(97); | |
67 } | |
68 System.out.println("PASSED"); | |
69 } | |
70 | |
71 static int test(boolean test_only) { | |
72 int[] a1 = new int[ARRLEN]; | |
73 int[] a2 = new int[ARRLEN]; | |
74 // Initialize | |
75 for (int i=0; i<ARRLEN; i++) { | |
76 a1[i] = -1; | |
77 a2[i] = -1; | |
78 } | |
79 System.out.println("Warmup"); | |
80 for (int i=0; i<ITERS; i++) { | |
81 test_ci(a1); | |
82 test_vi(a2, 123, -1); | |
83 test_cp(a1, a2); | |
84 test_2ci(a1, a2); | |
85 test_2vi(a1, a2, 123, 103); | |
86 test_ci_neg(a1, 123); | |
87 test_vi_neg(a2, 123, 103); | |
88 test_cp_neg(a1, a2); | |
89 test_2ci_neg(a1, a2); | |
90 test_2vi_neg(a1, a2, 123, 103); | |
91 test_ci_oppos(a1, 123); | |
92 test_vi_oppos(a2, 123, 103); | |
93 test_cp_oppos(a1, a2); | |
94 test_2ci_oppos(a1, a2); | |
95 test_2vi_oppos(a1, a2, 123, 103); | |
96 test_ci_off(a1, 123); | |
97 test_vi_off(a2, 123, 103); | |
98 test_cp_off(a1, a2); | |
99 test_2ci_off(a1, a2); | |
100 test_2vi_off(a1, a2, 123, 103); | |
101 test_ci_inv(a1, OFFSET, 123); | |
102 test_vi_inv(a2, 123, OFFSET, 103); | |
103 test_cp_inv(a1, a2, OFFSET); | |
104 test_2ci_inv(a1, a2, OFFSET); | |
105 test_2vi_inv(a1, a2, 123, 103, OFFSET); | |
106 test_ci_scl(a1, 123); | |
107 test_vi_scl(a2, 123, 103); | |
108 test_cp_scl(a1, a2); | |
109 test_2ci_scl(a1, a2); | |
110 test_2vi_scl(a1, a2, 123, 103); | |
111 test_cp_alndst(a1, a2); | |
112 test_cp_alnsrc(a1, a2); | |
113 test_2ci_aln(a1, a2); | |
114 test_2vi_aln(a1, a2, 123, 103); | |
115 test_cp_unalndst(a1, a2); | |
116 test_cp_unalnsrc(a1, a2); | |
117 test_2ci_unaln(a1, a2); | |
118 test_2vi_unaln(a1, a2, 123, 103); | |
119 } | |
120 // Initialize | |
121 for (int i=0; i<ARRLEN; i++) { | |
122 a1[i] = -1; | |
123 a2[i] = -1; | |
124 } | |
125 // Test and verify results | |
126 System.out.println("Verification"); | |
127 int errn = 0; | |
128 { | |
129 test_ci(a1); | |
130 for (int i=0; i<ARRLEN; i++) { | |
131 errn += verify("test_ci: a1", i, a1[i], -123); | |
132 } | |
133 test_vi(a2, 123, -1); | |
134 for (int i=0; i<ARRLEN; i++) { | |
135 errn += verify("test_vi: a2", i, a2[i], 123); | |
136 } | |
137 test_cp(a1, a2); | |
138 for (int i=0; i<ARRLEN; i++) { | |
139 errn += verify("test_cp: a1", i, a1[i], 123); | |
140 } | |
141 test_2ci(a1, a2); | |
142 for (int i=0; i<ARRLEN; i++) { | |
143 errn += verify("test_2ci: a1", i, a1[i], -123); | |
144 errn += verify("test_2ci: a2", i, a2[i], -103); | |
145 } | |
146 test_2vi(a1, a2, 123, 103); | |
147 for (int i=0; i<ARRLEN; i++) { | |
148 errn += verify("test_2vi: a1", i, a1[i], 123); | |
149 errn += verify("test_2vi: a2", i, a2[i], 103); | |
150 } | |
151 // Reset for negative stride | |
152 for (int i=0; i<ARRLEN; i++) { | |
153 a1[i] = -1; | |
154 a2[i] = -1; | |
155 } | |
156 test_ci_neg(a1, -1); | |
157 for (int i=0; i<ARRLEN; i++) { | |
158 errn += verify("test_ci_neg: a1", i, a1[i], -123); | |
159 } | |
160 test_vi_neg(a2, 123, -1); | |
161 for (int i=0; i<ARRLEN; i++) { | |
162 errn += verify("test_vi_neg: a2", i, a2[i], 123); | |
163 } | |
164 test_cp_neg(a1, a2); | |
165 for (int i=0; i<ARRLEN; i++) { | |
166 errn += verify("test_cp_neg: a1", i, a1[i], 123); | |
167 } | |
168 test_2ci_neg(a1, a2); | |
169 for (int i=0; i<ARRLEN; i++) { | |
170 errn += verify("test_2ci_neg: a1", i, a1[i], -123); | |
171 errn += verify("test_2ci_neg: a2", i, a2[i], -103); | |
172 } | |
173 test_2vi_neg(a1, a2, 123, 103); | |
174 for (int i=0; i<ARRLEN; i++) { | |
175 errn += verify("test_2vi_neg: a1", i, a1[i], 123); | |
176 errn += verify("test_2vi_neg: a2", i, a2[i], 103); | |
177 } | |
178 // Reset for opposite stride | |
179 for (int i=0; i<ARRLEN; i++) { | |
180 a1[i] = -1; | |
181 a2[i] = -1; | |
182 } | |
183 test_ci_oppos(a1, -1); | |
184 for (int i=0; i<ARRLEN; i++) { | |
185 errn += verify("test_ci_oppos: a1", i, a1[i], -123); | |
186 } | |
187 test_vi_oppos(a2, 123, -1); | |
188 for (int i=0; i<ARRLEN; i++) { | |
189 errn += verify("test_vi_oppos: a2", i, a2[i], 123); | |
190 } | |
191 test_cp_oppos(a1, a2); | |
192 for (int i=0; i<ARRLEN; i++) { | |
193 errn += verify("test_cp_oppos: a1", i, a1[i], 123); | |
194 } | |
195 test_2ci_oppos(a1, a2); | |
196 for (int i=0; i<ARRLEN; i++) { | |
197 errn += verify("test_2ci_oppos: a1", i, a1[i], -123); | |
198 errn += verify("test_2ci_oppos: a2", i, a2[i], -103); | |
199 } | |
200 test_2vi_oppos(a1, a2, 123, 103); | |
201 for (int i=0; i<ARRLEN; i++) { | |
202 errn += verify("test_2vi_oppos: a1", i, a1[i], 123); | |
203 errn += verify("test_2vi_oppos: a2", i, a2[i], 103); | |
204 } | |
205 // Reset for indexing with offset | |
206 for (int i=0; i<ARRLEN; i++) { | |
207 a1[i] = -1; | |
208 a2[i] = -1; | |
209 } | |
210 test_ci_off(a1, -1); | |
211 for (int i=OFFSET; i<ARRLEN; i++) { | |
212 errn += verify("test_ci_off: a1", i, a1[i], -123); | |
213 } | |
214 test_vi_off(a2, 123, -1); | |
215 for (int i=OFFSET; i<ARRLEN; i++) { | |
216 errn += verify("test_vi_off: a2", i, a2[i], 123); | |
217 } | |
218 test_cp_off(a1, a2); | |
219 for (int i=OFFSET; i<ARRLEN; i++) { | |
220 errn += verify("test_cp_off: a1", i, a1[i], 123); | |
221 } | |
222 test_2ci_off(a1, a2); | |
223 for (int i=OFFSET; i<ARRLEN; i++) { | |
224 errn += verify("test_2ci_off: a1", i, a1[i], -123); | |
225 errn += verify("test_2ci_off: a2", i, a2[i], -103); | |
226 } | |
227 test_2vi_off(a1, a2, 123, 103); | |
228 for (int i=OFFSET; i<ARRLEN; i++) { | |
229 errn += verify("test_2vi_off: a1", i, a1[i], 123); | |
230 errn += verify("test_2vi_off: a2", i, a2[i], 103); | |
231 } | |
232 for (int i=0; i<OFFSET; i++) { | |
233 errn += verify("test_2vi_off: a1", i, a1[i], -1); | |
234 errn += verify("test_2vi_off: a2", i, a2[i], -1); | |
235 } | |
236 // Reset for indexing with invariant offset | |
237 for (int i=0; i<ARRLEN; i++) { | |
238 a1[i] = -1; | |
239 a2[i] = -1; | |
240 } | |
241 test_ci_inv(a1, OFFSET, -1); | |
242 for (int i=OFFSET; i<ARRLEN; i++) { | |
243 errn += verify("test_ci_inv: a1", i, a1[i], -123); | |
244 } | |
245 test_vi_inv(a2, 123, OFFSET, -1); | |
246 for (int i=OFFSET; i<ARRLEN; i++) { | |
247 errn += verify("test_vi_inv: a2", i, a2[i], 123); | |
248 } | |
249 test_cp_inv(a1, a2, OFFSET); | |
250 for (int i=OFFSET; i<ARRLEN; i++) { | |
251 errn += verify("test_cp_inv: a1", i, a1[i], 123); | |
252 } | |
253 test_2ci_inv(a1, a2, OFFSET); | |
254 for (int i=OFFSET; i<ARRLEN; i++) { | |
255 errn += verify("test_2ci_inv: a1", i, a1[i], -123); | |
256 errn += verify("test_2ci_inv: a2", i, a2[i], -103); | |
257 } | |
258 test_2vi_inv(a1, a2, 123, 103, OFFSET); | |
259 for (int i=OFFSET; i<ARRLEN; i++) { | |
260 errn += verify("test_2vi_inv: a1", i, a1[i], 123); | |
261 errn += verify("test_2vi_inv: a2", i, a2[i], 103); | |
262 } | |
263 for (int i=0; i<OFFSET; i++) { | |
264 errn += verify("test_2vi_inv: a1", i, a1[i], -1); | |
265 errn += verify("test_2vi_inv: a2", i, a2[i], -1); | |
266 } | |
267 // Reset for indexing with scale | |
268 for (int i=0; i<ARRLEN; i++) { | |
269 a1[i] = -1; | |
270 a2[i] = -1; | |
271 } | |
272 test_ci_scl(a1, -1); | |
273 for (int i=0; i<ARRLEN; i++) { | |
274 int val = (i%SCALE != 0) ? -1 : -123; | |
275 errn += verify("test_ci_scl: a1", i, a1[i], val); | |
276 } | |
277 test_vi_scl(a2, 123, -1); | |
278 for (int i=0; i<ARRLEN; i++) { | |
279 int val = (i%SCALE != 0) ? -1 : 123; | |
280 errn += verify("test_vi_scl: a2", i, a2[i], val); | |
281 } | |
282 test_cp_scl(a1, a2); | |
283 for (int i=0; i<ARRLEN; i++) { | |
284 int val = (i%SCALE != 0) ? -1 : 123; | |
285 errn += verify("test_cp_scl: a1", i, a1[i], val); | |
286 } | |
287 test_2ci_scl(a1, a2); | |
288 for (int i=0; i<ARRLEN; i++) { | |
289 if (i%SCALE != 0) { | |
290 errn += verify("test_2ci_scl: a1", i, a1[i], -1); | |
291 } else if (i*SCALE < ARRLEN) { | |
292 errn += verify("test_2ci_scl: a1", i*SCALE, a1[i*SCALE], -123); | |
293 } | |
294 if (i%SCALE != 0) { | |
295 errn += verify("test_2ci_scl: a2", i, a2[i], -1); | |
296 } else if (i*SCALE < ARRLEN) { | |
297 errn += verify("test_2ci_scl: a2", i*SCALE, a2[i*SCALE], -103); | |
298 } | |
299 } | |
300 test_2vi_scl(a1, a2, 123, 103); | |
301 for (int i=0; i<ARRLEN; i++) { | |
302 if (i%SCALE != 0) { | |
303 errn += verify("test_2vi_scl: a1", i, a1[i], -1); | |
304 } else if (i*SCALE < ARRLEN) { | |
305 errn += verify("test_2vi_scl: a1", i*SCALE, a1[i*SCALE], 123); | |
306 } | |
307 if (i%SCALE != 0) { | |
308 errn += verify("test_2vi_scl: a2", i, a2[i], -1); | |
309 } else if (i*SCALE < ARRLEN) { | |
310 errn += verify("test_2vi_scl: a2", i*SCALE, a2[i*SCALE], 103); | |
311 } | |
312 } | |
313 // Reset for 2 arrays with relative aligned offset | |
314 for (int i=0; i<ARRLEN; i++) { | |
315 a1[i] = -1; | |
316 a2[i] = -1; | |
317 } | |
318 test_vi(a2, 123, -1); | |
319 test_cp_alndst(a1, a2); | |
320 for (int i=0; i<ALIGN_OFF; i++) { | |
321 errn += verify("test_cp_alndst: a1", i, a1[i], -1); | |
322 } | |
323 for (int i=ALIGN_OFF; i<ARRLEN; i++) { | |
324 errn += verify("test_cp_alndst: a1", i, a1[i], 123); | |
325 } | |
326 for (int i=0; i<ALIGN_OFF; i++) { | |
327 a1[i] = 123; | |
328 } | |
329 test_vi(a2, -123, 123); | |
330 test_cp_alnsrc(a1, a2); | |
331 for (int i=0; i<ARRLEN-ALIGN_OFF; i++) { | |
332 errn += verify("test_cp_alnsrc: a1", i, a1[i], -123); | |
333 } | |
334 for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) { | |
335 errn += verify("test_cp_alnsrc: a1", i, a1[i], 123); | |
336 } | |
337 for (int i=0; i<ARRLEN; i++) { | |
338 a1[i] = -1; | |
339 a2[i] = -1; | |
340 } | |
341 test_2ci_aln(a1, a2); | |
342 for (int i=0; i<ALIGN_OFF; i++) { | |
343 errn += verify("test_2ci_aln: a1", i, a1[i], -1); | |
344 } | |
345 for (int i=ALIGN_OFF; i<ARRLEN; i++) { | |
346 errn += verify("test_2ci_aln: a1", i, a1[i], -123); | |
347 } | |
348 for (int i=0; i<ARRLEN-ALIGN_OFF; i++) { | |
349 errn += verify("test_2ci_aln: a2", i, a2[i], -103); | |
350 } | |
351 for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) { | |
352 errn += verify("test_2ci_aln: a2", i, a2[i], -1); | |
353 } | |
354 for (int i=0; i<ARRLEN; i++) { | |
355 a1[i] = -1; | |
356 a2[i] = -1; | |
357 } | |
358 test_2vi_aln(a1, a2, 123, 103); | |
359 for (int i=0; i<ARRLEN-ALIGN_OFF; i++) { | |
360 errn += verify("test_2vi_aln: a1", i, a1[i], 123); | |
361 } | |
362 for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) { | |
363 errn += verify("test_2vi_aln: a1", i, a1[i], -1); | |
364 } | |
365 for (int i=0; i<ALIGN_OFF; i++) { | |
366 errn += verify("test_2vi_aln: a2", i, a2[i], -1); | |
367 } | |
368 for (int i=ALIGN_OFF; i<ARRLEN; i++) { | |
369 errn += verify("test_2vi_aln: a2", i, a2[i], 103); | |
370 } | |
371 | |
372 // Reset for 2 arrays with relative unaligned offset | |
373 for (int i=0; i<ARRLEN; i++) { | |
374 a1[i] = -1; | |
375 a2[i] = -1; | |
376 } | |
377 test_vi(a2, 123, -1); | |
378 test_cp_unalndst(a1, a2); | |
379 for (int i=0; i<UNALIGN_OFF; i++) { | |
380 errn += verify("test_cp_unalndst: a1", i, a1[i], -1); | |
381 } | |
382 for (int i=UNALIGN_OFF; i<ARRLEN; i++) { | |
383 errn += verify("test_cp_unalndst: a1", i, a1[i], 123); | |
384 } | |
385 test_vi(a2, -123, 123); | |
386 test_cp_unalnsrc(a1, a2); | |
387 for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) { | |
388 errn += verify("test_cp_unalnsrc: a1", i, a1[i], -123); | |
389 } | |
390 for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) { | |
391 errn += verify("test_cp_unalnsrc: a1", i, a1[i], 123); | |
392 } | |
393 for (int i=0; i<ARRLEN; i++) { | |
394 a1[i] = -1; | |
395 a2[i] = -1; | |
396 } | |
397 test_2ci_unaln(a1, a2); | |
398 for (int i=0; i<UNALIGN_OFF; i++) { | |
399 errn += verify("test_2ci_unaln: a1", i, a1[i], -1); | |
400 } | |
401 for (int i=UNALIGN_OFF; i<ARRLEN; i++) { | |
402 errn += verify("test_2ci_unaln: a1", i, a1[i], -123); | |
403 } | |
404 for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) { | |
405 errn += verify("test_2ci_unaln: a2", i, a2[i], -103); | |
406 } | |
407 for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) { | |
408 errn += verify("test_2ci_unaln: a2", i, a2[i], -1); | |
409 } | |
410 for (int i=0; i<ARRLEN; i++) { | |
411 a1[i] = -1; | |
412 a2[i] = -1; | |
413 } | |
414 test_2vi_unaln(a1, a2, 123, 103); | |
415 for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) { | |
416 errn += verify("test_2vi_unaln: a1", i, a1[i], 123); | |
417 } | |
418 for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) { | |
419 errn += verify("test_2vi_unaln: a1", i, a1[i], -1); | |
420 } | |
421 for (int i=0; i<UNALIGN_OFF; i++) { | |
422 errn += verify("test_2vi_unaln: a2", i, a2[i], -1); | |
423 } | |
424 for (int i=UNALIGN_OFF; i<ARRLEN; i++) { | |
425 errn += verify("test_2vi_unaln: a2", i, a2[i], 103); | |
426 } | |
427 | |
428 // Reset for aligned overlap initialization | |
429 for (int i=0; i<ALIGN_OFF; i++) { | |
430 a1[i] = i; | |
431 } | |
432 for (int i=ALIGN_OFF; i<ARRLEN; i++) { | |
433 a1[i] = -1; | |
434 } | |
435 test_cp_alndst(a1, a1); | |
436 for (int i=0; i<ARRLEN; i++) { | |
437 int v = i%ALIGN_OFF; | |
438 errn += verify("test_cp_alndst_overlap: a1", i, a1[i], v); | |
439 } | |
440 for (int i=0; i<ALIGN_OFF; i++) { | |
441 a1[i+ALIGN_OFF] = -1; | |
442 } | |
443 test_cp_alnsrc(a1, a1); | |
444 for (int i=0; i<ALIGN_OFF; i++) { | |
445 errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], -1); | |
446 } | |
447 for (int i=ALIGN_OFF; i<ARRLEN; i++) { | |
448 int v = i%ALIGN_OFF; | |
449 errn += verify("test_cp_alnsrc_overlap: a1", i, a1[i], v); | |
450 } | |
451 for (int i=0; i<ARRLEN; i++) { | |
452 a1[i] = -1; | |
453 } | |
454 test_2ci_aln(a1, a1); | |
455 for (int i=0; i<ARRLEN-ALIGN_OFF; i++) { | |
456 errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -103); | |
457 } | |
458 for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) { | |
459 errn += verify("test_2ci_aln_overlap: a1", i, a1[i], -123); | |
460 } | |
461 for (int i=0; i<ARRLEN; i++) { | |
462 a1[i] = -1; | |
463 } | |
464 test_2vi_aln(a1, a1, 123, 103); | |
465 for (int i=0; i<ARRLEN-ALIGN_OFF; i++) { | |
466 errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 123); | |
467 } | |
468 for (int i=ARRLEN-ALIGN_OFF; i<ARRLEN; i++) { | |
469 errn += verify("test_2vi_aln_overlap: a1", i, a1[i], 103); | |
470 } | |
471 | |
472 // Reset for unaligned overlap initialization | |
473 for (int i=0; i<UNALIGN_OFF; i++) { | |
474 a1[i] = i; | |
475 } | |
476 for (int i=UNALIGN_OFF; i<ARRLEN; i++) { | |
477 a1[i] = -1; | |
478 } | |
479 test_cp_unalndst(a1, a1); | |
480 for (int i=0; i<ARRLEN; i++) { | |
481 int v = i%UNALIGN_OFF; | |
482 errn += verify("test_cp_unalndst_overlap: a1", i, a1[i], v); | |
483 } | |
484 for (int i=0; i<UNALIGN_OFF; i++) { | |
485 a1[i+UNALIGN_OFF] = -1; | |
486 } | |
487 test_cp_unalnsrc(a1, a1); | |
488 for (int i=0; i<UNALIGN_OFF; i++) { | |
489 errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], -1); | |
490 } | |
491 for (int i=UNALIGN_OFF; i<ARRLEN; i++) { | |
492 int v = i%UNALIGN_OFF; | |
493 errn += verify("test_cp_unalnsrc_overlap: a1", i, a1[i], v); | |
494 } | |
495 for (int i=0; i<ARRLEN; i++) { | |
496 a1[i] = -1; | |
497 } | |
498 test_2ci_unaln(a1, a1); | |
499 for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) { | |
500 errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -103); | |
501 } | |
502 for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) { | |
503 errn += verify("test_2ci_unaln_overlap: a1", i, a1[i], -123); | |
504 } | |
505 for (int i=0; i<ARRLEN; i++) { | |
506 a1[i] = -1; | |
507 } | |
508 test_2vi_unaln(a1, a1, 123, 103); | |
509 for (int i=0; i<ARRLEN-UNALIGN_OFF; i++) { | |
510 errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 123); | |
511 } | |
512 for (int i=ARRLEN-UNALIGN_OFF; i<ARRLEN; i++) { | |
513 errn += verify("test_2vi_unaln_overlap: a1", i, a1[i], 103); | |
514 } | |
515 | |
516 } | |
517 | |
518 if (errn > 0 || test_only) | |
519 return errn; | |
520 | |
521 // Initialize | |
522 for (int i=0; i<ARRLEN; i++) { | |
523 a1[i] = -1; | |
524 a2[i] = -1; | |
525 } | |
526 System.out.println("Time"); | |
527 long start, end; | |
528 start = System.currentTimeMillis(); | |
529 for (int i=0; i<ITERS; i++) { | |
530 test_ci(a1); | |
531 } | |
532 end = System.currentTimeMillis(); | |
533 System.out.println("test_ci: " + (end - start)); | |
534 start = System.currentTimeMillis(); | |
535 for (int i=0; i<ITERS; i++) { | |
536 test_vi(a2, 123, -1); | |
537 } | |
538 end = System.currentTimeMillis(); | |
539 System.out.println("test_vi: " + (end - start)); | |
540 start = System.currentTimeMillis(); | |
541 for (int i=0; i<ITERS; i++) { | |
542 test_cp(a1, a2); | |
543 } | |
544 end = System.currentTimeMillis(); | |
545 System.out.println("test_cp: " + (end - start)); | |
546 start = System.currentTimeMillis(); | |
547 for (int i=0; i<ITERS; i++) { | |
548 test_2ci(a1, a2); | |
549 } | |
550 end = System.currentTimeMillis(); | |
551 System.out.println("test_2ci: " + (end - start)); | |
552 start = System.currentTimeMillis(); | |
553 for (int i=0; i<ITERS; i++) { | |
554 test_2vi(a1, a2, 123, 103); | |
555 } | |
556 end = System.currentTimeMillis(); | |
557 System.out.println("test_2vi: " + (end - start)); | |
558 | |
559 start = System.currentTimeMillis(); | |
560 for (int i=0; i<ITERS; i++) { | |
561 test_ci_neg(a1, 123); | |
562 } | |
563 end = System.currentTimeMillis(); | |
564 System.out.println("test_ci_neg: " + (end - start)); | |
565 start = System.currentTimeMillis(); | |
566 for (int i=0; i<ITERS; i++) { | |
567 test_vi_neg(a2, 123, 103); | |
568 } | |
569 end = System.currentTimeMillis(); | |
570 System.out.println("test_vi_neg: " + (end - start)); | |
571 start = System.currentTimeMillis(); | |
572 for (int i=0; i<ITERS; i++) { | |
573 test_cp_neg(a1, a2); | |
574 } | |
575 end = System.currentTimeMillis(); | |
576 System.out.println("test_cp_neg: " + (end - start)); | |
577 start = System.currentTimeMillis(); | |
578 for (int i=0; i<ITERS; i++) { | |
579 test_2ci_neg(a1, a2); | |
580 } | |
581 end = System.currentTimeMillis(); | |
582 System.out.println("test_2ci_neg: " + (end - start)); | |
583 start = System.currentTimeMillis(); | |
584 for (int i=0; i<ITERS; i++) { | |
585 test_2vi_neg(a1, a2, 123, 103); | |
586 } | |
587 end = System.currentTimeMillis(); | |
588 System.out.println("test_2vi_neg: " + (end - start)); | |
589 | |
590 start = System.currentTimeMillis(); | |
591 for (int i=0; i<ITERS; i++) { | |
592 test_ci_oppos(a1, 123); | |
593 } | |
594 end = System.currentTimeMillis(); | |
595 System.out.println("test_ci_oppos: " + (end - start)); | |
596 start = System.currentTimeMillis(); | |
597 for (int i=0; i<ITERS; i++) { | |
598 test_vi_oppos(a2, 123, 103); | |
599 } | |
600 end = System.currentTimeMillis(); | |
601 System.out.println("test_vi_oppos: " + (end - start)); | |
602 start = System.currentTimeMillis(); | |
603 for (int i=0; i<ITERS; i++) { | |
604 test_cp_oppos(a1, a2); | |
605 } | |
606 end = System.currentTimeMillis(); | |
607 System.out.println("test_cp_oppos: " + (end - start)); | |
608 start = System.currentTimeMillis(); | |
609 for (int i=0; i<ITERS; i++) { | |
610 test_2ci_oppos(a1, a2); | |
611 } | |
612 end = System.currentTimeMillis(); | |
613 System.out.println("test_2ci_oppos: " + (end - start)); | |
614 start = System.currentTimeMillis(); | |
615 for (int i=0; i<ITERS; i++) { | |
616 test_2vi_oppos(a1, a2, 123, 103); | |
617 } | |
618 end = System.currentTimeMillis(); | |
619 System.out.println("test_2vi_oppos: " + (end - start)); | |
620 | |
621 start = System.currentTimeMillis(); | |
622 for (int i=0; i<ITERS; i++) { | |
623 test_ci_off(a1, 123); | |
624 } | |
625 end = System.currentTimeMillis(); | |
626 System.out.println("test_ci_off: " + (end - start)); | |
627 start = System.currentTimeMillis(); | |
628 for (int i=0; i<ITERS; i++) { | |
629 test_vi_off(a2, 123, 103); | |
630 } | |
631 end = System.currentTimeMillis(); | |
632 System.out.println("test_vi_off: " + (end - start)); | |
633 start = System.currentTimeMillis(); | |
634 for (int i=0; i<ITERS; i++) { | |
635 test_cp_off(a1, a2); | |
636 } | |
637 end = System.currentTimeMillis(); | |
638 System.out.println("test_cp_off: " + (end - start)); | |
639 start = System.currentTimeMillis(); | |
640 for (int i=0; i<ITERS; i++) { | |
641 test_2ci_off(a1, a2); | |
642 } | |
643 end = System.currentTimeMillis(); | |
644 System.out.println("test_2ci_off: " + (end - start)); | |
645 start = System.currentTimeMillis(); | |
646 for (int i=0; i<ITERS; i++) { | |
647 test_2vi_off(a1, a2, 123, 103); | |
648 } | |
649 end = System.currentTimeMillis(); | |
650 System.out.println("test_2vi_off: " + (end - start)); | |
651 | |
652 start = System.currentTimeMillis(); | |
653 for (int i=0; i<ITERS; i++) { | |
654 test_ci_inv(a1, OFFSET, 123); | |
655 } | |
656 end = System.currentTimeMillis(); | |
657 System.out.println("test_ci_inv: " + (end - start)); | |
658 start = System.currentTimeMillis(); | |
659 for (int i=0; i<ITERS; i++) { | |
660 test_vi_inv(a2, 123, OFFSET, 103); | |
661 } | |
662 end = System.currentTimeMillis(); | |
663 System.out.println("test_vi_inv: " + (end - start)); | |
664 start = System.currentTimeMillis(); | |
665 for (int i=0; i<ITERS; i++) { | |
666 test_cp_inv(a1, a2, OFFSET); | |
667 } | |
668 end = System.currentTimeMillis(); | |
669 System.out.println("test_cp_inv: " + (end - start)); | |
670 start = System.currentTimeMillis(); | |
671 for (int i=0; i<ITERS; i++) { | |
672 test_2ci_inv(a1, a2, OFFSET); | |
673 } | |
674 end = System.currentTimeMillis(); | |
675 System.out.println("test_2ci_inv: " + (end - start)); | |
676 start = System.currentTimeMillis(); | |
677 for (int i=0; i<ITERS; i++) { | |
678 test_2vi_inv(a1, a2, 123, 103, OFFSET); | |
679 } | |
680 end = System.currentTimeMillis(); | |
681 System.out.println("test_2vi_inv: " + (end - start)); | |
682 | |
683 start = System.currentTimeMillis(); | |
684 for (int i=0; i<ITERS; i++) { | |
685 test_ci_scl(a1, 123); | |
686 } | |
687 end = System.currentTimeMillis(); | |
688 System.out.println("test_ci_scl: " + (end - start)); | |
689 start = System.currentTimeMillis(); | |
690 for (int i=0; i<ITERS; i++) { | |
691 test_vi_scl(a2, 123, 103); | |
692 } | |
693 end = System.currentTimeMillis(); | |
694 System.out.println("test_vi_scl: " + (end - start)); | |
695 start = System.currentTimeMillis(); | |
696 for (int i=0; i<ITERS; i++) { | |
697 test_cp_scl(a1, a2); | |
698 } | |
699 end = System.currentTimeMillis(); | |
700 System.out.println("test_cp_scl: " + (end - start)); | |
701 start = System.currentTimeMillis(); | |
702 for (int i=0; i<ITERS; i++) { | |
703 test_2ci_scl(a1, a2); | |
704 } | |
705 end = System.currentTimeMillis(); | |
706 System.out.println("test_2ci_scl: " + (end - start)); | |
707 start = System.currentTimeMillis(); | |
708 for (int i=0; i<ITERS; i++) { | |
709 test_2vi_scl(a1, a2, 123, 103); | |
710 } | |
711 end = System.currentTimeMillis(); | |
712 System.out.println("test_2vi_scl: " + (end - start)); | |
713 | |
714 start = System.currentTimeMillis(); | |
715 for (int i=0; i<ITERS; i++) { | |
716 test_cp_alndst(a1, a2); | |
717 } | |
718 end = System.currentTimeMillis(); | |
719 System.out.println("test_cp_alndst: " + (end - start)); | |
720 start = System.currentTimeMillis(); | |
721 for (int i=0; i<ITERS; i++) { | |
722 test_cp_alnsrc(a1, a2); | |
723 } | |
724 end = System.currentTimeMillis(); | |
725 System.out.println("test_cp_alnsrc: " + (end - start)); | |
726 start = System.currentTimeMillis(); | |
727 for (int i=0; i<ITERS; i++) { | |
728 test_2ci_aln(a1, a2); | |
729 } | |
730 end = System.currentTimeMillis(); | |
731 System.out.println("test_2ci_aln: " + (end - start)); | |
732 start = System.currentTimeMillis(); | |
733 for (int i=0; i<ITERS; i++) { | |
734 test_2vi_aln(a1, a2, 123, 103); | |
735 } | |
736 end = System.currentTimeMillis(); | |
737 System.out.println("test_2vi_aln: " + (end - start)); | |
738 | |
739 start = System.currentTimeMillis(); | |
740 for (int i=0; i<ITERS; i++) { | |
741 test_cp_unalndst(a1, a2); | |
742 } | |
743 end = System.currentTimeMillis(); | |
744 System.out.println("test_cp_unalndst: " + (end - start)); | |
745 start = System.currentTimeMillis(); | |
746 for (int i=0; i<ITERS; i++) { | |
747 test_cp_unalnsrc(a1, a2); | |
748 } | |
749 end = System.currentTimeMillis(); | |
750 System.out.println("test_cp_unalnsrc: " + (end - start)); | |
751 start = System.currentTimeMillis(); | |
752 for (int i=0; i<ITERS; i++) { | |
753 test_2ci_unaln(a1, a2); | |
754 } | |
755 end = System.currentTimeMillis(); | |
756 System.out.println("test_2ci_unaln: " + (end - start)); | |
757 start = System.currentTimeMillis(); | |
758 for (int i=0; i<ITERS; i++) { | |
759 test_2vi_unaln(a1, a2, 123, 103); | |
760 } | |
761 end = System.currentTimeMillis(); | |
762 System.out.println("test_2vi_unaln: " + (end - start)); | |
763 | |
764 return errn; | |
765 } | |
766 | |
767 private final static long byte_offset(int i) { | |
768 return ((long)i << 2) + BASE; | |
769 } | |
770 | |
771 static void test_ci(int[] a) { | |
772 for (int i = 0; i < ARRLEN; i+=1) { | |
773 unsafe.compareAndSwapInt(a, byte_offset(i), -1, -123); | |
774 } | |
775 } | |
776 static void test_vi(int[] a, int b, int old) { | |
777 for (int i = 0; i < ARRLEN; i+=1) { | |
778 unsafe.compareAndSwapInt(a, byte_offset(i), old, b); | |
779 } | |
780 } | |
781 static void test_cp(int[] a, int[] b) { | |
782 for (int i = 0; i < ARRLEN; i+=1) { | |
783 unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]); | |
784 } | |
785 } | |
786 static void test_2ci(int[] a, int[] b) { | |
787 for (int i = 0; i < ARRLEN; i+=1) { | |
788 unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123); | |
789 unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); | |
790 } | |
791 } | |
792 static void test_2vi(int[] a, int[] b, int c, int d) { | |
793 for (int i = 0; i < ARRLEN; i+=1) { | |
794 unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); | |
795 unsafe.compareAndSwapInt(b, byte_offset(i), -103, d); | |
796 } | |
797 } | |
798 static void test_ci_neg(int[] a, int old) { | |
799 for (int i = ARRLEN-1; i >= 0; i-=1) { | |
800 unsafe.compareAndSwapInt(a, byte_offset(i), old, -123); | |
801 } | |
802 } | |
803 static void test_vi_neg(int[] a, int b, int old) { | |
804 for (int i = ARRLEN-1; i >= 0; i-=1) { | |
805 unsafe.compareAndSwapInt(a, byte_offset(i), old, b); | |
806 } | |
807 } | |
808 static void test_cp_neg(int[] a, int[] b) { | |
809 for (int i = ARRLEN-1; i >= 0; i-=1) { | |
810 unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[i]); | |
811 } | |
812 } | |
813 static void test_2ci_neg(int[] a, int[] b) { | |
814 for (int i = ARRLEN-1; i >= 0; i-=1) { | |
815 unsafe.compareAndSwapInt(a, byte_offset(i), 123, -123); | |
816 unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); | |
817 } | |
818 } | |
819 static void test_2vi_neg(int[] a, int[] b, int c, int d) { | |
820 for (int i = ARRLEN-1; i >= 0; i-=1) { | |
821 unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); | |
822 unsafe.compareAndSwapInt(b, byte_offset(i), -103, d); | |
823 } | |
824 } | |
825 static void test_ci_oppos(int[] a, int old) { | |
826 int limit = ARRLEN-1; | |
827 for (int i = 0; i < ARRLEN; i+=1) { | |
828 unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, -123); | |
829 } | |
830 } | |
831 static void test_vi_oppos(int[] a, int b, int old) { | |
832 int limit = ARRLEN-1; | |
833 for (int i = limit; i >= 0; i-=1) { | |
834 unsafe.compareAndSwapInt(a, byte_offset(limit-i), old, b); | |
835 } | |
836 } | |
837 static void test_cp_oppos(int[] a, int[] b) { | |
838 int limit = ARRLEN-1; | |
839 for (int i = 0; i < ARRLEN; i+=1) { | |
840 unsafe.compareAndSwapInt(a, byte_offset(i), -123, b[limit-i]); | |
841 } | |
842 } | |
843 static void test_2ci_oppos(int[] a, int[] b) { | |
844 int limit = ARRLEN-1; | |
845 for (int i = 0; i < ARRLEN; i+=1) { | |
846 unsafe.compareAndSwapInt(a, byte_offset(limit-i), 123, -123); | |
847 unsafe.compareAndSwapInt(b, byte_offset(i), 123, -103); | |
848 } | |
849 } | |
850 static void test_2vi_oppos(int[] a, int[] b, int c, int d) { | |
851 int limit = ARRLEN-1; | |
852 for (int i = limit; i >= 0; i-=1) { | |
853 unsafe.compareAndSwapInt(a, byte_offset(i), -123, c); | |
854 unsafe.compareAndSwapInt(b, byte_offset(limit-i), -103, d); | |
855 } | |
856 } | |
857 static void test_ci_off(int[] a, int old) { | |
858 for (int i = 0; i < ARRLEN-OFFSET; i+=1) { | |
859 unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, -123); | |
860 } | |
861 } | |
862 static void test_vi_off(int[] a, int b, int old) { | |
863 for (int i = 0; i < ARRLEN-OFFSET; i+=1) { | |
864 unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), old, b); | |
865 } | |
866 } | |
867 static void test_cp_off(int[] a, int[] b) { | |
868 for (int i = 0; i < ARRLEN-OFFSET; i+=1) { | |
869 unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, b[i+OFFSET]); | |
870 } | |
871 } | |
872 static void test_2ci_off(int[] a, int[] b) { | |
873 for (int i = 0; i < ARRLEN-OFFSET; i+=1) { | |
874 unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), 123, -123); | |
875 unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), 123, -103); | |
876 } | |
877 } | |
878 static void test_2vi_off(int[] a, int[] b, int c, int d) { | |
879 for (int i = 0; i < ARRLEN-OFFSET; i+=1) { | |
880 unsafe.compareAndSwapInt(a, byte_offset(i+OFFSET), -123, c); | |
881 unsafe.compareAndSwapInt(b, byte_offset(i+OFFSET), -103, d); | |
882 } | |
883 } | |
884 static void test_ci_inv(int[] a, int k, int old) { | |
885 for (int i = 0; i < ARRLEN-k; i+=1) { | |
886 unsafe.compareAndSwapInt(a, byte_offset(i+k), old, -123); | |
887 } | |
888 } | |
889 static void test_vi_inv(int[] a, int b, int k, int old) { | |
890 for (int i = 0; i < ARRLEN-k; i+=1) { | |
891 unsafe.compareAndSwapInt(a, byte_offset(i+k), old, b); | |
892 } | |
893 } | |
894 static void test_cp_inv(int[] a, int[] b, int k) { | |
895 for (int i = 0; i < ARRLEN-k; i+=1) { | |
896 unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, b[i+k]); | |
897 } | |
898 } | |
899 static void test_2ci_inv(int[] a, int[] b, int k) { | |
900 for (int i = 0; i < ARRLEN-k; i+=1) { | |
901 unsafe.compareAndSwapInt(a, byte_offset(i+k), 123, -123); | |
902 unsafe.compareAndSwapInt(b, byte_offset(i+k), 123, -103); | |
903 } | |
904 } | |
905 static void test_2vi_inv(int[] a, int[] b, int c, int d, int k) { | |
906 for (int i = 0; i < ARRLEN-k; i+=1) { | |
907 unsafe.compareAndSwapInt(a, byte_offset(i+k), -123, c); | |
908 unsafe.compareAndSwapInt(b, byte_offset(i+k), -103, d); | |
909 } | |
910 } | |
911 static void test_ci_scl(int[] a, int old) { | |
912 for (int i = 0; i*SCALE < ARRLEN; i+=1) { | |
913 unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, -123); | |
914 } | |
915 } | |
916 static void test_vi_scl(int[] a, int b, int old) { | |
917 for (int i = 0; i*SCALE < ARRLEN; i+=1) { | |
918 unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), old, b); | |
919 } | |
920 } | |
921 static void test_cp_scl(int[] a, int[] b) { | |
922 for (int i = 0; i*SCALE < ARRLEN; i+=1) { | |
923 unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, b[i*SCALE]); | |
924 } | |
925 } | |
926 static void test_2ci_scl(int[] a, int[] b) { | |
927 for (int i = 0; i*SCALE < ARRLEN; i+=1) { | |
928 unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), 123, -123); | |
929 unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), 123, -103); | |
930 } | |
931 } | |
932 static void test_2vi_scl(int[] a, int[] b, int c, int d) { | |
933 for (int i = 0; i*SCALE < ARRLEN; i+=1) { | |
934 unsafe.compareAndSwapInt(a, byte_offset(i*SCALE), -123, c); | |
935 unsafe.compareAndSwapInt(b, byte_offset(i*SCALE), -103, d); | |
936 } | |
937 } | |
938 static void test_cp_alndst(int[] a, int[] b) { | |
939 for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { | |
940 unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, b[i]); | |
941 } | |
942 } | |
943 static void test_cp_alnsrc(int[] a, int[] b) { | |
944 for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { | |
945 int old = unsafe.getIntVolatile(a, byte_offset(i)); | |
946 unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+ALIGN_OFF]); | |
947 } | |
948 } | |
949 static void test_2ci_aln(int[] a, int[] b) { | |
950 for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { | |
951 unsafe.compareAndSwapInt(a, byte_offset(i+ALIGN_OFF), -1, -123); | |
952 int old = unsafe.getIntVolatile(b, byte_offset(i)); | |
953 unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); | |
954 } | |
955 } | |
956 static void test_2vi_aln(int[] a, int[] b, int c, int d) { | |
957 for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) { | |
958 int old = unsafe.getIntVolatile(a, byte_offset(i)); | |
959 unsafe.compareAndSwapInt(a, byte_offset(i), old, c); | |
960 old = unsafe.getIntVolatile(b, byte_offset(i+ALIGN_OFF)); | |
961 unsafe.compareAndSwapInt(b, byte_offset(i+ALIGN_OFF), old, d); | |
962 } | |
963 } | |
964 static void test_cp_unalndst(int[] a, int[] b) { | |
965 for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { | |
966 unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, b[i]); | |
967 } | |
968 } | |
969 static void test_cp_unalnsrc(int[] a, int[] b) { | |
970 for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { | |
971 int old = unsafe.getIntVolatile(a, byte_offset(i)); | |
972 unsafe.compareAndSwapInt(a, byte_offset(i), old, b[i+UNALIGN_OFF]); | |
973 } | |
974 } | |
975 static void test_2ci_unaln(int[] a, int[] b) { | |
976 for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { | |
977 unsafe.compareAndSwapInt(a, byte_offset(i+UNALIGN_OFF), -1, -123); | |
978 int old = unsafe.getIntVolatile(b, byte_offset(i)); | |
979 unsafe.compareAndSwapInt(b, byte_offset(i), old, -103); | |
980 } | |
981 } | |
982 static void test_2vi_unaln(int[] a, int[] b, int c, int d) { | |
983 for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) { | |
984 int old = unsafe.getIntVolatile(a, byte_offset(i)); | |
985 unsafe.compareAndSwapInt(a, byte_offset(i), old, c); | |
986 old = unsafe.getIntVolatile(b, byte_offset(i+UNALIGN_OFF)); | |
987 unsafe.compareAndSwapInt(b, byte_offset(i+UNALIGN_OFF), old, d); | |
988 } | |
989 } | |
990 | |
991 static int verify(String text, int i, int elem, int val) { | |
992 if (elem != val) { | |
993 System.err.println(text + "[" + i + "] = " + elem + " != " + val); | |
994 return 1; | |
995 } | |
996 return 0; | |
997 } | |
998 } |