Mercurial > hg > truffle
annotate test/gc/arguments/TestG1ConcRefinementThreads.java @ 20915:916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 13 Apr 2015 15:10:55 +0200 |
parents | 8ba0078861d4 |
children |
rev | line source |
---|---|
20505
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
1 /* |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
4 * |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
8 * |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
13 * accompanied this code). |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
14 * |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
18 * |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
21 * questions. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
22 */ |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
23 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
24 /* |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
25 * @test TestG1ConcRefinementThreads |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
26 * @key gc |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
27 * @bug 8047976 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
28 * @summary Tests argument processing for G1ConcRefinementThreads |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
29 * @library /testlibrary |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
30 */ |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
31 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
32 import com.oracle.java.testlibrary.*; |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
33 import java.util.*; |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
34 import java.util.regex.*; |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
35 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
36 public class TestG1ConcRefinementThreads { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
37 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
38 static final int AUTO_SELECT_THREADS_COUNT = 0; |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
39 static final int PASSED_THREADS_COUNT = 11; |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
40 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
41 public static void main(String args[]) throws Exception { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
42 // default case |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
43 runG1ConcRefinementThreadsTest( |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
44 new String[]{}, // automatically selected |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
45 AUTO_SELECT_THREADS_COUNT /* use default setting */); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
46 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
47 // zero setting case |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
48 runG1ConcRefinementThreadsTest( |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
49 new String[]{"-XX:G1ConcRefinementThreads=0"}, // automatically selected |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
50 AUTO_SELECT_THREADS_COUNT /* set to zero */); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
51 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
52 // non-zero sestting case |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
53 runG1ConcRefinementThreadsTest( |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
54 new String[]{"-XX:G1ConcRefinementThreads="+Integer.toString(PASSED_THREADS_COUNT)}, |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
55 PASSED_THREADS_COUNT); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
56 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
57 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
58 private static void runG1ConcRefinementThreadsTest(String[] passedOpts, |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
59 int expectedValue) throws Exception { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
60 List<String> vmOpts = new ArrayList<>(); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
61 if (passedOpts.length > 0) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
62 Collections.addAll(vmOpts, passedOpts); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
63 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
64 Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:+PrintFlagsFinal", "-version"); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
65 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
66 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()])); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
67 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
68 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
69 output.shouldHaveExitValue(0); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
70 String stdout = output.getStdout(); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
71 checkG1ConcRefinementThreadsConsistency(stdout, expectedValue); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
72 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
73 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
74 private static void checkG1ConcRefinementThreadsConsistency(String output, int expectedValue) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
75 int actualValue = getIntValue("G1ConcRefinementThreads", output); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
76 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
77 if (expectedValue == 0) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
78 // If expectedValue is automatically selected, set it same as ParallelGCThreads. |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
79 expectedValue = getIntValue("ParallelGCThreads", output); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
80 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
81 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
82 if (expectedValue != actualValue) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
83 throw new RuntimeException( |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
84 "Actual G1ConcRefinementThreads(" + Integer.toString(actualValue) |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
85 + ") is not equal to expected value(" + Integer.toString(expectedValue) + ")"); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
86 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
87 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
88 |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
89 public static int getIntValue(String flag, String where) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
90 Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
91 if (!m.find()) { |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
92 throw new RuntimeException("Could not find value for flag " + flag + " in output string"); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
93 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
94 String match = m.group(); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
95 return Integer.parseInt(match.substring(match.lastIndexOf(" ") + 1, match.length())); |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
96 } |
8ba0078861d4
8047976: Ergonomics for GC thread counts should update the flags
jwilhelm
parents:
diff
changeset
|
97 } |