hotspot/src/cpu/aarch64/vm/aarch64.ad
changeset 36562 4d1e93624d6a
parent 36554 a7eb9ee4680c
child 36565 8e38f7594806
equal deleted inserted replaced
36561:b18243f4d955 36562:4d1e93624d6a
  4130 
  4130 
  4131   enc_class aarch64_enc_cmpxchg(memory mem, iRegLNoSp oldval, iRegLNoSp newval) %{
  4131   enc_class aarch64_enc_cmpxchg(memory mem, iRegLNoSp oldval, iRegLNoSp newval) %{
  4132     MacroAssembler _masm(&cbuf);
  4132     MacroAssembler _masm(&cbuf);
  4133     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4133     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4134     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4134     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4135                &Assembler::ldxr, &MacroAssembler::cmp, &Assembler::stlxr);
  4135                Assembler::xword, /*acquire*/ false, /*release*/ true);
  4136   %}
  4136   %}
  4137 
  4137 
  4138   enc_class aarch64_enc_cmpxchgw(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
  4138   enc_class aarch64_enc_cmpxchgw(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
  4139     MacroAssembler _masm(&cbuf);
  4139     MacroAssembler _masm(&cbuf);
  4140     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4140     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4141     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4141     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4142                &Assembler::ldxrw, &MacroAssembler::cmpw, &Assembler::stlxrw);
  4142                Assembler::word, /*acquire*/ false, /*release*/ true);
  4143   %}
  4143   %}
  4144 
  4144 
  4145 
  4145 
  4146   // The only difference between aarch64_enc_cmpxchg and
  4146   // The only difference between aarch64_enc_cmpxchg and
  4147   // aarch64_enc_cmpxchg_acq is that we use load-acquire in the
  4147   // aarch64_enc_cmpxchg_acq is that we use load-acquire in the
  4149   // lock.
  4149   // lock.
  4150   enc_class aarch64_enc_cmpxchg_acq(memory mem, iRegLNoSp oldval, iRegLNoSp newval) %{
  4150   enc_class aarch64_enc_cmpxchg_acq(memory mem, iRegLNoSp oldval, iRegLNoSp newval) %{
  4151     MacroAssembler _masm(&cbuf);
  4151     MacroAssembler _masm(&cbuf);
  4152     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4152     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4153     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4153     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4154                &Assembler::ldaxr, &MacroAssembler::cmp, &Assembler::stlxr);
  4154                Assembler::xword, /*acquire*/ true, /*release*/ true);
  4155   %}
  4155   %}
  4156 
  4156 
  4157   enc_class aarch64_enc_cmpxchgw_acq(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
  4157   enc_class aarch64_enc_cmpxchgw_acq(memory mem, iRegINoSp oldval, iRegINoSp newval) %{
  4158     MacroAssembler _masm(&cbuf);
  4158     MacroAssembler _masm(&cbuf);
  4159     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4159     guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding");
  4160     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4160     __ cmpxchg($mem$$base$$Register, $oldval$$Register, $newval$$Register,
  4161                &Assembler::ldaxrw, &MacroAssembler::cmpw, &Assembler::stlxrw);
  4161                Assembler::word, /*acquire*/ true, /*release*/ true);
  4162   %}
  4162   %}
  4163 
  4163 
  4164 
  4164 
  4165   // auxiliary used for CompareAndSwapX to set result register
  4165   // auxiliary used for CompareAndSwapX to set result register
  4166   enc_class aarch64_enc_cset_eq(iRegINoSp res) %{
  4166   enc_class aarch64_enc_cset_eq(iRegINoSp res) %{
  4674     // Initialize the box. (Must happen before we update the object mark!)
  4674     // Initialize the box. (Must happen before we update the object mark!)
  4675     __ str(disp_hdr, Address(box, BasicLock::displaced_header_offset_in_bytes()));
  4675     __ str(disp_hdr, Address(box, BasicLock::displaced_header_offset_in_bytes()));
  4676 
  4676 
  4677     // Compare object markOop with mark and if equal exchange scratch1
  4677     // Compare object markOop with mark and if equal exchange scratch1
  4678     // with object markOop.
  4678     // with object markOop.
  4679     {
  4679     if (UseLSE) {
       
  4680       __ mov(tmp, disp_hdr);
       
  4681       __ casal(Assembler::xword, tmp, box, oop);
       
  4682       __ cmp(tmp, disp_hdr);
       
  4683       __ br(Assembler::EQ, cont);
       
  4684     } else {
  4680       Label retry_load;
  4685       Label retry_load;
  4681       __ bind(retry_load);
  4686       __ bind(retry_load);
  4682       __ ldaxr(tmp, oop);
  4687       __ ldaxr(tmp, oop);
  4683       __ cmp(tmp, disp_hdr);
  4688       __ cmp(tmp, disp_hdr);
  4684       __ br(Assembler::NE, cas_failed);
  4689       __ br(Assembler::NE, cas_failed);
  4724       //
  4729       //
  4725       // Try to CAS m->owner from NULL to current thread.
  4730       // Try to CAS m->owner from NULL to current thread.
  4726       __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value));
  4731       __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value));
  4727       __ mov(disp_hdr, zr);
  4732       __ mov(disp_hdr, zr);
  4728 
  4733 
  4729       {
  4734       if (UseLSE) {
       
  4735         __ mov(rscratch1, disp_hdr);
       
  4736         __ casal(Assembler::xword, rscratch1, rthread, tmp);
       
  4737         __ cmp(rscratch1, disp_hdr);
       
  4738       } else {
  4730         Label retry_load, fail;
  4739         Label retry_load, fail;
  4731         __ bind(retry_load);
  4740         __ bind(retry_load);
  4732         __ ldaxr(rscratch1, tmp);
  4741         __ ldaxr(rscratch1, tmp);
  4733         __ cmp(disp_hdr, rscratch1);
  4742         __ cmp(disp_hdr, rscratch1);
  4734         __ br(Assembler::NE, fail);
  4743         __ br(Assembler::NE, fail);
  4813 
  4822 
  4814     // Check if it is still a light weight lock, this is is true if we
  4823     // Check if it is still a light weight lock, this is is true if we
  4815     // see the stack address of the basicLock in the markOop of the
  4824     // see the stack address of the basicLock in the markOop of the
  4816     // object.
  4825     // object.
  4817 
  4826 
  4818       {
  4827       if (UseLSE) {
       
  4828         __ mov(tmp, box);
       
  4829         __ casl(Assembler::xword, tmp, disp_hdr, oop);
       
  4830         __ cmp(tmp, box);
       
  4831       } else {
  4819         Label retry_load;
  4832         Label retry_load;
  4820         __ bind(retry_load);
  4833         __ bind(retry_load);
  4821         __ ldxr(tmp, oop);
  4834         __ ldxr(tmp, oop);
  4822         __ cmp(box, tmp);
  4835         __ cmp(box, tmp);
  4823         __ br(Assembler::NE, cas_failed);
  4836         __ br(Assembler::NE, cas_failed);