Skip to content

Commit f155f7d

Browse files
committed
8364141: Remove LockingMode related code from x86
Reviewed-by: aboldtch, dholmes, coleenp
1 parent b81f4fa commit f155f7d

10 files changed

+93
-602
lines changed

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ int LIR_Assembler::emit_unwind_handler() {
413413
if (method()->is_synchronized()) {
414414
monitor_address(0, FrameMap::rax_opr);
415415
stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
416-
if (LockingMode == LM_MONITOR) {
417-
__ jmp(*stub->entry());
418-
} else {
419-
__ unlock_object(rdi, rsi, rax, *stub->entry());
420-
}
416+
__ unlock_object(rdi, rsi, rax, *stub->entry());
421417
__ bind(*stub->continuation());
422418
}
423419

@@ -2733,15 +2729,9 @@ void LIR_Assembler::emit_lock(LIR_OpLock* op) {
27332729
Register obj = op->obj_opr()->as_register(); // may not be an oop
27342730
Register hdr = op->hdr_opr()->as_register();
27352731
Register lock = op->lock_opr()->as_register();
2736-
if (LockingMode == LM_MONITOR) {
2737-
if (op->info() != nullptr) {
2738-
add_debug_info_for_null_check_here(op->info());
2739-
__ null_check(obj);
2740-
}
2741-
__ jmp(*op->stub()->entry());
2742-
} else if (op->code() == lir_lock) {
2732+
if (op->code() == lir_lock) {
27432733
assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
2744-
Register tmp = LockingMode == LM_LIGHTWEIGHT ? op->scratch_opr()->as_register() : noreg;
2734+
Register tmp = op->scratch_opr()->as_register();
27452735
// add debug info for NullPointerException only if one is possible
27462736
int null_check_offset = __ lock_object(hdr, obj, lock, tmp, *op->stub()->entry());
27472737
if (op->info() != nullptr) {

src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
289289
// this CodeEmitInfo must not have the xhandlers because here the
290290
// object is already locked (xhandlers expect object to be unlocked)
291291
CodeEmitInfo* info = state_for(x, x->state(), true);
292-
LIR_Opr tmp = LockingMode == LM_LIGHTWEIGHT ? new_register(T_ADDRESS) : LIR_OprFact::illegalOpr;
292+
LIR_Opr tmp = new_register(T_ADDRESS);
293293
monitor_enter(obj.result(), lock, syncTempOpr(), tmp,
294294
x->monitor_no(), info_for_exception, info);
295295
}

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#include "utilities/globalDefinitions.hpp"
4343

4444
int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Register tmp, Label& slow_case) {
45-
const int aligned_mask = BytesPerWord -1;
46-
const int hdr_offset = oopDesc::mark_offset_in_bytes();
4745
assert(hdr == rax, "hdr must be rax, for the cmpxchg instruction");
4846
assert_different_registers(hdr, obj, disp_hdr, tmp);
4947
int null_check_offset = -1;
@@ -55,93 +53,20 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
5553

5654
null_check_offset = offset();
5755

58-
if (LockingMode == LM_LIGHTWEIGHT) {
59-
lightweight_lock(disp_hdr, obj, hdr, tmp, slow_case);
60-
} else if (LockingMode == LM_LEGACY) {
61-
Label done;
62-
63-
if (DiagnoseSyncOnValueBasedClasses != 0) {
64-
load_klass(hdr, obj, rscratch1);
65-
testb(Address(hdr, Klass::misc_flags_offset()), KlassFlags::_misc_is_value_based_class);
66-
jcc(Assembler::notZero, slow_case);
67-
}
68-
69-
// Load object header
70-
movptr(hdr, Address(obj, hdr_offset));
71-
// and mark it as unlocked
72-
orptr(hdr, markWord::unlocked_value);
73-
// save unlocked object header into the displaced header location on the stack
74-
movptr(Address(disp_hdr, 0), hdr);
75-
// test if object header is still the same (i.e. unlocked), and if so, store the
76-
// displaced header address in the object header - if it is not the same, get the
77-
// object header instead
78-
MacroAssembler::lock(); // must be immediately before cmpxchg!
79-
cmpxchgptr(disp_hdr, Address(obj, hdr_offset));
80-
// if the object header was the same, we're done
81-
jcc(Assembler::equal, done);
82-
// if the object header was not the same, it is now in the hdr register
83-
// => test if it is a stack pointer into the same stack (recursive locking), i.e.:
84-
//
85-
// 1) (hdr & aligned_mask) == 0
86-
// 2) rsp <= hdr
87-
// 3) hdr <= rsp + page_size
88-
//
89-
// these 3 tests can be done by evaluating the following expression:
90-
//
91-
// (hdr - rsp) & (aligned_mask - page_size)
92-
//
93-
// assuming both the stack pointer and page_size have their least
94-
// significant 2 bits cleared and page_size is a power of 2
95-
subptr(hdr, rsp);
96-
andptr(hdr, aligned_mask - (int)os::vm_page_size());
97-
// for recursive locking, the result is zero => save it in the displaced header
98-
// location (null in the displaced hdr location indicates recursive locking)
99-
movptr(Address(disp_hdr, 0), hdr);
100-
// otherwise we don't care about the result and handle locking via runtime call
101-
jcc(Assembler::notZero, slow_case);
102-
// done
103-
bind(done);
104-
inc_held_monitor_count();
105-
}
56+
lightweight_lock(disp_hdr, obj, hdr, tmp, slow_case);
10657

10758
return null_check_offset;
10859
}
10960

11061
void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
111-
const int aligned_mask = BytesPerWord -1;
112-
const int hdr_offset = oopDesc::mark_offset_in_bytes();
11362
assert(disp_hdr == rax, "disp_hdr must be rax, for the cmpxchg instruction");
11463
assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
115-
Label done;
116-
117-
if (LockingMode != LM_LIGHTWEIGHT) {
118-
// load displaced header
119-
movptr(hdr, Address(disp_hdr, 0));
120-
// if the loaded hdr is null we had recursive locking
121-
testptr(hdr, hdr);
122-
// if we had recursive locking, we are done
123-
jcc(Assembler::zero, done);
124-
}
12564

12665
// load object
12766
movptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset()));
12867
verify_oop(obj);
12968

130-
if (LockingMode == LM_LIGHTWEIGHT) {
131-
lightweight_unlock(obj, disp_hdr, hdr, slow_case);
132-
} else if (LockingMode == LM_LEGACY) {
133-
// test if object header is pointing to the displaced header, and if so, restore
134-
// the displaced header in the object - if the object header is not pointing to
135-
// the displaced header, get the object header instead
136-
MacroAssembler::lock(); // must be immediately before cmpxchg!
137-
cmpxchgptr(hdr, Address(obj, hdr_offset));
138-
// if the object header was not pointing to the displaced header,
139-
// we do unlocking via runtime call
140-
jcc(Assembler::notEqual, slow_case);
141-
// done
142-
bind(done);
143-
dec_held_monitor_count();
144-
}
69+
lightweight_unlock(obj, disp_hdr, hdr, slow_case);
14570
}
14671

14772

0 commit comments

Comments
 (0)