Skip to content


8281043: Intrinsify recursive ObjectMonitor locking for PPC64
Browse files Browse the repository at this point in the history
Backport-of: 46c6c6f308b5ec0ec3b762df4b76de555287474c
  • Loading branch information
TheRealMDoerr committed Mar 3, 2022
1 parent 02a876f commit 23b7f7e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
@@ -1,6 +1,6 @@
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2022 SAP SE. All rights reserved.
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -2942,16 +2942,17 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register

// Store a non-null value into the box.
std(box, BasicLock::displaced_header_offset_in_bytes(), box);
beq(flag, cont);

# ifdef ASSERT
// Check for recursive locking.
cmpd(flag, current_header, R16_thread);
bne(flag, cont);
// We have acquired the monitor, check some invariants.
addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes());
// Invariant 1: _recursions should be 0.
//assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
"monitor->_recursions should be 0");
# endif

// Current thread already owns the lock. Just increment recursions.
Register recursions = displaced_header;
ld(recursions, ObjectMonitor::recursions_offset_in_bytes()-ObjectMonitor::owner_offset_in_bytes(), temp);
addi(recursions, recursions, 1);
std(recursions, ObjectMonitor::recursions_offset_in_bytes()-ObjectMonitor::owner_offset_in_bytes(), temp);

} // use_rtm()
Expand All @@ -2967,8 +2968,7 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
bool try_bias, bool use_rtm) {
assert_different_registers(oop, box, temp, displaced_header, current_header);
assert(flag != CCR0, "bad condition register");
Label cont;
Label object_has_monitor;
Label cont, object_has_monitor, notRecursive;

if (try_bias) {
biased_locking_exit(flag, oop, current_header, cont);
Expand Down Expand Up @@ -3039,11 +3039,16 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe

ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
xorr(temp, R16_thread, temp); // Will be 0 if we are the owner.
orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions.
cmpdi(flag, temp, 0);

cmpd(flag, temp, R16_thread);
bne(flag, cont);

addic_(displaced_header, displaced_header, -1);
blt(CCR0, notRecursive); // Not recursive if negative after decrement.
std(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
b(cont); // flag is already EQ here.

ld(temp, ObjectMonitor::EntryList_offset_in_bytes(), current_header);
ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header);
orr(temp, temp, displaced_header); // Will be 0 if both are 0.
Expand Down

1 comment on commit 23b7f7e

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.