src/hotspot/cpu/arm/macroAssembler_arm.cpp
changeset 57777 90ead0febf56
parent 53061 5da72d7e0e80
child 57959 6b539901e79e
equal deleted inserted replaced
57774:21dccfac0ec5 57777:90ead0febf56
  1343   if (PrintBiasedLockingStatistics && (counters == NULL)) {
  1343   if (PrintBiasedLockingStatistics && (counters == NULL)) {
  1344     counters = BiasedLocking::counters();
  1344     counters = BiasedLocking::counters();
  1345   }
  1345   }
  1346 #endif
  1346 #endif
  1347 
  1347 
  1348   assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
  1348   assert(markWord::age_shift == markWord::lock_bits + markWord::biased_lock_bits, "biased locking makes assumptions about bit layout");
  1349   Address mark_addr(obj_reg, oopDesc::mark_offset_in_bytes());
  1349   Address mark_addr(obj_reg, oopDesc::mark_offset_in_bytes());
  1350 
  1350 
  1351   // Biased locking
  1351   // Biased locking
  1352   // See whether the lock is currently biased toward our thread and
  1352   // See whether the lock is currently biased toward our thread and
  1353   // whether the epoch is still valid
  1353   // whether the epoch is still valid
  1365   }
  1365   }
  1366 
  1366 
  1367   // On MP platform loads could return 'stale' values in some cases.
  1367   // On MP platform loads could return 'stale' values in some cases.
  1368   // That is acceptable since either CAS or slow case path is taken in the worst case.
  1368   // That is acceptable since either CAS or slow case path is taken in the worst case.
  1369 
  1369 
  1370   andr(tmp_reg, swap_reg, (uintx)markOopDesc::biased_lock_mask_in_place);
  1370   andr(tmp_reg, swap_reg, (uintx)markWord::biased_lock_mask_in_place);
  1371   cmp(tmp_reg, markOopDesc::biased_lock_pattern);
  1371   cmp(tmp_reg, markWord::biased_lock_pattern);
  1372 
  1372 
  1373   b(cas_label, ne);
  1373   b(cas_label, ne);
  1374 
  1374 
  1375   // The bias pattern is present in the object's header. Need to check
  1375   // The bias pattern is present in the object's header. Need to check
  1376   // whether the bias owner and the epoch are both still current.
  1376   // whether the bias owner and the epoch are both still current.
  1377   load_klass(tmp_reg, obj_reg);
  1377   load_klass(tmp_reg, obj_reg);
  1378   ldr(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset()));
  1378   ldr(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset()));
  1379   orr(tmp_reg, tmp_reg, Rthread);
  1379   orr(tmp_reg, tmp_reg, Rthread);
  1380   eor(tmp_reg, tmp_reg, swap_reg);
  1380   eor(tmp_reg, tmp_reg, swap_reg);
  1381 
  1381 
  1382   bics(tmp_reg, tmp_reg, ((int) markOopDesc::age_mask_in_place));
  1382   bics(tmp_reg, tmp_reg, ((int) markWord::age_mask_in_place));
  1383 
  1383 
  1384 #ifndef PRODUCT
  1384 #ifndef PRODUCT
  1385   if (counters != NULL) {
  1385   if (counters != NULL) {
  1386     cond_atomic_inc32(eq, counters->biased_lock_entry_count_addr());
  1386     cond_atomic_inc32(eq, counters->biased_lock_entry_count_addr());
  1387   }
  1387   }
  1399   // header.
  1399   // header.
  1400 
  1400 
  1401   // If the low three bits in the xor result aren't clear, that means
  1401   // If the low three bits in the xor result aren't clear, that means
  1402   // the prototype header is no longer biased and we have to revoke
  1402   // the prototype header is no longer biased and we have to revoke
  1403   // the bias on this object.
  1403   // the bias on this object.
  1404   tst(tmp_reg, (uintx)markOopDesc::biased_lock_mask_in_place);
  1404   tst(tmp_reg, (uintx)markWord::biased_lock_mask_in_place);
  1405   b(try_revoke_bias, ne);
  1405   b(try_revoke_bias, ne);
  1406 
  1406 
  1407   // Biasing is still enabled for this data type. See whether the
  1407   // Biasing is still enabled for this data type. See whether the
  1408   // epoch of the current bias is still valid, meaning that the epoch
  1408   // epoch of the current bias is still valid, meaning that the epoch
  1409   // bits of the mark word are equal to the epoch bits of the
  1409   // bits of the mark word are equal to the epoch bits of the
  1411   // only change at a safepoint.) If not, attempt to rebias the object
  1411   // only change at a safepoint.) If not, attempt to rebias the object
  1412   // toward the current thread. Note that we must be absolutely sure
  1412   // toward the current thread. Note that we must be absolutely sure
  1413   // that the current epoch is invalid in order to do this because
  1413   // that the current epoch is invalid in order to do this because
  1414   // otherwise the manipulations it performs on the mark word are
  1414   // otherwise the manipulations it performs on the mark word are
  1415   // illegal.
  1415   // illegal.
  1416   tst(tmp_reg, (uintx)markOopDesc::epoch_mask_in_place);
  1416   tst(tmp_reg, (uintx)markWord::epoch_mask_in_place);
  1417   b(try_rebias, ne);
  1417   b(try_rebias, ne);
  1418 
  1418 
  1419   // tmp_reg has the age, epoch and pattern bits cleared
  1419   // tmp_reg has the age, epoch and pattern bits cleared
  1420   // The remaining (owner) bits are (Thread ^ current_owner)
  1420   // The remaining (owner) bits are (Thread ^ current_owner)
  1421 
  1421 
  1429   // Note that we know the owner is not ourself. Hence, success can
  1429   // Note that we know the owner is not ourself. Hence, success can
  1430   // only happen when the owner bits is 0
  1430   // only happen when the owner bits is 0
  1431 
  1431 
  1432   // until the assembler can be made smarter, we need to make some assumptions about the values
  1432   // until the assembler can be made smarter, we need to make some assumptions about the values
  1433   // so we can optimize this:
  1433   // so we can optimize this:
  1434   assert((markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place) == 0x1ff, "biased bitmasks changed");
  1434   assert((markWord::biased_lock_mask_in_place | markWord::age_mask_in_place | markWord::epoch_mask_in_place) == 0x1ff, "biased bitmasks changed");
  1435 
  1435 
  1436   mov(swap_reg, AsmOperand(swap_reg, lsl, 23));
  1436   mov(swap_reg, AsmOperand(swap_reg, lsl, 23));
  1437   mov(swap_reg, AsmOperand(swap_reg, lsr, 23)); // markOop with thread bits cleared (for CAS)
  1437   mov(swap_reg, AsmOperand(swap_reg, lsr, 23)); // markWord with thread bits cleared (for CAS)
  1438 
  1438 
  1439   orr(tmp_reg, swap_reg, Rthread); // new mark
  1439   orr(tmp_reg, swap_reg, Rthread); // new mark
  1440 
  1440 
  1441   biased_locking_enter_with_cas(obj_reg, swap_reg, tmp_reg, tmp2, slow_case,
  1441   biased_locking_enter_with_cas(obj_reg, swap_reg, tmp_reg, tmp2, slow_case,
  1442         (counters != NULL) ? counters->anonymously_biased_lock_entry_count_addr() : NULL);
  1442         (counters != NULL) ? counters->anonymously_biased_lock_entry_count_addr() : NULL);
  1517   // a higher level. Second, if the bias was revoked while we held the
  1517   // a higher level. Second, if the bias was revoked while we held the
  1518   // lock, the object could not be rebiased toward another thread, so
  1518   // lock, the object could not be rebiased toward another thread, so
  1519   // the bias bit would be clear.
  1519   // the bias bit would be clear.
  1520   ldr(tmp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
  1520   ldr(tmp_reg, Address(obj_reg, oopDesc::mark_offset_in_bytes()));
  1521 
  1521 
  1522   andr(tmp_reg, tmp_reg, (uintx)markOopDesc::biased_lock_mask_in_place);
  1522   andr(tmp_reg, tmp_reg, (uintx)markWord::biased_lock_mask_in_place);
  1523   cmp(tmp_reg, markOopDesc::biased_lock_pattern);
  1523   cmp(tmp_reg, markWord::biased_lock_pattern);
  1524   b(done, eq);
  1524   b(done, eq);
  1525 }
  1525 }
  1526 
  1526 
  1527 
  1527 
  1528 void MacroAssembler::resolve_jobject(Register value,
  1528 void MacroAssembler::resolve_jobject(Register value,
  1991   }
  1991   }
  1992 
  1992 
  1993   // Invariant: Rmark loaded below does not contain biased lock pattern
  1993   // Invariant: Rmark loaded below does not contain biased lock pattern
  1994 
  1994 
  1995   ldr(Rmark, Address(Roop, oopDesc::mark_offset_in_bytes()));
  1995   ldr(Rmark, Address(Roop, oopDesc::mark_offset_in_bytes()));
  1996   tst(Rmark, markOopDesc::unlocked_value);
  1996   tst(Rmark, markWord::unlocked_value);
  1997   b(fast_lock, ne);
  1997   b(fast_lock, ne);
  1998 
  1998 
  1999   // Check for recursive lock
  1999   // Check for recursive lock
  2000   // See comments in InterpreterMacroAssembler::lock_object for
  2000   // See comments in InterpreterMacroAssembler::lock_object for
  2001   // explanations on the fast recursive locking check.
  2001   // explanations on the fast recursive locking check.