Skip to content

Commit a0ed69d

Browse files
committed
8341715: PPC64: ObjectMonitor::_owner should be reset unconditionally in nmethod unlocking
Reviewed-by: mdoerr Backport-of: f9208fadde8141e18a025ddb6ce28423861ba391
1 parent 532c49a commit a0ed69d

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

src/hotspot/cpu/ppc/macroAssembler_ppc.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,7 +2759,19 @@ void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register
27592759
// flag == NE indicates failure
27602760
bind(success);
27612761
inc_held_monitor_count(temp);
2762+
#ifdef ASSERT
2763+
// Check that unlocked label is reached with flag == EQ.
2764+
Label flag_correct;
2765+
beq(flag, flag_correct);
2766+
stop("compiler_fast_lock_object: Flag != EQ");
2767+
#endif
27622768
bind(failure);
2769+
#ifdef ASSERT
2770+
// Check that slow_path label is reached with flag == NE.
2771+
bne(flag, flag_correct);
2772+
stop("compiler_fast_lock_object: Flag != NE");
2773+
bind(flag_correct);
2774+
#endif
27632775
}
27642776

27652777
void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box,
@@ -2827,7 +2839,10 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
28272839
bind(object_has_monitor);
28282840
STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
28292841
addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
2830-
ld(temp, in_bytes(ObjectMonitor::owner_offset()), current_header);
2842+
2843+
if ((LockingMode == LM_LIGHTWEIGHT) || use_rtm) {
2844+
ld(temp, in_bytes(ObjectMonitor::owner_offset()), current_header);
2845+
}
28312846

28322847
// It's inflated.
28332848
#if INCLUDE_RTM_OPT
@@ -2842,15 +2857,18 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
28422857
}
28432858
#endif
28442859

2845-
// In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
2846-
// This is handled like owner thread mismatches: We take the slow path.
2847-
cmpd(flag, temp, R16_thread);
2848-
bne(flag, failure);
2860+
if (LockingMode == LM_LIGHTWEIGHT) {
2861+
// In case of LM_LIGHTWEIGHT, we may reach here with (temp & ObjectMonitor::ANONYMOUS_OWNER) != 0.
2862+
// This is handled like owner thread mismatches: We take the slow path.
2863+
cmpd(flag, temp, R16_thread);
2864+
bne(flag, failure);
2865+
}
28492866

28502867
ld(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
2851-
28522868
addic_(displaced_header, displaced_header, -1);
28532869
blt(CCR0, notRecursive); // Not recursive if negative after decrement.
2870+
2871+
// Recursive unlock
28542872
std(displaced_header, in_bytes(ObjectMonitor::recursions_offset()), current_header);
28552873
if (flag == CCR0) { // Otherwise, flag is already EQ, here.
28562874
crorc(CCR0, Assembler::equal, CCR0, Assembler::equal); // Set CCR0 EQ
@@ -2870,7 +2888,19 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe
28702888
// flag == NE indicates failure
28712889
bind(success);
28722890
dec_held_monitor_count(temp);
2891+
#ifdef ASSERT
2892+
// Check that unlocked label is reached with flag == EQ.
2893+
Label flag_correct;
2894+
beq(flag, flag_correct);
2895+
stop("compiler_fast_unlock_object: Flag != EQ");
2896+
#endif
28732897
bind(failure);
2898+
#ifdef ASSERT
2899+
// Check that slow_path label is reached with flag == NE.
2900+
bne(flag, flag_correct);
2901+
stop("compiler_fast_unlock_object: Flag != NE");
2902+
bind(flag_correct);
2903+
#endif
28742904
}
28752905

28762906
void MacroAssembler::safepoint_poll(Label& slow_path, Register temp, bool at_return, bool in_nmethod) {

0 commit comments

Comments
 (0)