acmp/cas retries and null arguments

Aleksey Shipilev shade at redhat.com
Thu Sep 22 17:04:53 UTC 2016


On 09/14/2016 06:39 PM, Aleksey Shipilev wrote:
> I'll take a look 

Was slacking off while new CAS code breeds in my mind.

acmp(%a, %b):
  cmp %a, %b
  je done

    test %a, %a
    je <over1> // the idea was to jump to "done"
    shenandoah_rb (%a)
    over1:

    test %b, %b
    je <over2> // the idea was to jump to "done"
    shenandoah_rb (%b)
    over2:

    cmp %a, %b;
 done:

So, I tried several things, and none of them work better than our
current code, at least in C1, which looks optimal.

The idea was to make the quicker exit from null-check tests prior to RB.
This does not work good at least on x86, because you have to have the
status code from the cmp, which is in *reverse*. That is, if $op is
null, then test $op, $op sets ZF=1; but, we need to return ZF=0 from the
barrier on all paths!

We can jump to cmp to get proper flags. This makes the optimization
futile: the whole reason was to not do the second cmp. There is no
explicit way to set ZF, and all "alternatives" I tried still require
additional branches to get back on track.

Oh well. Negative result is still a result:
 https://upmic.files.wordpress.com/2013/06/negative-data.png

Thanks,
-Aleksey





More information about the shenandoah-dev mailing list