! int R8; oop R9; // R9 is 64 bits ! oop R10 = R9[R8]; // R10 is 32 bits ! load compressed ptr from wide base ptr: movl R10, [R9 + R8<<2 + 16] ! klassOop R11 = R10._klass; // R11 is 32 bits ! void* const R12 = GetHeapBase(); ! load compressed klass ptr from compressed base ptr: movl R11, [R12 + R10<<3 + 8]
Here is an example of a sparc instruction sequence which decodes a compressed oop (which might be null):
! java.lang.Thread::getThreadGroup@1 (line 1072) ! L1 = L7.group ld [ %l7 + 0x44 ], %l1 ! L3 = decode(L1) cmp %l1, 0 sllx %l1, 3, %l3 brnz,a %l3, .+8 add %l3, %g6, %l3 ! %g6 is constant heap base
(Annotated output is from the disassembly plugin.)
A 32-bit zero value decodes into a 64-bit native null value. This requires an awkward special path in the decoding logic, to the point where it is profitable to statically note which compressed oops (like klass fields) are guaranteed never to be null, and use a simpler version of the full decode or encode operation.