18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
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 /testlibrary
29 * @run main UseCompressedOops
30 */
31 import java.util.ArrayList;
32 import java.util.Collections;
33 import com.oracle.java.testlibrary.*;
34
35 public class UseCompressedOops {
36
37 public static void main(String[] args) throws Exception {
38
39 if (Platform.is64bit()) {
40 // Explicitly turn of compressed oops
41 testCompressedOops("-XX:-UseCompressedOops", "-Xmx32m")
42 .shouldNotContain("Compressed Oops")
43 .shouldHaveExitValue(0);
44
45 // Compressed oops should be on by default
46 testCompressedOops("-Xmx32m")
47 .shouldContain("Compressed Oops mode")
48 .shouldHaveExitValue(0);
49
50 // Explicly enabling compressed oops
51 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32m")
52 .shouldContain("Compressed Oops mode")
53 .shouldHaveExitValue(0);
54
55 // Skip the following three test cases if we're on OSX or Solaris.
56 //
57 // OSX doesn't seem to care about HeapBaseMinAddress and Solaris
58 // puts the heap way up, forcing different behaviour.
59 if (!Platform.isOSX() && !Platform.isSolaris()) {
60 // Larger than 4gb heap should result in zero based with shift 3
61 testCompressedOops("-XX:+UseCompressedOops", "-Xmx5g")
62 .shouldContain("Zero based")
63 .shouldContain("Oop shift amount: 3")
64 .shouldHaveExitValue(0);
65
66 // Small heap above 4gb should result in zero based with shift 3
67 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=4g")
68 .shouldContain("Zero based")
69 .shouldContain("Oop shift amount: 3")
70 .shouldHaveExitValue(0);
71
72 // Small heap above 32gb should result in non-zero based with shift 3
73 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=32g")
74 .shouldContain("Non-zero based")
75 .shouldContain("Oop shift amount: 3")
76 .shouldHaveExitValue(0);
77
78 // 32gb heap with heap base above 64gb and object alignment set to 16 bytes should result
79 // in non-zero based with shift 4
80 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16",
81 "-XX:HeapBaseMinAddress=64g")
82 .shouldContain("Non-zero based")
83 .shouldContain("Oop shift amount: 4")
84 .shouldHaveExitValue(0);
85
86 // 32gb heap with object alignment set to 16 bytes should result in zero based with shift 4
87 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16")
88 .shouldContain("Zero based")
89 .shouldContain("Oop shift amount: 4")
90 .shouldHaveExitValue(0);
91 }
92
93 // Explicitly enabling compressed oops with 32gb heap should result a warning
94 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32g")
95 .shouldContain("Max heap size too large for Compressed Oops")
96 .shouldHaveExitValue(0);
97
98 // 32gb heap should not result a warning
99 testCompressedOops("-Xmx32g")
100 .shouldNotContain("Max heap size too large for Compressed Oops")
101 .shouldHaveExitValue(0);
102
103 // Explicitly enabling compressed oops with 32gb heap and object
104 // alignment set to 8 byte should result a warning
105 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=8")
106 .shouldContain("Max heap size too large for Compressed Oops")
107 .shouldHaveExitValue(0);
108
109 // 64gb heap and object alignment set to 16 bytes should result in a warning
110 testCompressedOops("-XX:+UseCompressedOops", "-Xmx64g", "-XX:ObjectAlignmentInBytes=16")
111 .shouldContain("Max heap size too large for Compressed Oops")
112 .shouldHaveExitValue(0);
113
114 } else {
115 // Compressed oops should only apply to 64bit platforms
116 testCompressedOops("-XX:+UseCompressedOops", "-Xmx32m")
117 .shouldContain("Unrecognized VM option 'UseCompressedOops'")
118 .shouldHaveExitValue(1);
119 }
120 }
121
122 private static OutputAnalyzer testCompressedOops(String... flags) throws Exception {
123 ArrayList<String> args = new ArrayList<>();
124
125 // Always run with these three:
126 args.add("-XX:+UnlockDiagnosticVMOptions");
127 args.add("-XX:+PrintCompressedOopsMode");
128 args.add("-Xms32m");
129
130 // Add the extra flags
131 Collections.addAll(args, flags);
132
133 args.add("-version");
134
135 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
136 return new OutputAnalyzer(pb.start());
137 }
138 }
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
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 /testlibrary
29 * @run main UseCompressedOops
30 */
31 import java.util.ArrayList;
32 import java.util.Collections;
33 import com.oracle.java.testlibrary.*;
34
35 public class UseCompressedOops {
36
37 public static void main(String[] args) throws Exception {
38 testCompressedOopsModesGCs();
39 testCompressedOopsModesGCs("-XX:+UseLargePages");
40 }
41
42 public static void testCompressedOopsModesGCs(String... flags) throws Exception {
43 ArrayList<String> args = new ArrayList<>();
44 Collections.addAll(args, flags);
45
46 // Test default.
47 testCompressedOopsModes(args);
48 // Test GCs.
49 testCompressedOopsModes(args, "-XX:+UseG1GC");
50 testCompressedOopsModes(args, "-XX:+UseConcMarkSweepGC");
51 testCompressedOopsModes(args, "-XX:+UseSerialGC");
52 testCompressedOopsModes(args, "-XX:+UseParallelGC");
53 testCompressedOopsModes(args, "-XX:+UseParallelOldGC");
54 }
55
56 public static void testCompressedOopsModes(ArrayList<String> flags1, String... flags2) throws Exception {
57 ArrayList<String> args = new ArrayList<>();
58 args.addAll(flags1);
59 Collections.addAll(args, flags2);
60
61 if (Platform.is64bit()) {
62 // Explicitly turn of compressed oops
63 testCompressedOops(args, "-XX:-UseCompressedOops", "-Xmx32m")
64 .shouldNotContain("Compressed Oops")
65 .shouldHaveExitValue(0);
66
67 // Compressed oops should be on by default
68 testCompressedOops(args, "-Xmx32m")
69 .shouldContain("Compressed Oops mode")
70 .shouldHaveExitValue(0);
71
72 // Explicly enabling compressed oops
73 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
74 .shouldContain("Compressed Oops mode")
75 .shouldHaveExitValue(0);
76
77 // Skip the following three test cases if we're on OSX or Solaris.
78 //
79 // OSX doesn't seem to care about HeapBaseMinAddress and Solaris
80 // puts the heap way up, forcing different behaviour.
81 if (!Platform.isOSX() && !Platform.isSolaris()) {
82 // Larger than 4gb heap should result in zero based with shift 3
83 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx5g")
84 .shouldContain("Zero based")
85 .shouldContain("Oop shift amount: 3")
86 .shouldHaveExitValue(0);
87
88 // Larger than 3gb heap and HeapBaseMinAddress=1g should result in zero based with shift 3
89 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx3200m", "-XX:HeapBaseMinAddress=1g")
90 .shouldContain("Zero based")
91 .shouldContain("Oop shift amount: 3")
92 .shouldHaveExitValue(0);
93
94 // Small heap above 4gb should result in zero based with shift 3
95 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=4g")
96 .shouldContain("Zero based")
97 .shouldContain("Oop shift amount: 3")
98 .shouldHaveExitValue(0);
99
100 // Small heap above 32gb should result in non-zero based with shift 3
101 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=32g")
102 .shouldContain("Non-zero disjoint base")
103 .shouldContain("Oop shift amount: 3")
104 .shouldHaveExitValue(0);
105
106 // Small heap above 32gb should result in non-zero based with shift 3
107 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=72704m")
108 .shouldContain("Non-zero based")
109 .shouldContain("Oop shift amount: 3")
110 .shouldHaveExitValue(0);
111
112 // 32gb heap with heap base above 64gb and object alignment set to 16 bytes should result
113 // in non-zero based with shift 4
114 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16",
115 "-XX:HeapBaseMinAddress=64g")
116 .shouldContain("Non-zero disjoint base")
117 .shouldContain("Oop shift amount: 4")
118 .shouldHaveExitValue(0);
119
120 // 32gb heap with object alignment set to 16 bytes should result in zero based with shift 4
121 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16")
122 .shouldContain("Zero based")
123 .shouldContain("Oop shift amount: 4")
124 .shouldHaveExitValue(0);
125 }
126
127 // This is a pathologic case for the heap allocation algorithm. Regression test.
128 // HeapBaseMinAddress must be 2g and should not be set on the command line.
129 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx2g")
130 .shouldNotContain("Max heap size too large for Compressed Oops")
131 .shouldHaveExitValue(0);
132 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx29g", "-XX:CompressedClassSpaceSize=1g")
133 .shouldNotContain("Max heap size too large for Compressed Oops")
134 .shouldHaveExitValue(0);
135
136 // Explicitly enabling compressed oops with 32gb heap should result a warning
137 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g")
138 .shouldContain("Max heap size too large for Compressed Oops")
139 .shouldHaveExitValue(0);
140
141 // 32gb heap should not result a warning
142 testCompressedOops(args, "-Xmx32g")
143 .shouldNotContain("Max heap size too large for Compressed Oops")
144 .shouldHaveExitValue(0);
145
146 // Explicitly enabling compressed oops with 32gb heap and object
147 // alignment set to 8 byte should result a warning
148 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=8")
149 .shouldContain("Max heap size too large for Compressed Oops")
150 .shouldHaveExitValue(0);
151
152 // 64gb heap and object alignment set to 16 bytes should result in a warning
153 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx64g", "-XX:ObjectAlignmentInBytes=16")
154 .shouldContain("Max heap size too large for Compressed Oops")
155 .shouldHaveExitValue(0);
156
157 } else {
158 // Compressed oops should only apply to 64bit platforms
159 testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
160 .shouldContain("Unrecognized VM option 'UseCompressedOops'")
161 .shouldHaveExitValue(1);
162 }
163 }
164
165 private static OutputAnalyzer testCompressedOops(ArrayList<String> flags1, String... flags2) throws Exception {
166 ArrayList<String> args = new ArrayList<>();
167
168 // Always run with these three:
169 args.add("-XX:+UnlockDiagnosticVMOptions");
170 args.add("-XX:+PrintCompressedOopsMode");
171 args.add("-Xms32m");
172
173 // Add the extra flags
174 args.addAll(flags1);
175 Collections.addAll(args, flags2);
176
177 args.add("-version");
178
179 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
180 return new OutputAnalyzer(pb.start());
181 }
182 }
|