Skip to content


8281043: Intrinsify recursive ObjectMonitor locking for PPC64
Browse files Browse the repository at this point in the history
Reviewed-by: rrich, lucy
  • Loading branch information
TheRealMDoerr committed Feb 4, 2022
1 parent c936e70 commit 46c6c6f
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 @@ -2732,16 +2732,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 @@ -2757,8 +2758,7 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
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 (UseRTMForStackLocks && use_rtm) {
Expand Down Expand Up @@ -2830,11 +2830,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

3 comments on commit 46c6c6f

Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

Copy link

@openjdk openjdk bot commented on 46c6c6f Feb 9, 2022

Choose a reason for hiding this comment

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

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-46c6c6f3 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 46c6c6f3 from the openjdk/jdk repository.

The commit being backported was authored by Martin Doerr on 4 Feb 2022 and was reviewed by Richard Reingruber and Lutz Schmidt.


If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch TheRealMDoerr-backport-46c6c6f3:TheRealMDoerr-backport-46c6c6f3
$ git checkout TheRealMDoerr-backport-46c6c6f3
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push TheRealMDoerr-backport-46c6c6f3

Please sign in to comment.