20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8022865
27 * @summary Tests for different combination of UseCompressedOops options
28 * @library /test/lib
29 * @modules java.base/jdk.internal.misc
30 * java.management
31 * @build sun.hotspot.WhiteBox
32 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
33 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops
34 */
35 import java.util.ArrayList;
36 import java.util.Collections;
37 import jdk.test.lib.Platform;
38 import jdk.test.lib.process.ProcessTools;
39 import jdk.test.lib.process.OutputAnalyzer;
40
41 import sun.hotspot.code.Compiler;
42
43 public class UseCompressedOops {
44
45 public static void main(String[] args) throws Exception {
46 testCompressedOopsModesGCs();
47 testCompressedOopsModesGCs("-XX:+UseLargePages");
48 }
49
50 public static void testCompressedOopsModesGCs(String... flags) throws Exception {
51 ArrayList<String> args = new ArrayList<>();
52 Collections.addAll(args, flags);
53
54 // Test default.
55 testCompressedOopsModes(args);
56 // Test GCs.
57 testCompressedOopsModes(args, "-XX:+UseG1GC");
58 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
59 testCompressedOopsModes(args, "-XX:+UseConcMarkSweepGC");
60 }
61 testCompressedOopsModes(args, "-XX:+UseSerialGC");
62 testCompressedOopsModes(args, "-XX:+UseParallelGC");
63 testCompressedOopsModes(args, "-XX:+UseParallelOldGC");
64 }
65
66 public static void testCompressedOopsModes(ArrayList<String> flags1, String... flags2) throws Exception {
67 ArrayList<String> args = new ArrayList<>();
68 args.addAll(flags1);
69 Collections.addAll(args, flags2);
70
71 if (Platform.is64bit()) {
72 // Explicitly turn of compressed oops
73 testCompressedOops(args, "-XX:-UseCompressedOops", "-Xmx32m")
74 .shouldNotContain("Compressed Oops")
75 .shouldHaveExitValue(0);
76
77 // Compressed oops should be on by default
78 testCompressedOops(args, "-Xmx32m")
79 .shouldContain("Compressed Oops mode")
80 .shouldHaveExitValue(0);
81
82 // Explicly enabling compressed oops
83 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8022865
27 * @summary Tests for different combination of UseCompressedOops options
28 * @library /test/lib
29 * @modules java.base/jdk.internal.misc
30 * java.management
31 * @build sun.hotspot.WhiteBox
32 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
33 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops
34 */
35 import java.util.ArrayList;
36 import java.util.Collections;
37 import jdk.test.lib.Platform;
38 import jdk.test.lib.process.ProcessTools;
39 import jdk.test.lib.process.OutputAnalyzer;
40 import sun.hotspot.gc.GC;
41
42 import sun.hotspot.code.Compiler;
43
44 public class UseCompressedOops {
45
46 public static void main(String[] args) throws Exception {
47 testCompressedOopsModesGCs();
48 testCompressedOopsModesGCs("-XX:+UseLargePages");
49 }
50
51 public static void testCompressedOopsModesGCs(String... flags) throws Exception {
52 ArrayList<String> args = new ArrayList<>();
53 Collections.addAll(args, flags);
54
55 // Test default.
56 testCompressedOopsModes(args);
57 // Test GCs.
58 testCompressedOopsModes(args, "-XX:+UseG1GC");
59 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
60 testCompressedOopsModes(args, "-XX:+UseConcMarkSweepGC");
61 }
62 testCompressedOopsModes(args, "-XX:+UseSerialGC");
63 testCompressedOopsModes(args, "-XX:+UseParallelGC");
64 testCompressedOopsModes(args, "-XX:+UseParallelOldGC");
65 if (GC.Shenandoah.isSupported()) {
66 testCompressedOopsModes(args, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC");
67 }
68 }
69
70 public static void testCompressedOopsModes(ArrayList<String> flags1, String... flags2) throws Exception {
71 ArrayList<String> args = new ArrayList<>();
72 args.addAll(flags1);
73 Collections.addAll(args, flags2);
74
75 if (Platform.is64bit()) {
76 // Explicitly turn of compressed oops
77 testCompressedOops(args, "-XX:-UseCompressedOops", "-Xmx32m")
78 .shouldNotContain("Compressed Oops")
79 .shouldHaveExitValue(0);
80
81 // Compressed oops should be on by default
82 testCompressedOops(args, "-Xmx32m")
83 .shouldContain("Compressed Oops mode")
84 .shouldHaveExitValue(0);
85
86 // Explicly enabling compressed oops
87 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
|