author | sspitsyn |
Wed, 03 May 2017 02:32:02 +0000 | |
changeset 46426 | 02a1fc064144 |
parent 40914 | 90c87069b39c |
permissions | -rw-r--r-- |
40914
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
1 |
/* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
4 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
8 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
13 |
* accompanied this code). |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
14 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
18 |
* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
21 |
* questions. |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
22 |
*/ |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
23 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
24 |
/* |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
25 |
* @test TestAgeOutput |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
26 |
* @bug 8164936 |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
27 |
* @summary Check that collectors using age table based aging print an age table even for the first garbage collection |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
28 |
* @key gc |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
29 |
* @requires vm.gc=="null" |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
31 |
* @library /test/lib |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
32 |
* @build sun.hotspot.WhiteBox |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
33 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
34 |
* @run main/othervm -XX:+UseSerialGC TestAgeOutput UseSerialGC |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
35 |
* @run main/othervm -XX:+UseConcMarkSweepGC TestAgeOutput UseConcMarkSweepGC |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
36 |
* @run main/othervm -XX:+UseG1GC TestAgeOutput UseG1GC |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
37 |
*/ |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
38 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
39 |
import sun.hotspot.WhiteBox; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
40 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
41 |
import java.util.regex.Matcher; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
42 |
import java.util.regex.Pattern; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
43 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
44 |
import jdk.test.lib.Platform; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
45 |
import jdk.test.lib.process.OutputAnalyzer; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
46 |
import jdk.test.lib.process.ProcessTools; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
47 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
48 |
import static jdk.test.lib.Asserts.*; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
49 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
50 |
public class TestAgeOutput { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
51 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
52 |
public static void checkPattern(String pattern, String what) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
53 |
Pattern r = Pattern.compile(pattern); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
54 |
Matcher m = r.matcher(what); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
55 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
56 |
if (!m.find()) { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
57 |
throw new RuntimeException("Could not find pattern " + pattern + " in output"); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
58 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
59 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
60 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
61 |
public static void runTest(String gcArg) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
62 |
final String[] arguments = { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
63 |
"-Xbootclasspath/a:.", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
64 |
"-XX:+UnlockExperimentalVMOptions", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
65 |
"-XX:+UnlockDiagnosticVMOptions", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
66 |
"-XX:+WhiteBoxAPI", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
67 |
"-XX:+" + gcArg, |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
68 |
"-Xmx10M", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
69 |
"-Xlog:gc+age=trace", |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
70 |
GCTest.class.getName() |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
71 |
}; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
72 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
73 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
74 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
75 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
76 |
output.shouldHaveExitValue(0); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
77 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
78 |
System.out.println(output.getStdout()); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
79 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
80 |
String stdout = output.getStdout(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
81 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
82 |
checkPattern(".*GC\\(0\\) .*Desired survivor size.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
83 |
checkPattern(".*GC\\(0\\) .*Age table with threshold.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
84 |
checkPattern(".*GC\\(0\\) .*- age 1:.*", stdout); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
85 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
86 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
87 |
public static void main(String[] args) throws Exception { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
88 |
runTest(args[0]); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
89 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
90 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
91 |
static class GCTest { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
92 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
93 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
94 |
public static Object holder; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
95 |
|
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
96 |
public static void main(String [] args) { |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
97 |
holder = new byte[100]; |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
98 |
WB.youngGC(); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
99 |
System.out.println(holder); |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
100 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
101 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
102 |
} |
90c87069b39c
8164936: G1 age table printout contains contents from previous GC
tschatzl
parents:
diff
changeset
|
103 |