JDK-8357250 : assert(shift >= 0 && shift < 4) failed: unexpected compressd klass shift!
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 25
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • CPU: aarch64
  • Submitted: 2025-05-19
  • Updated: 2025-05-20
Related Reports
Causes :  
Description
The following tests run into the assertion "assert(shift >= 0 && shift < 4) failed: unexpected compressd klass shift!" on aarch64 platforms when Compact Object Headers are enabled:
runtime/cds/appcds/aotCache/HelloAOTCache.java
runtime/cds/appcds/aotCode/AOTCodeCompressedOopsTest.java
runtime/cds/appcds/aotCode/AOTCodeFlags.java

Stack:
V  [libjvm.dylib+0x13b8e6c]  VMError::report(outputStream*, bool)+0x1b00  (macroAssembler_aarch64.cpp:5418)
V  [libjvm.dylib+0x13bc71c]  VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void const*, void const*, char const*, int, unsigned long)+0x55c
V  [libjvm.dylib+0x5bad04]  print_error_for_unit_test(char const*, char const*, char*)+0x0
V  [libjvm.dylib+0xd838fc]  MacroAssembler::decode_klass_not_null_for_aot(Register, Register)+0x3cc
V  [libjvm.dylib+0x8bcb9c]  InterpreterMacroAssembler::profile_obj_type(Register, Address const&)+0x288
V  [libjvm.dylib+0x8bdd3c]  InterpreterMacroAssembler::profile_return_type(Register, Register, Register)+0x3fc
V  [libjvm.dylib+0x12caab4]  TemplateInterpreterGenerator::generate_return_entry_for(TosState, int, unsigned long)+0x33c
...

Reproducer (tested on MacBook Pro M1):
make run-test TEST=runtime/cds/appcds/aotCache/HelloAOTCache.java JTREG="VM_OPTIONS=-XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders"

CDS archive(s) mapped at: [0x0000400000000000-0x00004000008d0000-0x00004000008d0000), size 9240576, SharedBaseAddress: 0x0000400000000000, ArchiveRelocationMode: 1.
Compressed class space mapped at: 0x0000400001000000-0x0000400041000000, reserved size: 1073741824
UseCompressedClassPointers 1, UseCompactObjectHeaders 1
Narrow klass pointer bits 22, Max shift 10
Narrow klass base: 0x0000400000000000, Narrow klass shift: 10
Encoding Range: [0x0000400000000000 - 0x0000400100000000), (4294967296 bytes)
Klass Range:    [0x0000400000004000 - 0x0000400041000000), (1090502656 bytes)
Klass ID Range:  [16 - 1064960) (1064944)
Protection zone: [0x0000400000000000 - 0x0000400000004000), (16384 bytes)

Comments
We should use `CompressedKlassPointers::max_shift()` in assert.
19-05-2025