< prev index next >

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Print this page
@@ -2342,24 +2342,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=*/R16_thread,
+            /*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, R16_thread);
+   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);

@@ -2422,11 +2424,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.
-   cmpd(flag, temp, R16_thread);
+   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);

@@ -2526,22 +2530,24 @@
      const Register owner_addr = tmp2;
  
      // Compute owner address.
      addi(owner_addr, tagged_monitor, in_bytes(ObjectMonitor::owner_offset()) - monitor_tag);
  
-     // CAS owner (null => current thread).
+     // CAS owner (null => current thread id).
+     Register thread_id = tmp1;
+     ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
      cmpxchgd(/*flag=*/flag,
              /*current_value=*/t,
              /*compare_value=*/(intptr_t)0,
-             /*exchange_value=*/R16_thread,
+             /*exchange_value=*/thread_id,
              /*where=*/owner_addr,
              MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
              MacroAssembler::cmpxchgx_hint_acquire_lock());
      beq(flag, locked);
  
      // Check if recursive.
-     cmpd(flag, t, R16_thread);
+     cmpd(flag, t, thread_id);
      bne(flag, slow_path);
  
      // Recursive.
      ld(tmp1, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), owner_addr);
      addi(tmp1, tmp1, 1);

@@ -2692,11 +2698,13 @@
      beq(flag, release_);
  
      // The owner may be anonymous and we removed the last obj entry in
      // the lock-stack. This loses the information about the owner.
      // Write the thread to the owner field so the runtime knows the owner.
-     std(R16_thread, in_bytes(ObjectMonitor::owner_offset()), monitor);
+     Register thread_id = tmp2;
+     ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
+     std(thread_id, in_bytes(ObjectMonitor::owner_offset()), monitor);
      b(slow_path);
  
      bind(release_);
      // Set owner to null.
      release();
< prev index next >