< prev index next >

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Print this page

2324     std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box);
2325 
2326     if (flag != CCR0) {
2327       mcrf(flag, CCR0);
2328     }
2329     beq(CCR0, success);
2330     b(failure);
2331   } else {
2332     assert(LockingMode == LM_LIGHTWEIGHT, "must be");
2333     lightweight_lock(oop, displaced_header, temp, failure);
2334     b(success);
2335   }
2336 
2337   // Handle existing monitor.
2338   bind(object_has_monitor);
2339   // The object's monitor m is unlocked iff m->owner is null,
2340   // otherwise m->owner may contain a thread or a stack address.
2341 
2342   // Try to CAS m->owner from null to current thread.
2343   addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value);


2344   cmpxchgd(/*flag=*/flag,
2345            /*current_value=*/current_header,
2346            /*compare_value=*/(intptr_t)0,
2347            /*exchange_value=*/R16_thread,
2348            /*where=*/temp,
2349            MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
2350            MacroAssembler::cmpxchgx_hint_acquire_lock());
2351 
2352   if (LockingMode != LM_LIGHTWEIGHT) {
2353     // Store a non-null value into the box.
2354     std(box, BasicLock::displaced_header_offset_in_bytes(), box);
2355   }
2356   beq(flag, success);
2357 
2358   // Check for recursive locking.
2359   cmpd(flag, current_header, R16_thread);
2360   bne(flag, failure);
2361 
2362   // Current thread already owns the lock. Just increment recursions.
2363   Register recursions = displaced_header;
2364   ld(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);
2365   addi(recursions, recursions, 1);
2366   std(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);
2367 
2368   // flag == EQ indicates success, increment held monitor count
2369   // flag == NE indicates failure
2370   bind(success);
2371   inc_held_monitor_count(temp);
2372   bind(failure);
2373 }
2374 
2375 void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box,
2376                                                  Register temp, Register displaced_header, Register current_header) {
2377   assert_different_registers(oop, box, temp, displaced_header, current_header);
2378   assert(LockingMode != LM_LIGHTWEIGHT || flag == CCR0, "bad condition register");
2379   Label success, failure, object_has_monitor, notRecursive;

2409              MacroAssembler::MemBarRel,
2410              MacroAssembler::cmpxchgx_hint_release_lock(),
2411              noreg,
2412              &failure);
2413     assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
2414     b(success);
2415   } else {
2416     assert(LockingMode == LM_LIGHTWEIGHT, "must be");
2417     lightweight_unlock(oop, current_header, failure);
2418     b(success);
2419   }
2420 
2421   // Handle existing monitor.
2422   bind(object_has_monitor);
2423   STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
2424   addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
2425   ld(temp,             in_bytes(ObjectMonitor::owner_offset()), current_header);
2426 
2427   // In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
2428   // This is handled like owner thread mismatches: We take the slow path.
2429   cmpd(flag, temp, R16_thread);


2430   bne(flag, failure);
2431 
2432   ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
2433 
2434   addic_(displaced_header, displaced_header, -1);
2435   blt(CCR0, notRecursive); // Not recursive if negative after decrement.
2436   std(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
2437   if (flag == CCR0) { // Otherwise, flag is already EQ, here.
2438     crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); // Set CCR0 EQ
2439   }
2440   b(success);
2441 
2442   bind(notRecursive);
2443   ld(temp,             in_bytes(ObjectMonitor::EntryList_offset()), current_header);
2444   ld(displaced_header, in_bytes(ObjectMonitor::cxq_offset()), current_header);
2445   orr(temp, temp, displaced_header); // Will be 0 if both are 0.
2446   cmpdi(flag, temp, 0);
2447   bne(flag, failure);
2448   release();
2449   std(temp, in_bytes(ObjectMonitor::owner_offset()), current_header);

2324     std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box);
2325 
2326     if (flag != CCR0) {
2327       mcrf(flag, CCR0);
2328     }
2329     beq(CCR0, success);
2330     b(failure);
2331   } else {
2332     assert(LockingMode == LM_LIGHTWEIGHT, "must be");
2333     lightweight_lock(oop, displaced_header, temp, failure);
2334     b(success);
2335   }
2336 
2337   // Handle existing monitor.
2338   bind(object_has_monitor);
2339   // The object's monitor m is unlocked iff m->owner is null,
2340   // otherwise m->owner may contain a thread or a stack address.
2341 
2342   // Try to CAS m->owner from null to current thread.
2343   addi(temp, displaced_header, in_bytes(ObjectMonitor::owner_offset()) - markWord::monitor_value);
2344   Register thread_id = displaced_header;
2345   ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
2346   cmpxchgd(/*flag=*/flag,
2347            /*current_value=*/current_header,
2348            /*compare_value=*/(intptr_t)0,
2349            /*exchange_value=*/thread_id,
2350            /*where=*/temp,
2351            MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
2352            MacroAssembler::cmpxchgx_hint_acquire_lock());
2353 
2354   if (LockingMode != LM_LIGHTWEIGHT) {
2355     // Store a non-null value into the box.
2356     std(box, BasicLock::displaced_header_offset_in_bytes(), box);
2357   }
2358   beq(flag, success);
2359 
2360   // Check for recursive locking.
2361   cmpd(flag, current_header, thread_id);
2362   bne(flag, failure);
2363 
2364   // Current thread already owns the lock. Just increment recursions.
2365   Register recursions = displaced_header;
2366   ld(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);
2367   addi(recursions, recursions, 1);
2368   std(recursions, in_bytes(ObjectMonitor::recursions_offset() - ObjectMonitor::owner_offset()), temp);
2369 
2370   // flag == EQ indicates success, increment held monitor count
2371   // flag == NE indicates failure
2372   bind(success);
2373   inc_held_monitor_count(temp);
2374   bind(failure);
2375 }
2376 
2377 void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box,
2378                                                  Register temp, Register displaced_header, Register current_header) {
2379   assert_different_registers(oop, box, temp, displaced_header, current_header);
2380   assert(LockingMode != LM_LIGHTWEIGHT || flag == CCR0, "bad condition register");
2381   Label success, failure, object_has_monitor, notRecursive;

2411              MacroAssembler::MemBarRel,
2412              MacroAssembler::cmpxchgx_hint_release_lock(),
2413              noreg,
2414              &failure);
2415     assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
2416     b(success);
2417   } else {
2418     assert(LockingMode == LM_LIGHTWEIGHT, "must be");
2419     lightweight_unlock(oop, current_header, failure);
2420     b(success);
2421   }
2422 
2423   // Handle existing monitor.
2424   bind(object_has_monitor);
2425   STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
2426   addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
2427   ld(temp,             in_bytes(ObjectMonitor::owner_offset()), current_header);
2428 
2429   // In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
2430   // This is handled like owner thread mismatches: We take the slow path.
2431   Register thread_id = displaced_header;
2432   ld(thread_id, in_bytes(JavaThread::lock_id_offset()), R16_thread);
2433   cmpd(flag, temp, thread_id);
2434   bne(flag, failure);
2435 
2436   ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
2437 
2438   addic_(displaced_header, displaced_header, -1);
2439   blt(CCR0, notRecursive); // Not recursive if negative after decrement.
2440   std(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
2441   if (flag == CCR0) { // Otherwise, flag is already EQ, here.
2442     crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); // Set CCR0 EQ
2443   }
2444   b(success);
2445 
2446   bind(notRecursive);
2447   ld(temp,             in_bytes(ObjectMonitor::EntryList_offset()), current_header);
2448   ld(displaced_header, in_bytes(ObjectMonitor::cxq_offset()), current_header);
2449   orr(temp, temp, displaced_header); // Will be 0 if both are 0.
2450   cmpdi(flag, temp, 0);
2451   bne(flag, failure);
2452   release();
2453   std(temp, in_bytes(ObjectMonitor::owner_offset()), current_header);
< prev index next >