From 62cc4efba20637755ffb3cea8ccabe2b370125ca Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Fri, 24 Jul 2026 08:11:59 +0000 Subject: [PATCH] 8388712: [s390x, ppc] runtime/CompressedOops/CompressedClassPointersEncodingScheme.java fails since JDK-8387652 Reviewed-by: amitkumar, mbaesken --- src/hotspot/share/oops/compressedKlass.cpp | 7 ++----- ...CompressedClassPointersEncodingScheme.java | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/hotspot/share/oops/compressedKlass.cpp b/src/hotspot/share/oops/compressedKlass.cpp index 134f5a93365..4c79a858031 100644 --- a/src/hotspot/share/oops/compressedKlass.cpp +++ b/src/hotspot/share/oops/compressedKlass.cpp @@ -241,12 +241,9 @@ void CompressedKlassPointers::initialize(address addr, size_t len) { // a cacheline size. _base = addr; + const int log2_len_to_cover = log2i_ceil(len); const int log_cacheline = exact_log2(DEFAULT_CACHE_LINE_SIZE); - int s = max_shift(); - while (s > log_cacheline && ((size_t)nth_bit(narrow_klass_pointer_bits() + s - 1) > len)) { - s--; - } - _shift = s; + _shift = MAX2(log_cacheline, log2_len_to_cover - narrow_klass_pointer_bits()); } else { diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java index f4ef0800a73..a8c03e259fc 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassPointersEncodingScheme.java @@ -36,7 +36,6 @@ import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; -import jtreg.SkippedException; import java.io.IOException; @@ -102,14 +101,18 @@ public class CompressedClassPointersEncodingScheme { // Compact Object Header Mode: // We expect the VM to chose the smallest possible shift value needed to cover the encoding range. // We expect the encoding Base to start at the class space start - but to enforce that, - // we choose unsuited to even shift-extended zero-based mode. + // we choose a base unsuited to even shift-extended zero-based mode. forceAddress = 32 * G; + int minShift = 6; + if (Platform.isPPC()) minShift = 7; + if (Platform.isS390x()) minShift = 8; - test(forceAddress, true, 128 * M, forceAddress, 6); - test(forceAddress, true, 256 * M, forceAddress, 7); - test(forceAddress, true, 512 * M, forceAddress, 8); - test(forceAddress, true, G, forceAddress, 9); - test(forceAddress, true, 3 * G, forceAddress, 10); + test(forceAddress, true, 128 * M, forceAddress, Math.max(minShift, 5)); + test(forceAddress, true, 256 * M, forceAddress, Math.max(minShift, 6)); + test(forceAddress, true, 512 * M, forceAddress, Math.max(minShift, 7)); + test(forceAddress, true, G, forceAddress, Math.max(minShift, 8)); + test(forceAddress, true, 2 * G, forceAddress, Math.max(minShift, 9)); + test(forceAddress, true, 4 * G, forceAddress, 10); // Test a "crooked" base address: // - just aligned enough to pass metaspace reserve alignment test of 16MB. @@ -118,8 +121,8 @@ public class CompressedClassPointersEncodingScheme { // - small enough to not cause test errors on small devices (e.g. arm64 39bit address space) // - large enough to not end up with zero-based encoding forceAddress = 0x0000000d55000000L; - test(forceAddress, true, 32 * M, forceAddress, 6); - test(forceAddress, false, 32 * M, forceAddress, 0); + test(forceAddress, true, 4 * G, forceAddress, 10); + test(forceAddress, false, 4 * G, forceAddress, 0); } }