Condition code not set after CAS on aarch64

Andrew Haley aph at redhat.com
Wed Nov 16 16:09:30 UTC 2016


On 16/11/16 15:59, Roman Kennke wrote:
> Yes. And we set that register in cmpxchg_oop_shenandoah(). The
> condition code might be foobar after the loop.

  enc_class aarch64_enc_cmpxchg_oop_shenandoah(memory mem, iRegLNoSp oldval, iRegLNoSp newval, iRegP tmp) %{
    MacroAssembler _masm(&cbuf);
    guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
    __ cmpxchg_oop_shenandoah($mem$$base$$Register, $oldval$$Register, $newval$$Register,
                              /*acquire*/ false, /*release*/ true, $tmp$$Register);
  %}

void MacroAssembler::cmpxchg_oop_shenandoah(Register addr, Register expected,
                                            Register new_val,
                                            bool acquire, bool release,
                                            Register tmp1, Register tmp2, Register tmp3) {
  assert(UseShenandoahGC, "only for shenandoah");
  Label retry, fail, success;

  dmb(LD); // Not required but makes it more likely updates to the
           // brooks pointer are seen without a trip through the loop
  mov(tmp1, expected);
  oopDesc::bs()->interpreter_read_barrier(this, tmp1);

  bind(retry);
  load_exclusive(tmp2, addr, xword, acquire);
  cmp(tmp2, expected); // compare with expected
  ccmp(tmp2, tmp1, 0b0100, NE); // and with [expected-8]
  br(NE, fail);

  store_exclusive(tmp3, new_val, addr, xword, release);
  cbnz(tmp3, retry);
  b(success);

  bind(fail);

  if (!acquire) dmb(LD); // Required: updates to the brooks pointer
                         // could be missed otherwise

  // reload in case the object moved in the meantime
  oopDesc::bs()->interpreter_read_barrier(this, tmp1);
  mov(tmp3, tmp2);
  oopDesc::bs()->interpreter_read_barrier(this, tmp3);
  cmp(tmp3, tmp1); // compare it with dereferenced expected val
  mov(tmp1, tmp2);
  br(Assembler::EQ, retry);
  bind(success);
}

Where?

Andrew.



More information about the shenandoah-dev mailing list