Skip to content
Permalink
Browse files
8265705: aarch64: KlassDecodeMovk mode broken
Reviewed-by: aph, iklam, ngasson
  • Loading branch information
tstuefe committed May 17, 2021
1 parent cf97252 commit 3c010a7c7e64706ee6124d6e9ef69a5f3cf0d1ba
Showing with 44 additions and 18 deletions.
  1. +10 −1 src/hotspot/share/oops/compressedOops.cpp
  2. +34 −17 test/hotspot/jtreg/runtime/cds/SharedBaseAddress.java
@@ -219,7 +219,16 @@ void CompressedKlassPointers::initialize(address addr, size_t len) {
// cannot be larger than that).

base = addr;
shift = LogKlassAlignmentInBytes;

// JDK-8265705
// This is a temporary fix for aarch64: there, if the range-to-be-encoded is located
// below 32g, either encoding base should be zero or base should be aligned to 4G
// and shift should be zero. The simplest way to fix this for now is to force
// shift to zero for both runtime and dumptime.
// Note however that this is not a perfect solution. Ideally this whole function
// should be CDS agnostic, that would simplify it - and testing - alot. See JDK-8267141
// for details.
shift = 0;

// This must be true since at dumptime cds+ccs is 4G, at runtime it can
// only be smaller, see comment above.
@@ -23,6 +23,7 @@

/**
* @test SharedBaseAddress
* @bug 8265705
* @summary Test variety of values for SharedBaseAddress, making sure
* VM handles normal values as well as edge values w/o a crash.
* @requires vm.cds
@@ -47,6 +48,8 @@
"0xffffffffffffffff", // archive bottom wraps around 64-bit address space -- due to align_up()
"0xffffffff", // archive bottom wraps around 32-bit address space -- due to align_up()
"0x00007ffffff00000", // end of archive will go past the end of user space on linux/x64
"0x500000000", // (20g) below 32g at a 4g aligned address, but cannot be expressed with a logical
// immediate on aarch64 (0x5_0000_0000) (see JDK-8265705)
"0", // always let OS pick the base address at runtime (ASLR for CDS archive)
};

@@ -55,24 +58,38 @@

public static void main(String[] args) throws Exception {

for (String testEntry : testTable) {
String filename = "SharedBaseAddress" + testEntry + ".jsa";
System.out.println("sharedBaseAddress = " + testEntry);
CDSOptions opts = (new CDSOptions())
.setArchiveName(filename)
.addPrefix("-XX:SharedBaseAddress=" + testEntry)
.addPrefix("-Xlog:cds=debug")
.addPrefix("-Xlog:cds+reloc=debug")
.addPrefix("-Xlog:nmt=debug")
.addPrefix("-Xlog:os=debug")
.addPrefix("-XX:NativeMemoryTracking=detail");
for (int run = 0; run < 2; run ++) {
// We run twice:
// Once, where we want to increase the chance that mapping the generated archive at the designated base
// succeeds, to test Klass pointer encoding at that weird location. We do this by sizing heap + class space
// small, and by switching off compressed oops.
// On the second run, we don't do this but instead go with default parameters. This is more of a test of
// CDS' ability to recover if mapping at runtime fails.
for (String testEntry : testTable) {
String filename = "SharedBaseAddress-base" + testEntry + "-run" + run + ".jsa";
System.out.println("sharedBaseAddress = " + testEntry);
CDSOptions opts = (new CDSOptions())
.setArchiveName(filename)
.addPrefix("-XX:SharedBaseAddress=" + testEntry)
.addPrefix("-Xlog:cds=debug")
.addPrefix("-Xlog:cds+reloc=debug")
.addPrefix("-Xlog:nmt=debug")
.addPrefix("-Xlog:os=debug")
.addPrefix("-Xlog:gc+metaspace")
.addPrefix("-XX:NativeMemoryTracking=detail");

CDSTestUtils.createArchiveAndCheck(opts);
OutputAnalyzer out = CDSTestUtils.runWithArchiveAndCheck(opts);
if (testEntry.equals("0")) {
out.shouldContain("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address.")
.shouldContain("Try to map archive(s) at an alternative address")
.shouldNotMatch(failedPattern);
if (run == 0) {
opts.addPrefix("-Xmx128m")
.addPrefix("-XX:CompressedClassSpaceSize=32m")
.addPrefix("-XX:-UseCompressedOops");
}
CDSTestUtils.createArchiveAndCheck(opts);
OutputAnalyzer out = CDSTestUtils.runWithArchiveAndCheck(opts);
if (testEntry.equals("0")) {
out.shouldContain("Archive(s) were created with -XX:SharedBaseAddress=0. Always map at os-selected address.")
.shouldContain("Try to map archive(s) at an alternative address")
.shouldNotMatch(failedPattern);
}
}
}
}

0 comments on commit 3c010a7

Please sign in to comment.