< prev index next >

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Print this page
@@ -2339,14 +2339,16 @@
    // 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());
  
    if (LockingMode != LM_LIGHTWEIGHT) {

@@ -2354,11 +2356,11 @@
      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);

@@ -2424,11 +2426,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);
< prev index next >