2013-10-25 19:19:29 +00:00
|
|
|
/*
|
2020-04-30 02:51:45 +00:00
|
|
|
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
2013-10-25 19:19:29 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @bug 8024927
|
|
|
|
* @summary Testing address of compressed class pointer space as best as possible.
|
2020-05-13 09:36:12 +00:00
|
|
|
* @requires vm.bits == 64 & os.family != "windows" & !vm.graal.enabled
|
2016-08-19 14:06:30 +00:00
|
|
|
* @library /test/lib
|
2016-04-09 22:03:39 +00:00
|
|
|
* @modules java.base/jdk.internal.misc
|
2015-03-26 15:36:56 +00:00
|
|
|
* java.management
|
2020-04-30 02:51:45 +00:00
|
|
|
* @run driver CompressedClassPointers
|
2013-10-25 19:19:29 +00:00
|
|
|
*/
|
|
|
|
|
2016-08-19 14:06:30 +00:00
|
|
|
import jdk.test.lib.Platform;
|
|
|
|
import jdk.test.lib.process.ProcessTools;
|
|
|
|
import jdk.test.lib.process.OutputAnalyzer;
|
2018-08-02 21:40:55 +00:00
|
|
|
import jtreg.SkippedException;
|
2013-10-25 19:19:29 +00:00
|
|
|
|
|
|
|
public class CompressedClassPointers {
|
|
|
|
|
|
|
|
public static void smallHeapTest() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-Xmx128m",
|
2015-12-10 13:57:55 +00:00
|
|
|
"-Xlog:gc+metaspace=trace",
|
2018-04-23 14:51:46 +00:00
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base: 0x0000000000000000");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
2019-10-28 20:41:47 +00:00
|
|
|
public static void smallHeapTestWith1G() throws Exception {
|
2013-10-25 19:19:29 +00:00
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
2019-10-28 20:41:47 +00:00
|
|
|
"-XX:CompressedClassSpaceSize=1g",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-Xmx128m",
|
2015-12-10 13:57:55 +00:00
|
|
|
"-Xlog:gc+metaspace=trace",
|
2018-04-23 14:51:46 +00:00
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void largeHeapTest() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
2019-08-08 08:43:16 +00:00
|
|
|
"-XX:+UnlockExperimentalVMOptions",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-Xmx30g",
|
2016-12-12 03:07:04 +00:00
|
|
|
"-XX:-UseAOT", // AOT explicitly set klass shift to 3.
|
2015-12-10 13:57:55 +00:00
|
|
|
"-Xlog:gc+metaspace=trace",
|
2018-04-23 14:51:46 +00:00
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldNotContain("Narrow klass base: 0x0000000000000000");
|
|
|
|
output.shouldContain("Narrow klass shift: 0");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void largePagesTest() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:+UseLargePages",
|
2015-12-10 13:57:55 +00:00
|
|
|
"-Xlog:gc+metaspace=trace",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base:");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
2014-02-19 02:58:13 +00:00
|
|
|
public static void heapBaseMinAddressTest() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:HeapBaseMinAddress=1m",
|
2016-04-07 17:11:15 +00:00
|
|
|
"-Xlog:gc+heap+coops=debug",
|
2014-02-19 02:58:13 +00:00
|
|
|
"-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("HeapBaseMinAddress must be at least");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
2013-10-25 19:19:29 +00:00
|
|
|
public static void sharingTest() throws Exception {
|
|
|
|
// Test small heaps
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
2015-03-30 15:28:07 +00:00
|
|
|
"-XX:SharedArchiveFile=./CompressedClassPointers.jsa",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-XX:+PrintCompressedOopsMode",
|
|
|
|
"-XX:+VerifyBeforeGC",
|
2019-12-20 07:04:49 +00:00
|
|
|
"-Xshare:dump", "-Xlog:cds");
|
2013-10-25 19:19:29 +00:00
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
2017-08-03 08:24:34 +00:00
|
|
|
if (output.firstMatch("Shared spaces are not supported in this VM") != null) {
|
|
|
|
return;
|
|
|
|
}
|
2013-10-25 19:19:29 +00:00
|
|
|
try {
|
|
|
|
output.shouldContain("Loading classes to share");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
2015-03-30 15:28:07 +00:00
|
|
|
"-XX:SharedArchiveFile=./CompressedClassPointers.jsa",
|
2013-10-25 19:19:29 +00:00
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-XX:+PrintCompressedOopsMode",
|
|
|
|
"-Xshare:on",
|
|
|
|
"-version");
|
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("sharing");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
output.shouldContain("Unable to use shared archive");
|
|
|
|
output.shouldHaveExitValue(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-13 09:36:12 +00:00
|
|
|
public static void smallHeapTestNoCoop() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-Xlog:gc+metaspace=trace",
|
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base: 0x0000000000000000");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void smallHeapTestWith1GNoCoop() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:CompressedClassSpaceSize=1g",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-Xlog:gc+metaspace=trace",
|
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base: 0x0000000000000000");
|
|
|
|
output.shouldContain("Narrow klass shift: 0");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void largeHeapTestNoCoop() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:+UnlockExperimentalVMOptions",
|
|
|
|
"-Xmx30g",
|
|
|
|
"-XX:-UseAOT", // AOT explicitly set klass shift to 3.
|
|
|
|
"-Xlog:gc+metaspace=trace",
|
|
|
|
"-Xshare:off",
|
|
|
|
"-Xlog:cds=trace",
|
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base: 0x0000000000000000");
|
|
|
|
output.shouldContain("Narrow klass shift: 0");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void largePagesTestNoCoop() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:+UseLargePages",
|
|
|
|
"-Xlog:gc+metaspace=trace",
|
|
|
|
"-XX:+VerifyBeforeGC", "-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("Narrow klass base:");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void heapBaseMinAddressTestNoCoop() throws Exception {
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:HeapBaseMinAddress=1m",
|
|
|
|
"-Xlog:gc+heap+coops=debug",
|
|
|
|
"-version");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("HeapBaseMinAddress must be at least");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void sharingTestNoCoop() throws Exception {
|
|
|
|
// Test small heaps
|
|
|
|
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:SharedArchiveFile=./CompressedClassPointers.jsa",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-XX:+PrintCompressedOopsMode",
|
|
|
|
"-XX:+VerifyBeforeGC",
|
|
|
|
"-Xshare:dump", "-Xlog:cds");
|
|
|
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
|
|
|
if (output.firstMatch("Shared spaces are not supported in this VM") != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
output.shouldContain("Loading classes to share");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
pb = ProcessTools.createJavaProcessBuilder(
|
|
|
|
"-XX:-UseCompressedOops",
|
|
|
|
"-XX:+UseCompressedClassPointers",
|
|
|
|
"-XX:+UnlockDiagnosticVMOptions",
|
|
|
|
"-XX:SharedArchiveFile=./CompressedClassPointers.jsa",
|
|
|
|
"-Xmx128m",
|
|
|
|
"-XX:SharedBaseAddress=8g",
|
|
|
|
"-XX:+PrintCompressedOopsMode",
|
|
|
|
"-Xshare:on",
|
|
|
|
"-version");
|
|
|
|
output = new OutputAnalyzer(pb.start());
|
|
|
|
output.shouldContain("sharing");
|
|
|
|
output.shouldHaveExitValue(0);
|
|
|
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
output.shouldContain("Unable to use shared archive");
|
|
|
|
output.shouldHaveExitValue(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-19 02:58:13 +00:00
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
smallHeapTest();
|
2019-10-28 20:41:47 +00:00
|
|
|
smallHeapTestWith1G();
|
2014-02-19 02:58:13 +00:00
|
|
|
largeHeapTest();
|
|
|
|
largePagesTest();
|
|
|
|
heapBaseMinAddressTest();
|
|
|
|
sharingTest();
|
2020-05-13 09:36:12 +00:00
|
|
|
|
8244224: Implementation of JEP 381: Remove the Solaris and SPARC Ports
Reviewed-by: alanb, bchristi, dcubed, dfuchs, eosterlund, erikj, glaubitz, ihse, iignatyev, jjiang, kbarrett, ksrini, kvn, naoto, prr, rriggs, serb, sspitsyn, stefank, tschatzl, valeriep, weijun, weijun
2020-05-21 00:33:37 +00:00
|
|
|
boolean ccpRequiresCoop = Platform.isAArch64();
|
2020-05-13 09:36:12 +00:00
|
|
|
|
|
|
|
if (!ccpRequiresCoop && !Platform.isOSX()) {
|
|
|
|
// Testing compressed class pointers without compressed oops.
|
|
|
|
// This is only possible if the platform supports it. Notably,
|
|
|
|
// on macOS, when compressed oops is disabled and the heap is
|
|
|
|
// given an arbitrary address, that address occasionally collides
|
|
|
|
// with where we would ideally have placed the compressed class
|
|
|
|
// space. Therefore, macOS is omitted for now.
|
|
|
|
smallHeapTestNoCoop();
|
|
|
|
smallHeapTestWith1GNoCoop();
|
|
|
|
largeHeapTestNoCoop();
|
|
|
|
largePagesTestNoCoop();
|
|
|
|
heapBaseMinAddressTestNoCoop();
|
|
|
|
sharingTestNoCoop();
|
|
|
|
}
|
2014-02-19 02:58:13 +00:00
|
|
|
}
|
2013-10-25 19:19:29 +00:00
|
|
|
}
|