Mercurial > hg > graal-compiler
annotate test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java @ 20488:9c8439756c05
8052313: Backport CDS tests from JDK-9 to jdk8_u40
Summary: Copied CDS tests from jdk-9 to jdk8u40
Reviewed-by: ccheung, dholmes
author | mseledtsov |
---|---|
date | Fri, 19 Sep 2014 11:12:39 -0400 |
parents | 8a7429682242 |
children | 85f4c4ecc963 |
rev | line source |
---|---|
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
1 /* |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
4 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
8 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
13 * accompanied this code). |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
14 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
18 * |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
21 * questions. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
22 */ |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
23 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
24 /* |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
25 * @test |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
26 * @key gc |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
27 * @bug 8049831 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
28 * @library /testlibrary /testlibrary/whitebox |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
29 * @build TestCMSClassUnloadingEnabledHWM AllocateBeyondMetaspaceSize |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
31 * @run driver TestCMSClassUnloadingEnabledHWM |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
32 * @summary Test that -XX:-CMSClassUnloadingEnabled will trigger a Full GC when more than MetaspaceSize metadata is allocated. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
33 */ |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
34 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
35 import com.oracle.java.testlibrary.OutputAnalyzer; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
36 import com.oracle.java.testlibrary.ProcessTools; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
37 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
38 import java.util.ArrayList; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
39 import java.util.Arrays; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
40 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
41 public class TestCMSClassUnloadingEnabledHWM { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
42 private static long MetaspaceSize = 32 * 1024 * 1024; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
43 private static long YoungGenSize = 32 * 1024 * 1024; |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
44 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
45 private static OutputAnalyzer run(boolean enableUnloading) throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
46 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
47 "-Xbootclasspath/a:.", |
20330
8a7429682242
8055275: Several gc/class_unloading/ tests fail due to missed +UnlockDiagnosticVMOptions flag
stefank
parents:
20282
diff
changeset
|
48 "-XX:+UnlockDiagnosticVMOptions", |
20282
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
49 "-XX:+WhiteBoxAPI", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
50 "-XX:MetaspaceSize=" + MetaspaceSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
51 "-Xmn" + YoungGenSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
52 "-XX:+UseConcMarkSweepGC", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
53 "-XX:" + (enableUnloading ? "+" : "-") + "CMSClassUnloadingEnabled", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
54 "-XX:+PrintHeapAtGC", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
55 "-XX:+PrintGCDetails", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
56 "AllocateBeyondMetaspaceSize", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
57 "" + MetaspaceSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
58 "" + YoungGenSize); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
59 return new OutputAnalyzer(pb.start()); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
60 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
61 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
62 public static OutputAnalyzer runWithCMSClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
63 return run(true); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
64 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
65 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
66 public static OutputAnalyzer runWithoutCMSClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
67 return run(false); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
68 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
69 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
70 public static void testWithoutCMSClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
71 // -XX:-CMSClassUnloadingEnabled is used, so we expect a full GC instead of a concurrent cycle. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
72 OutputAnalyzer out = runWithoutCMSClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
73 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
74 out.shouldMatch(".*Full GC.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
75 out.shouldNotMatch(".*CMS Initial Mark.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
76 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
77 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
78 public static void testWithCMSClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
79 // -XX:+CMSClassUnloadingEnabled is used, so we expect a concurrent cycle instead of a full GC. |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
80 OutputAnalyzer out = runWithCMSClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
81 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
82 out.shouldMatch(".*CMS Initial Mark.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
83 out.shouldNotMatch(".*Full GC.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
84 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
85 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
86 public static void main(String args[]) throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
87 testWithCMSClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
88 testWithoutCMSClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
89 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
90 } |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
91 |