Mercurial > hg > graal-jvmci-8
annotate test/compiler/loopopts/UseCountedLoopSafepoints.java @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | cf93dd06db0f |
children |
rev | line source |
---|---|
23473
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
1 /* |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
4 * |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
8 * |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
13 * accompanied this code). |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
14 * |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
18 * |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
21 * questions. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
22 * |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
23 */ |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
24 |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
25 /** |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
26 * @test |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
27 * @bug 6869327 |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
28 * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
29 * @library /testlibrary |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
30 * @run main UseCountedLoopSafepoints |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
31 */ |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
32 |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
33 import java.util.concurrent.atomic.AtomicLong; |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
34 import com.oracle.java.testlibrary.ProcessTools; |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
35 import com.oracle.java.testlibrary.OutputAnalyzer; |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
36 |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
37 public class UseCountedLoopSafepoints { |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
38 private static final AtomicLong _num = new AtomicLong(0); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
39 |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
40 // Uses the fact that an EnableBiasedLocking vmop will be started |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
41 // after 500ms, while we are still in the loop. If there is a |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
42 // safepoint in the counted loop, then we will reach safepoint |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
43 // very quickly. Otherwise SafepointTimeout will be hit. |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
44 public static void main (String args[]) throws Exception { |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
45 if (args.length == 1) { |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
46 final int loops = Integer.parseInt(args[0]); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
47 for (int i = 0; i < loops; i++) { |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
48 _num.addAndGet(1); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
49 } |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
50 } else { |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
51 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
52 "-XX:+IgnoreUnrecognizedVMOptions", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
53 "-XX:-TieredCompilation", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
54 "-XX:+UseBiasedLocking", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
55 "-XX:BiasedLockingStartupDelay=500", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
56 "-XX:+SafepointTimeout", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
57 "-XX:SafepointTimeoutDelay=2000", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
58 "-XX:+UseCountedLoopSafepoints", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
59 "UseCountedLoopSafepoints", |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
60 "2000000000" |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
61 ); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
62 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
63 output.shouldNotContain("Timeout detected"); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
64 output.shouldHaveExitValue(0); |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
65 } |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
66 } |
cf93dd06db0f
6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff
changeset
|
67 } |