author | darcy |
Wed, 18 Jan 2012 16:43:59 -0800 | |
changeset 11553 | 4389b722f8dc |
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 TestConjointAtomicArraycopy |
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 oops 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 TestConjointAtomicArraycopy |
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 TestConjointAtomicArraycopy |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
30 |
* @author axel.siebenborn@sap.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 TestConjointAtomicArraycopy { |
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 volatile Object [] testArray = new Object [4]; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
36 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
41 |
static volatile boolean keepRunning = true; |
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 |
static void testOopsCopy() throws InterruptedException{ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
44 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
45 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
46 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
47 |
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
|
48 |
for (int i = 0; i < testArray.length; i++){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
49 |
testArray[i] = new String("A"); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
50 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
51 |
|
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
52 |
Thread writer = new Thread (new Runnable(){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
53 |
public void run(){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
54 |
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
|
55 |
System.arraycopy(testArray, 1, testArray, 0, 3); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
56 |
testArray[2] = new String("a"); |
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 |
Thread reader = new Thread( new Runnable(){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
62 |
public void run(){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
63 |
while (keepRunning){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
64 |
String name = testArray[2].getClass().getName(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
65 |
if(!(name.endsWith("String"))){ |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
66 |
throw new RuntimeException("got wrong class name"); |
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 |
}); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
71 |
keepRunning = true; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
72 |
reader.start(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
73 |
writer.start(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
74 |
writer.join(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
75 |
keepRunning = false; |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
76 |
reader.join(); |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
77 |
} |
2ee610c1fe49
7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff
changeset
|
78 |
} |