Question about hack in templateTable_x86.cpp

Sergey Kuksenko sergey.kuksenko at oracle.com
Thu Nov 5 18:09:52 UTC 2020


Here is the code:

void TemplateTable::if_acmp(Condition cc) {
   transition(atos,vtos);
   // assume branch is more often taken than not (loops use backward 
branches) Label taken, not_taken;
   __ pop_ptr(rdx);

   __ profile_acmp(rbx, rdx, rax, rcx);

   if (EnableValhalla) {
       __ cmpoop(rdx, rax);
       __ jcc(Assembler::equal, (cc ==equal) ? taken : not_taken);

     // 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?




More information about the valhalla-dev mailing list