Question about hack in templateTable_x86.cpp

John Rose john.r.rose at oracle.com
Thu Nov 5 23:09:00 UTC 2020


On Nov 5, 2020, at 10:09 AM, Sergey Kuksenko <sergey.kuksenko at oracle.com> wrote:
> 
>    // might be substitutable, test if either rax or rdx is null __ testptr(rdx, rax);
>    __ jcc(Assembler::zero, (cc ==equal) ? not_taken : taken);
> 
> The last "test" does simultaneous check either one of oops is null. I really like that hack, but I am not sure.
> 
> What if we've got two non-null pointers which just have different bits? That hack may work only if we know that ANY two pointers have some ones at the same bit position. Do we have such assurance?

Not in general.  If you look at verify_oop_mask and verify_oop_bits,
you might be able to reassure yourself that this works out OK.
In particular, we need both values to be non-zero.

The macro here should do this, and fall back to reliable code (such
as a CC-testing bitwise OR) if the reassurance fails, or at least fail
to boot the JVM.

See Universe::calculate_verify_data for where these bits come from.

— John


More information about the valhalla-dev mailing list