1 /*
2 * Copyright (c) 2017 Red Hat, Inc. and/or its affiliates.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 /*
25 * @test VerifyJCStressTest
26 * @summary Tests that we pass at least one jcstress-like test with all verification turned on
27 * @key gc
28 * @modules java.base/jdk.internal.misc
29 * java.management
30 * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
31 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyStrictOopOperations
32 * -XX:ShenandoahGCHeuristics=passive -XX:+ShenandoahDegeneratedGC
33 * VerifyJCStressTest
34 *
35 * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
36 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyStrictOopOperations
37 * -XX:ShenandoahGCHeuristics=passive -XX:-ShenandoahDegeneratedGC
38 * VerifyJCStressTest
39 *
40 * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
41 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyStrictOopOperations -XX:+ShenandoahVerifyOptoBarriers
42 * -XX:ShenandoahGCHeuristics=adaptive
43 * VerifyJCStressTest
44 *
45 * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
46 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyStrictOopOperations -XX:+ShenandoahVerifyOptoBarriers
47 * -XX:ShenandoahGCHeuristics=static
48 * VerifyJCStressTest
49 */
50
51 import java.util.*;
52 import java.util.concurrent.*;
53 import java.util.concurrent.locks.*;
54
55 public class VerifyJCStressTest {
56
57 public static void main(String[] args) throws Exception {
58 ExecutorService service = Executors.newFixedThreadPool(
59 2,
60 r -> {
61 Thread t = new Thread(r);
62 t.setDaemon(true);
63 return t;
64 }
65 );
66
67 for (int c = 0; c < 10000; c++) {
68 final Test[] tests = new Test[10000];
69 for (int t = 0; t < tests.length; t++) {
70 tests[t] = new Test();
71 }
72
73 Future<?> f1 = service.submit(() -> {
74 IntResult2 r = new IntResult2();
75 for (Test test : tests) {
101 long stamp = lock.readLock();
102 r.r1 = x;
103 r.r2 = y;
104 lock.unlock(stamp);
105 }
106
107 public void WLI_Us() {
108 try {
109 StampedLock lock = this.lock;
110 long stamp = lock.writeLockInterruptibly();
111 x = 1;
112 y = 2;
113 lock.unlock(stamp);
114 } catch (InterruptedException e) {
115 throw new RuntimeException(e);
116 }
117 }
118 }
119
120 }
121
|
1 /*
2 * Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 /*
25 * @test TestVerifyJCStress
26 * @summary Tests that we pass at least one jcstress-like test with all verification turned on
27 * @key gc
28 *
29 * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions
30 * -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseShenandoahGC
31 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
32 * -XX:ShenandoahGCHeuristics=passive -XX:+ShenandoahDegeneratedGC
33 * TestVerifyJCStress
34 *
35 * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions
36 * -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseShenandoahGC
37 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
38 * -XX:ShenandoahGCHeuristics=passive -XX:-ShenandoahDegeneratedGC
39 * TestVerifyJCStress
40 *
41 * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions
42 * -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseShenandoahGC
43 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
44 * -XX:ShenandoahGCHeuristics=adaptive
45 * TestVerifyJCStress
46 *
47 * @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions
48 * -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+UseShenandoahGC
49 * -XX:+ShenandoahStoreCheck -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
50 * -XX:ShenandoahGCHeuristics=static
51 * TestVerifyJCStress
52 */
53
54 import java.util.*;
55 import java.util.concurrent.*;
56 import java.util.concurrent.locks.*;
57
58 public class TestVerifyJCStress {
59
60 public static void main(String[] args) throws Exception {
61 ExecutorService service = Executors.newFixedThreadPool(
62 2,
63 r -> {
64 Thread t = new Thread(r);
65 t.setDaemon(true);
66 return t;
67 }
68 );
69
70 for (int c = 0; c < 10000; c++) {
71 final Test[] tests = new Test[10000];
72 for (int t = 0; t < tests.length; t++) {
73 tests[t] = new Test();
74 }
75
76 Future<?> f1 = service.submit(() -> {
77 IntResult2 r = new IntResult2();
78 for (Test test : tests) {
104 long stamp = lock.readLock();
105 r.r1 = x;
106 r.r2 = y;
107 lock.unlock(stamp);
108 }
109
110 public void WLI_Us() {
111 try {
112 StampedLock lock = this.lock;
113 long stamp = lock.writeLockInterruptibly();
114 x = 1;
115 y = 2;
116 lock.unlock(stamp);
117 } catch (InterruptedException e) {
118 throw new RuntimeException(e);
119 }
120 }
121 }
122
123 }
|