< prev index next >

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Print this page
*** 664,13 ***
--- 664,15 ---
  //      rscratch1, rscratch2 (scratch regs)
  void InterpreterMacroAssembler::lock_object(Register lock_reg)
  {
    assert(lock_reg == c_rarg1, "The argument is only for looks. It must be c_rarg1");
    if (LockingMode == LM_MONITOR) {
+     push_cont_fastpath();
      call_VM(noreg,
              CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
              lock_reg);
+     pop_cont_fastpath();
    } else {
      Label count, done;
  
      const Register swap_reg = r0;
      const Register tmp = c_rarg2;

*** 695,11 ***
        br(Assembler::NE, slow_case);
      }
  
      if (LockingMode == LM_LIGHTWEIGHT) {
        lightweight_lock(obj_reg, tmp, tmp2, tmp3, slow_case);
!       b(count);
      } else if (LockingMode == LM_LEGACY) {
        // Load (object->mark() | 1) into swap_reg
        ldr(rscratch1, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
        orr(swap_reg, rscratch1, 1);
  
--- 697,11 ---
        br(Assembler::NE, slow_case);
      }
  
      if (LockingMode == LM_LIGHTWEIGHT) {
        lightweight_lock(obj_reg, tmp, tmp2, tmp3, slow_case);
!       b(done);
      } else if (LockingMode == LM_LEGACY) {
        // Load (object->mark() | 1) into swap_reg
        ldr(rscratch1, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
        orr(swap_reg, rscratch1, 1);
  

*** 745,29 ***
        sub(swap_reg, swap_reg, rscratch1);
        ands(swap_reg, swap_reg, (uint64_t)(7 - (int)os::vm_page_size()));
  
        // Save the test result, for recursive case, the result is zero
        str(swap_reg, Address(lock_reg, mark_offset));
!       br(Assembler::EQ, count);
      }
      bind(slow_case);
  
      // Call the runtime routine for slow case
      if (LockingMode == LM_LIGHTWEIGHT) {
        call_VM(noreg,
                CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter_obj),
                obj_reg);
      } else {
        call_VM(noreg,
                CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
                lock_reg);
      }
!     b(done);
- 
-     bind(count);
-     increment(Address(rthread, JavaThread::held_monitor_count_offset()));
- 
      bind(done);
    }
  }
  
  
--- 747,32 ---
        sub(swap_reg, swap_reg, rscratch1);
        ands(swap_reg, swap_reg, (uint64_t)(7 - (int)os::vm_page_size()));
  
        // Save the test result, for recursive case, the result is zero
        str(swap_reg, Address(lock_reg, mark_offset));
!       br(Assembler::NE, slow_case);
+       b(done);
      }
+ 
+     bind(count);
+     inc_held_monitor_count();
+     b(done);
+ 
      bind(slow_case);
  
      // Call the runtime routine for slow case
+     push_cont_fastpath();
      if (LockingMode == LM_LIGHTWEIGHT) {
        call_VM(noreg,
                CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter_obj),
                obj_reg);
      } else {
        call_VM(noreg,
                CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter),
                lock_reg);
      }
!     pop_cont_fastpath();
      bind(done);
    }
  }
  
  

*** 808,34 ***
      ldr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
  
      // Free entry
      str(zr, Address(lock_reg, BasicObjectLock::obj_offset()));
  
      if (LockingMode == LM_LIGHTWEIGHT) {
-       Label slow_case;
        lightweight_unlock(obj_reg, header_reg, swap_reg, tmp_reg, slow_case);
!       b(count);
-       bind(slow_case);
      } else if (LockingMode == LM_LEGACY) {
        // Load the old header from BasicLock structure
        ldr(header_reg, Address(swap_reg,
                                BasicLock::displaced_header_offset_in_bytes()));
  
        // Test for recursion
!       cbz(header_reg, count);
  
        // Atomic swap back the old header
!       cmpxchg_obj_header(swap_reg, header_reg, obj_reg, rscratch1, count, /*fallthrough*/nullptr);
      }
-     // Call the runtime routine for slow case.
-     str(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset())); // restore obj
-     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
-     b(done);
  
      bind(count);
!     decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
  
      bind(done);
      restore_bcp();
    }
  }
  
--- 813,34 ---
      ldr(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset()));
  
      // Free entry
      str(zr, Address(lock_reg, BasicObjectLock::obj_offset()));
  
+     Label slow_case;
      if (LockingMode == LM_LIGHTWEIGHT) {
        lightweight_unlock(obj_reg, header_reg, swap_reg, tmp_reg, slow_case);
!       b(done);
      } else if (LockingMode == LM_LEGACY) {
        // Load the old header from BasicLock structure
        ldr(header_reg, Address(swap_reg,
                                BasicLock::displaced_header_offset_in_bytes()));
  
        // Test for recursion
!       cbz(header_reg, done);
  
        // Atomic swap back the old header
!       cmpxchg_obj_header(swap_reg, header_reg, obj_reg, rscratch1, count, &slow_case);
      }
  
      bind(count);
!     dec_held_monitor_count();
+     b(done);
  
+     bind(slow_case);
+     // Call the runtime routine for slow case.
+     str(obj_reg, Address(lock_reg, BasicObjectLock::obj_offset())); // restore obj
+     call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), lock_reg);
      bind(done);
      restore_bcp();
    }
  }
  
< prev index next >