annotate test/runtime/7100935/TestConjointAtomicArraycopy.java @ 14649:f6301b007a16

6498581: ThreadInterruptTest3 produces wrong output on Windows Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set. Reviewed-by: acorn, kvn Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author minqi
date Wed, 26 Feb 2014 15:20:41 -0800
parents 16f9fa2bf76c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 TestConjointAtomicArraycopy
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 oops 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 TestConjointAtomicArraycopy
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 TestConjointAtomicArraycopy
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
30 * @author axel.siebenborn@sap.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 TestConjointAtomicArraycopy {
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 volatile Object [] testArray = new Object [4];
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
36
16f9fa2bf76c 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];
16f9fa2bf76c 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];
16f9fa2bf76c 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];
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 static volatile boolean keepRunning = true;
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 static void testOopsCopy() throws InterruptedException{
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
44
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
45 }
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
46
16f9fa2bf76c 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{
16f9fa2bf76c 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++){
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
49 testArray[i] = new String("A");
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
50 }
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
51
16f9fa2bf76c 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(){
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
53 public void run(){
16f9fa2bf76c 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++) {
16f9fa2bf76c 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);
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
56 testArray[2] = new String("a");
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 Thread reader = new Thread( new Runnable(){
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
62 public void run(){
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
63 while (keepRunning){
16f9fa2bf76c 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();
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
65 if(!(name.endsWith("String"))){
16f9fa2bf76c 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");
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 });
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
71 keepRunning = true;
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
72 reader.start();
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
73 writer.start();
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
74 writer.join();
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
75 keepRunning = false;
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
76 reader.join();
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
77 }
16f9fa2bf76c 7100935: win32: memmove is not atomic but is used for pd_conjoint_*_atomic operations
kvn
parents:
diff changeset
78 }