9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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 /**
26 * @test
27 * @summary Sanity test of AOT Code Cache with compressed oops configurations
28 * @requires vm.cds.supports.aot.code.caching
29 * @requires vm.compMode != "Xcomp"
30 * @comment The test verifies AOT checks during VM startup and not code generation.
31 * No need to run it with -Xcomp. It takes a lot of time to complete all
32 * subtests with this flag.
33 * @library /test/lib /test/setup_aot
34 * @build AOTCodeCompressedOopsTest JavacBenchApp
35 * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar
36 * JavacBenchApp
37 * JavacBenchApp$ClassFile
38 * JavacBenchApp$FileManager
39 * JavacBenchApp$SourceFile
40 * @run driver AOTCodeCompressedOopsTest
41 */
42
43 import java.util.ArrayList;
44 import java.util.List;
45 import java.util.regex.Matcher;
46 import java.util.regex.Pattern;
47
48 import jdk.test.lib.cds.CDSAppTester;
49 import jdk.test.lib.process.OutputAnalyzer;
156 public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
157 if (runMode == RunMode.PRODUCTION) {
158 int aotCacheShift = -1, currentShift = -1;
159 long aotCacheBase = -1, currentBase = -1;
160 List<String> list = out.asLines();
161 /* We tried to have CompressedOops settings as per the test requirement,
162 * but it ultimately depends on OS and is not guaranteed that we have got the desired settings.
163 * So we parse the log output from the production run to get the real settings.
164 *
165 * Parse the following Xlog:cds output to get the values of CompressedOops::base and CompressedOops::shift
166 * used during the AOTCache assembly and production run:
167 *
168 * [0.022s][info][cds] CDS archive was created with max heap size = 1024M, and the following configuration:
169 * [0.022s][info][cds] narrow_klass_base at mapping start address, narrow_klass_pointer_bits = 32, narrow_klass_shift = 0
170 * [0.022s][info][cds] narrow_oop_mode = 1, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 3
171 * [0.022s][info][cds] The current max heap size = 31744M, G1HeapRegion::GrainBytes = 16777216
172 * [0.022s][info][cds] narrow_klass_base = 0x000007fc00000000, arrow_klass_pointer_bits = 32, narrow_klass_shift = 0
173 * [0.022s][info][cds] narrow_oop_mode = 3, narrow_oop_base = 0x0000000300000000, narrow_oop_shift = 3
174 * [0.022s][info][cds] heap range = [0x0000000301000000 - 0x0000000ac1000000]
175 */
176 Pattern p = Pattern.compile("narrow_oop_base = 0x(\\d+), narrow_oop_shift = (\\d)");
177 for (int i = 0; i < list.size(); i++) {
178 String line = list.get(i);
179 if (line.indexOf("CDS archive was created with max heap size") != -1) {
180 // Parse AOT Cache CompressedOops settings
181 line = list.get(i+2);
182 Matcher m = p.matcher(line);
183 if (!m.find()) {
184 throw new RuntimeException("Pattern \"" + p + "\" not found in the output");
185 }
186 aotCacheBase = Long.valueOf(m.group(1), 16);
187 aotCacheShift = Integer.valueOf(m.group(2));
188 // Parse current CompressedOops settings
189 line = list.get(i+5);
190 m = p.matcher(line);
191 if (!m.find()) {
192 throw new RuntimeException("Pattern \"" + p + "\" not found in the output");
193 }
194 currentBase = Long.valueOf(m.group(1), 16);
195 currentShift = Integer.valueOf(m.group(2));
196 break;
197 }
198 }
199 if (aotCacheShift == -1 || currentShift == -1 || aotCacheBase == -1 || currentBase == -1) {
200 throw new RuntimeException("Failed to find CompressedOops settings");
201 }
202 if (aotCacheShift != currentShift) {
203 out.shouldContain("AOT Code Cache disabled: it was created with different CompressedOops::shift()");
204 } else if ((aotCacheBase == 0 || currentBase == 0) && (aotCacheBase != currentBase)) {
205 out.shouldContain("AOTStubCaching is disabled: incompatible CompressedOops::base()");
206 } else {
207 out.shouldMatch("Read \\d+ entries table at offset \\d+ from AOT Code Cache");
208 }
209 }
210 }
211 }
212 }
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
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 /**
26 * @test
27 * @summary Sanity test of AOT Code Cache with compressed oops configurations
28 * @requires vm.cds.supports.aot.code.caching
29 * @requires vm.compMode != "Xcomp" & vm.compMode != "Xint"
30 * @comment The test verifies AOT checks during VM startup and not code generation.
31 * No need to run it with -Xcomp. It takes a lot of time to complete all
32 * subtests with this flag.
33 * @library /test/lib /test/setup_aot
34 * @build AOTCodeCompressedOopsTest JavacBenchApp
35 * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar app.jar
36 * JavacBenchApp
37 * JavacBenchApp$ClassFile
38 * JavacBenchApp$FileManager
39 * JavacBenchApp$SourceFile
40 * @run driver AOTCodeCompressedOopsTest
41 */
42
43 import java.util.ArrayList;
44 import java.util.List;
45 import java.util.regex.Matcher;
46 import java.util.regex.Pattern;
47
48 import jdk.test.lib.cds.CDSAppTester;
49 import jdk.test.lib.process.OutputAnalyzer;
156 public void checkExecution(OutputAnalyzer out, RunMode runMode) throws Exception {
157 if (runMode == RunMode.PRODUCTION) {
158 int aotCacheShift = -1, currentShift = -1;
159 long aotCacheBase = -1, currentBase = -1;
160 List<String> list = out.asLines();
161 /* We tried to have CompressedOops settings as per the test requirement,
162 * but it ultimately depends on OS and is not guaranteed that we have got the desired settings.
163 * So we parse the log output from the production run to get the real settings.
164 *
165 * Parse the following Xlog:cds output to get the values of CompressedOops::base and CompressedOops::shift
166 * used during the AOTCache assembly and production run:
167 *
168 * [0.022s][info][cds] CDS archive was created with max heap size = 1024M, and the following configuration:
169 * [0.022s][info][cds] narrow_klass_base at mapping start address, narrow_klass_pointer_bits = 32, narrow_klass_shift = 0
170 * [0.022s][info][cds] narrow_oop_mode = 1, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 3
171 * [0.022s][info][cds] The current max heap size = 31744M, G1HeapRegion::GrainBytes = 16777216
172 * [0.022s][info][cds] narrow_klass_base = 0x000007fc00000000, arrow_klass_pointer_bits = 32, narrow_klass_shift = 0
173 * [0.022s][info][cds] narrow_oop_mode = 3, narrow_oop_base = 0x0000000300000000, narrow_oop_shift = 3
174 * [0.022s][info][cds] heap range = [0x0000000301000000 - 0x0000000ac1000000]
175 */
176 Pattern p = Pattern.compile("narrow_oop_base = 0x([0-9a-fA-F]+), narrow_oop_shift = (\\d)");
177 for (int i = 0; i < list.size(); i++) {
178 String line = list.get(i);
179 if (line.indexOf("CDS archive was created with max heap size") != -1) {
180 // Parse AOT Cache CompressedOops settings
181 line = list.get(i+2);
182 Matcher m = p.matcher(line);
183 if (!m.find()) {
184 throw new RuntimeException("Pattern \"" + p + "\" not found in the output. Got \"" + line + "\"");
185 }
186 aotCacheBase = Long.valueOf(m.group(1), 16);
187 aotCacheShift = Integer.valueOf(m.group(2));
188 // Parse current CompressedOops settings
189 line = list.get(i+5);
190 m = p.matcher(line);
191 if (!m.find()) {
192 throw new RuntimeException("Pattern \"" + p + "\" not found in the output. Got \"" + line + "\"");
193 }
194 currentBase = Long.valueOf(m.group(1), 16);
195 currentShift = Integer.valueOf(m.group(2));
196 break;
197 }
198 }
199 if (aotCacheShift == -1 || currentShift == -1 || aotCacheBase == -1 || currentBase == -1) {
200 throw new RuntimeException("Failed to find CompressedOops settings");
201 }
202 if (aotCacheShift != currentShift) {
203 out.shouldContain("AOT Code Cache disabled: it was created with different CompressedOops::shift()");
204 } else if ((aotCacheBase == 0 || currentBase == 0) && (aotCacheBase != currentBase)) {
205 out.shouldContain("AOTStubCaching is disabled: incompatible CompressedOops::base()");
206 } else {
207 out.shouldMatch("Read \\d+ entries table at offset \\d+ from AOT Code Cache");
208 }
209 }
210 }
211 }
212 }
|