if
(mark->has_bias_pattern()) { uintptr_t thread_ident; uintptr_t anticipated_bias_locking_value;
thread_ident = (uintptr_t)istate->thread();
anticipated_bias_locking_value =
(((uintptr_t)lockee->klass()->prototype_header() | thread_ident) ^ (uintptr_t)mark) &
~((uintptr_t) markOopDesc::age_mask_in_place);
if
(anticipated_bias_locking_value ==
0
) {
if
(PrintBiasedLockingStatistics) {
(* BiasedLocking::biased_lock_entry_count_addr())++;
}
success =
true
;
}
else
if
((anticipated_bias_locking_value & markOopDesc::biased_lock_mask_in_place) !=
0
) {
markOop header = lockee->klass()->prototype_header();
if
(hash != markOopDesc::no_hash) {
header = header->copy_set_hash(hash);
}
if
(Atomic::cmpxchg_ptr(header, lockee->mark_addr(), mark) == mark) {
if
(PrintBiasedLockingStatistics)
(*BiasedLocking::revoked_lock_entry_count_addr())++;
}
}
else
if
((anticipated_bias_locking_value & epoch_mask_in_place) !=
0
) {
markOop new_header = (markOop) ( (intptr_t) lockee->klass()->prototype_header() | thread_ident);
if
(hash != markOopDesc::no_hash) {
new_header = new_header->copy_set_hash(hash);
}
if
(Atomic::cmpxchg_ptr((
void
*)new_header, lockee->mark_addr(), mark) == mark) {
if
(PrintBiasedLockingStatistics)
(* BiasedLocking::rebiased_lock_entry_count_addr())++;
}
else
{
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
}
success =
true
;
}
else
{
markOop header = (markOop) ((uintptr_t) mark & ((uintptr_t)markOopDesc::biased_lock_mask_in_place |(uintptr_t)markOopDesc::age_mask_in_place |epoch_mask_in_place));
if
(hash != markOopDesc::no_hash) {
header = header->copy_set_hash(hash);
}
markOop new_header = (markOop) ((uintptr_t) header | thread_ident);
DEBUG_ONLY(entry->lock()->set_displaced_header((markOop) (uintptr_t)
0xdeaddead
);)
if
(Atomic::cmpxchg_ptr((
void
*)new_header, lockee->mark_addr(), header) == header) {
if
(PrintBiasedLockingStatistics)
(* BiasedLocking::anonymously_biased_lock_entry_count_addr())++;
}
else
{
CALL_VM(InterpreterRuntime::monitorenter(THREAD, entry), handle_exception);
}
success =
true
;
}