Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8258576: Try to get zerobased CCS if heap is above 32 and CDS is disa…
…bled

Reviewed-by: mdoerr, stuefe
  • Loading branch information
reinrich committed Jan 12, 2021
1 parent a3561ae commit a6ab9e4740024302fa74c3ede286c3fb6776b438
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
@@ -703,13 +703,13 @@ void Metaspace::global_initialize() {
// case (b)
ReservedSpace rs;

// If UseCompressedOops=1, java heap may have been placed in coops-friendly
// territory already (lower address regions), so we attempt to place ccs
// If UseCompressedOops=1 and the java heap has been placed in coops-friendly
// territory, i.e. its base is under 32G, then we attempt to place ccs
// right above the java heap.
// If UseCompressedOops=0, the heap has been placed anywhere - probably in
// high memory regions. In that case, try to place ccs at the lowest allowed
// mapping address.
address base = UseCompressedOops ? CompressedOops::end() : (address)HeapBaseMinAddress;
// Otherwise the lower 32G are still free. We try to place ccs at the lowest
// allowed mapping address.
address base = (UseCompressedOops && (uint64_t)CompressedOops::base() < OopEncodingHeapMax) ?
CompressedOops::end() : (address)HeapBaseMinAddress;
base = align_up(base, Metaspace::reserve_alignment());

const size_t size = align_up(CompressedClassSpaceSize, Metaspace::reserve_alignment());
@@ -98,17 +98,41 @@ public static void largeHeapTest() throws Exception {
"-Xshare:off",
"-XX:+VerifyBeforeGC", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (testNarrowKlassBase() && !Platform.isAix()) {
// AIX: the heap cannot be placed below 32g. The first attempt to
// place the CCS behind the heap fails (luckily). Subsequently CCS
// is successfully placed below 32g. So we get 0x0 as narrow klass
// base.
if (testNarrowKlassBase() && !Platform.isPPC() && !Platform.isOSX()) {
// PPC: in most cases the heap cannot be placed below 32g so there
// is room for ccs and narrow klass base will be 0x0. Exception:
// Linux 4.1.42 or earlier (see ELF_ET_DYN_BASE in JDK-8244847).
// For simplicity we exclude PPC.
// OSX: similar.
output.shouldNotContain("Narrow klass base: 0x0000000000000000");
output.shouldContain("Narrow klass shift: 0");
}
output.shouldHaveExitValue(0);
}

// Settings as in largeHeapTest() except for max heap size. We make max heap
// size even larger such that it cannot fit into lower 32G but not too large
// for compressed oops.
// We expect a zerobased ccs.
public static void largeHeapAbove32GTest() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+UnlockExperimentalVMOptions",
"-Xmx31g",
"-XX:-UseAOT", // AOT explicitly set klass shift to 3.
logging_option,
"-Xshare:off",
"-XX:+VerifyBeforeGC", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
if (testNarrowKlassBase()) {
output.shouldContain("Narrow klass base: 0x0000000000000000");
if (!Platform.isAArch64() && !Platform.isOSX()) {
output.shouldContain("Narrow klass shift: 0");
}
}
output.shouldHaveExitValue(0);
}

// Using large paged heap, metaspace uses small pages.
public static void largePagesForHeapTest() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
@@ -297,6 +321,7 @@ public static void main(String[] args) throws Exception {
smallHeapTest();
smallHeapTestWith1G();
largeHeapTest();
largeHeapAbove32GTest();
largePagesForHeapTest();
heapBaseMinAddressTest();
sharingTest();

0 comments on commit a6ab9e4

Please sign in to comment.