< prev index next >

src/hotspot/cpu/aarch64/aarch64.ad

Print this page
@@ -3768,40 +3768,19 @@
  
      // Check for existing monitor
      __ tbnz(disp_hdr, exact_log2(markWord::monitor_value), object_has_monitor);
  
      if (!UseHeavyMonitors) {
-       // Set tmp to be (markWord of object | UNLOCK_VALUE).
-       __ orr(tmp, disp_hdr, markWord::unlocked_value);
- 
-       // Initialize the box. (Must happen before we update the object mark!)
-       __ str(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
- 
-       // Compare object markWord with an unlocked value (tmp) and if
-       // equal exchange the stack address of our box with object markWord.
-       // On failure disp_hdr contains the possibly locked markWord.
-       __ cmpxchg(oop, tmp, box, Assembler::xword, /*acquire*/ true,
-                  /*release*/ true, /*weak*/ false, disp_hdr);
-       __ br(Assembler::EQ, cont);
- 
-       assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
- 
-       // If the compare-and-exchange succeeded, then we found an unlocked
-       // object, will have now locked it will continue at label cont
- 
-       // Check if the owner is self by comparing the value in the
-       // markWord of object (disp_hdr) with the stack pointer.
-       __ mov(rscratch1, sp);
-       __ sub(disp_hdr, disp_hdr, rscratch1);
-       __ mov(tmp, (address) (~(os::vm_page_size()-1) | markWord::lock_mask_in_place));
-       // If condition is true we are cont and hence we can store 0 as the
-       // displaced header in the box, which indicates that it is a recursive lock.
-       __ ands(tmp/*==0?*/, disp_hdr, tmp);   // Sets flags for result
-       __ str(tmp/*==0, perhaps*/, Address(box, BasicLock::displaced_header_offset_in_bytes()));
-     } else {
-       __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
+       Label slow;
+       __ fast_lock(oop, disp_hdr, box, tmp, rscratch1, slow);
+ 
+       // Indicate success at cont.
+       __ cmp(oop, oop);
+       __ b(cont);
+       __ bind(slow);
      }
+     __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
      __ b(cont);
  
      // Handle existing monitor.
      __ bind(object_has_monitor);
  

@@ -3811,17 +3790,10 @@
      // Try to CAS m->owner from NULL to current thread.
      __ add(tmp, disp_hdr, (ObjectMonitor::owner_offset_in_bytes()-markWord::monitor_value));
      __ cmpxchg(tmp, zr, rthread, Assembler::xword, /*acquire*/ true,
                 /*release*/ true, /*weak*/ false, rscratch1); // Sets flags for result
  
-     // Store a non-null value into the box to avoid looking like a re-entrant
-     // lock. The fast-path monitor unlock code checks for
-     // markWord::monitor_value so use markWord::unused_mark which has the
-     // relevant bit set, and also matches ObjectSynchronizer::enter.
-     __ mov(tmp, (address)markWord::unused_mark().value());
-     __ str(tmp, Address(box, BasicLock::displaced_header_offset_in_bytes()));
- 
      __ br(Assembler::EQ, cont); // CAS success means locking succeeded
  
      __ cmp(rscratch1, rthread);
      __ br(Assembler::NE, cont); // Check for recursive locking
  

@@ -3849,42 +3821,47 @@
      Label object_has_monitor;
      Label no_count;
  
      assert_different_registers(oop, box, tmp, disp_hdr);
  
-     if (!UseHeavyMonitors) {
-       // Find the lock address and load the displaced header from the stack.
-       __ ldr(disp_hdr, Address(box, BasicLock::displaced_header_offset_in_bytes()));
- 
-       // If the displaced header is 0, we have a recursive unlock.
-       __ cmp(disp_hdr, zr);
-       __ br(Assembler::EQ, cont);
-     }
- 
      // Handle existing monitor.
      __ ldr(tmp, Address(oop, oopDesc::mark_offset_in_bytes()));
-     __ tbnz(disp_hdr, exact_log2(markWord::monitor_value), object_has_monitor);
+ 
+     assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  
      if (!UseHeavyMonitors) {
-       // Check if it is still a light weight lock, this is is true if we
-       // see the stack address of the basicLock in the markWord of the
-       // object.
+       Label slow;
+       __ tbnz(tmp, exact_log2(markWord::monitor_value), object_has_monitor);
  
-       __ cmpxchg(oop, box, disp_hdr, Assembler::xword, /*acquire*/ false,
-                  /*release*/ true, /*weak*/ false, tmp);
-     } else {
-       __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
+       __ fast_unlock(oop, tmp, box, disp_hdr, slow);
+ 
+       // Indicate success at cont.
+       __ cmp(oop, oop);
+       __ b(cont);
+ 
+       __ bind(slow);
      }
+     __ tst(oop, oop); // Set NE to indicate 'failure' -> take slow-path. We know that oop != 0.
      __ b(cont);
  
-     assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
- 
      // Handle existing monitor.
      __ bind(object_has_monitor);
      STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
      __ add(tmp, tmp, -(int)markWord::monitor_value); // monitor
-     __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
+ 
+     // If the owner is anonymous, we need to fix it -- in the slow-path.
+     {
+       Label L;
+       __ ldr(disp_hdr, Address(tmp, ObjectMonitor::owner_offset_in_bytes()));
+       __ cmp(disp_hdr, (unsigned char)(intptr_t) ANONYMOUS_OWNER);
+       __ br(Assembler::NE, L);
+       __ tst(oop, oop); // Indicate failure at cont -- dive into slow-path.
+       __ b(cont);
+       __ bind(L);
+     }
+ 
+    __ ldr(disp_hdr, Address(tmp, ObjectMonitor::recursions_offset_in_bytes()));
  
      Label notRecursive;
      __ cbz(disp_hdr, notRecursive);
  
      // Recursive lock

@@ -7167,21 +7144,24 @@
  
    ins_pipe(iload_reg_mem);
  %}
  
  // Load Narrow Klass Pointer
- instruct loadNKlass(iRegNNoSp dst, memory4 mem)
+ instruct loadNKlass(iRegNNoSp dst, memory4 mem, rFlagsReg cr)
  %{
    match(Set dst (LoadNKlass mem));
+   effect(TEMP_DEF dst, KILL cr);
    predicate(!needs_acquiring_load(n));
  
    ins_cost(4 * INSN_COST);
    format %{ "ldrw  $dst, $mem\t# compressed class ptr" %}
- 
-   ins_encode(aarch64_enc_ldrw(dst, mem));
- 
-   ins_pipe(iload_reg_mem);
+   ins_encode %{
+     assert($mem$$disp == oopDesc::klass_offset_in_bytes(), "expect correct offset");
+     assert($mem$$index$$Register == noreg, "expect no index");
+     __ load_nklass($dst$$Register, $mem$$base$$Register);
+   %}
+   ins_pipe(pipe_slow);
  %}
  
  // Load Float
  instruct loadF(vRegF dst, memory4 mem)
  %{

@@ -16126,12 +16106,12 @@
  // ============================================================================
  // inlined locking and unlocking
  
  instruct cmpFastLock(rFlagsReg cr, iRegP object, iRegP box, iRegPNoSp tmp, iRegPNoSp tmp2)
  %{
-   match(Set cr (FastLock object box));
-   effect(TEMP tmp, TEMP tmp2);
+   match(Set cr (FastLock object));
+   effect(TEMP tmp, TEMP tmp2, TEMP box);
  
    // TODO
    // identify correct cost
    ins_cost(5 * INSN_COST);
    format %{ "fastlock $object,$box\t! kills $tmp,$tmp2" %}

@@ -16141,12 +16121,12 @@
    ins_pipe(pipe_serial);
  %}
  
  instruct cmpFastUnlock(rFlagsReg cr, iRegP object, iRegP box, iRegPNoSp tmp, iRegPNoSp tmp2)
  %{
-   match(Set cr (FastUnlock object box));
-   effect(TEMP tmp, TEMP tmp2);
+   match(Set cr (FastUnlock object));
+   effect(TEMP box, TEMP tmp, TEMP tmp2);
  
    ins_cost(5 * INSN_COST);
    format %{ "fastunlock $object,$box\t! kills $tmp, $tmp2" %}
  
    ins_encode(aarch64_enc_fast_unlock(object, box, tmp, tmp2));
< prev index next >