Mercurial > hg > truffle
annotate test/runtime/7100935/TestShortArraycopy.java @ 18118:e98942f26fa4
graalCompiler: fix bootstrap with CTW (regression caused by jdk8-8041959)
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Fri, 17 Oct 2014 11:59:55 +0200 |
parents | 16f9fa2bf76c |
children |
rev | line source |
---|---|
4010
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
1 /* |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
2 * Copyright 2011 SAP AG. All Rights Reserved. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
4 * |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
8 * |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
14 * |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
18 * |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
21 * questions. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
22 */ |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
23 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
24 /* |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
25 * @test TestShortArraycopy |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
26 * @bug 7100935 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
27 * @summary verify that shorts are copied element-wise atomic. |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
28 * @run main/othervm -Xint TestShortArraycopy |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
29 * @run main/othervm -Xcomp -Xbatch TestShortArraycopy |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
30 * @author volker.simonis@gmail.com |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
31 */ |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
32 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
33 public class TestShortArraycopy { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
34 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
35 static short[] a1 = new short[8]; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
36 static short[] a2 = new short[8]; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
37 static short[] a3 = new short[8]; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
38 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
39 static volatile boolean keepRunning = true; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
40 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
41 public static void main(String[] args) throws InterruptedException { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
42 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
43 for (int i = 0; i < a1.length ; i++) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
44 a1[i] = (short)0xffff; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
45 a2[i] = (short)0xffff; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
46 a3[i] = (short)0x0000; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
47 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
48 Thread reader = new Thread() { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
49 public void run() { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
50 while (keepRunning) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
51 for (int j = 0; j < a1.length; j++) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
52 short s = a1[j]; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
53 if (s != (short)0xffff && s != (short)0x0000) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
54 System.out.println("Error: s = " + s); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
55 throw new RuntimeException("wrong result"); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
56 |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
57 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
58 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
59 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
60 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
61 }; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
62 Thread writer = new Thread() { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
63 public void run() { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
64 for (int i = 0; i < 1000000; i++) { |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
65 System.arraycopy(a2, 5, a1, 3, 3); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
66 System.arraycopy(a3, 5, a1, 3, 3); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
67 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
68 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
69 }; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
70 keepRunning = true; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
71 reader.start(); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
72 writer.start(); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
73 writer.join(); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
74 keepRunning = false; |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
75 reader.join(); |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
76 } |
16f9fa2bf76c
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
77 } |