Mercurial > hg > truffle
annotate test/gc/class_unloading/TestG1ClassUnloadingHWM.java @ 20282:f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
Summary: Added -XX:+/-ClassUnloadingWithConcurrentMark
Reviewed-by: jmasa, brutisso, mgerdin
author | stefank |
---|---|
date | Wed, 06 Aug 2014 09:55:16 +0200 |
parents | |
children | 8a7429682242 |
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 TestG1ClassUnloadingHWM 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 TestG1ClassUnloadingHWM |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
32 * @summary Test that -XX:-ClassUnloadingWithConcurrentMark 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 TestG1ClassUnloadingHWM { |
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:.", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
48 "-XX:+WhiteBoxAPI", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
49 "-XX:MetaspaceSize=" + MetaspaceSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
50 "-Xmn" + YoungGenSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
51 "-XX:+UseG1GC", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
52 "-XX:" + (enableUnloading ? "+" : "-") + "ClassUnloadingWithConcurrentMark", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
53 "-XX:+PrintHeapAtGC", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
54 "-XX:+PrintGCDetails", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
55 "AllocateBeyondMetaspaceSize", |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
56 "" + MetaspaceSize, |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
57 "" + YoungGenSize); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
58 return new OutputAnalyzer(pb.start()); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
59 } |
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 public static OutputAnalyzer runWithG1ClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
62 return run(true); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
63 } |
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 public static OutputAnalyzer runWithoutG1ClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
66 return run(false); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
67 } |
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 public static void testWithoutG1ClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
70 // -XX:-ClassUnloadingWithConcurrentMark 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
|
71 OutputAnalyzer out = runWithoutG1ClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
72 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
73 out.shouldMatch(".*Full GC.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
74 out.shouldNotMatch(".*initial-mark.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
75 } |
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 public static void testWithG1ClassUnloading() throws Exception { |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
78 // -XX:+ClassUnloadingWithConcurrentMark 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
|
79 OutputAnalyzer out = runWithG1ClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
80 |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
81 out.shouldMatch(".*initial-mark.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
82 out.shouldNotMatch(".*Full GC.*"); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
83 } |
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 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
|
86 testWithG1ClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
87 testWithoutG1ClassUnloading(); |
f3aeae1f9fc5
8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents:
diff
changeset
|
88 } |
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 |