< prev index next >

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Print this page
*** 2619,24 ***
    // The object's monitor m is unlocked iff m->owner is null,
    // otherwise m->owner may contain a thread or a stack address.
  
    // Try to CAS m->owner from null to current thread.
    addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value);
    cmpxchgd(/*flag=*/flag,
             /*current_value=*/current_header,
             /*compare_value=*/(intptr_t)0,
!            /*exchange_value=*/R16_thread,
             /*where=*/temp,
             MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
             MacroAssembler::cmpxchgx_hint_acquire_lock());
  
    // Store a non-null value into the box.
    std(box, BasicLock::displaced_header_offset_in_bytes(), box);
    beq(flag, success);
  
    // Check for recursive locking.
!   cmpd(flag, current_header, R16_thread);
    bne(flag, failure);
  
    // Current thread already owns the lock. Just increment recursions.
    Register recursions = displaced_header;
    ld(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);
--- 2619,26 ---
    // The object's monitor m is unlocked iff m->owner is null,
    // otherwise m->owner may contain a thread or a stack address.
  
    // Try to CAS m->owner from null to current thread.
    addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value);
+   Register thread_id = displaced_header;
+   ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
    cmpxchgd(/*flag=*/flag,
             /*current_value=*/current_header,
             /*compare_value=*/(intptr_t)0,
!            /*exchange_value=*/thread_id,
             /*where=*/temp,
             MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
             MacroAssembler::cmpxchgx_hint_acquire_lock());
  
    // Store a non-null value into the box.
    std(box, BasicLock::displaced_header_offset_in_bytes(), box);
    beq(flag, success);
  
    // Check for recursive locking.
!   cmpd(flag, current_header, thread_id);
    bne(flag, failure);
  
    // Current thread already owns the lock. Just increment recursions.
    Register recursions = displaced_header;
    ld(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);

*** 2699,11 ***
    addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
    ld(temp,             in_bytes(ObjectMonitor::owner_offset()), current_header);
  
    // In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
    // This is handled like owner thread mismatches: We take the slow path.
!   cmpd(flag, temp, R16_thread);
    bne(flag, failure);
  
    ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
  
    addic_(displaced_header, displaced_header, -1);
--- 2701,13 ---
    addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
    ld(temp,             in_bytes(ObjectMonitor::owner_offset()), current_header);
  
    // In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
    // This is handled like owner thread mismatches: We take the slow path.
!   Register thread_id = displaced_header;
+   ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
+   cmpd(flag, temp, thread_id);
    bne(flag, failure);
  
    ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
  
    addic_(displaced_header, displaced_header, -1);

*** 2870,22 ***
  
        // Compute owner address.
        addi(owner_addr, monitor, in_bytes(ObjectMonitor::owner_offset()));
      }
  
!     // CAS owner (null => current thread).
      cmpxchgd(/*flag=*/CCR0,
              /*current_value=*/t,
              /*compare_value=*/(intptr_t)0,
!             /*exchange_value=*/R16_thread,
              /*where=*/owner_addr,
              MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
              MacroAssembler::cmpxchgx_hint_acquire_lock());
      beq(CCR0, monitor_locked);
  
      // Check if recursive.
!     cmpd(CCR0, t, R16_thread);
      bne(CCR0, slow_path);
  
      // Recursive.
      if (!UseObjectMonitorTable) {
        assert_different_registers(tmp1, owner_addr);
--- 2874,24 ---
  
        // Compute owner address.
        addi(owner_addr, monitor, in_bytes(ObjectMonitor::owner_offset()));
      }
  
!     // CAS owner (null => current thread id).
+     Register thread_id = tmp1;
+     ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
      cmpxchgd(/*flag=*/CCR0,
              /*current_value=*/t,
              /*compare_value=*/(intptr_t)0,
!             /*exchange_value=*/thread_id,
              /*where=*/owner_addr,
              MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
              MacroAssembler::cmpxchgx_hint_acquire_lock());
      beq(CCR0, monitor_locked);
  
      // Check if recursive.
!     cmpd(CCR0, t, thread_id);
      bne(CCR0, slow_path);
  
      // Recursive.
      if (!UseObjectMonitorTable) {
        assert_different_registers(tmp1, owner_addr);
< prev index next >