author | jlaskey |
Tue, 23 Jul 2013 12:00:29 -0300 | |
changeset 19089 | 51cfdcf21d35 |
parent 10743 | 2ee610c1fe49 |
child 35594 | cc13089c6327 |
permissions | -rw-r--r-- |
10743
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
1 |
/* |
2ee610c1fe49
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. |
2ee610c1fe49
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. |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
4 |
* |
2ee610c1fe49
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 |
2ee610c1fe49
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 |
2ee610c1fe49
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. |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
8 |
* |
2ee610c1fe49
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 |
2ee610c1fe49
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 |
2ee610c1fe49
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 |
2ee610c1fe49
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 |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
13 |
* accompanied this code). |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
14 |
* |
2ee610c1fe49
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 |
2ee610c1fe49
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, |
2ee610c1fe49
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. |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
18 |
* |
2ee610c1fe49
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 |
2ee610c1fe49
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 |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
21 |
* questions. |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
22 |
*/ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
23 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
24 |
/* |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
25 |
* @test TestShortArraycopy |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
26 |
* @bug 7100935 |
2ee610c1fe49
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. |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
28 |
* @run main/othervm -Xint TestShortArraycopy |
2ee610c1fe49
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 |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
30 |
* @author volker.simonis@gmail.com |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
31 |
*/ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
32 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
33 |
public class TestShortArraycopy { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
34 |
|
2ee610c1fe49
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]; |
2ee610c1fe49
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]; |
2ee610c1fe49
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]; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
38 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
39 |
static volatile boolean keepRunning = true; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
40 |
|
2ee610c1fe49
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 { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
42 |
|
2ee610c1fe49
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++) { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
44 |
a1[i] = (short)0xffff; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
45 |
a2[i] = (short)0xffff; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
46 |
a3[i] = (short)0x0000; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
47 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
48 |
Thread reader = new Thread() { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
49 |
public void run() { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
50 |
while (keepRunning) { |
2ee610c1fe49
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++) { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
52 |
short s = a1[j]; |
2ee610c1fe49
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) { |
2ee610c1fe49
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); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
55 |
throw new RuntimeException("wrong result"); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
56 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
57 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
58 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
59 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
60 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
61 |
}; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
62 |
Thread writer = new Thread() { |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
63 |
public void run() { |
2ee610c1fe49
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++) { |
2ee610c1fe49
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); |
2ee610c1fe49
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); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
67 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
68 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
69 |
}; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
70 |
keepRunning = true; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
71 |
reader.start(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
72 |
writer.start(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
73 |
writer.join(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
74 |
keepRunning = false; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
75 |
reader.join(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
76 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
77 |
} |