Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,14 @@ void MonitorEnterStub::emit_code(LIR_Assembler* ce) {

void MonitorExitStub::emit_code(LIR_Assembler* ce) {
__ bind(_entry);

if (_compute_lock) {
// lock_reg was destroyed by fast unlocking attempt => recompute it
ce->monitor_address(_monitor_ix, _lock_reg);
}
ce->store_parameter(_obj_reg->as_register(), 1);
ce->store_parameter(_lock_reg->as_register(), 0);

// note: non-blocking leaf routine => no call info needed
Runtime1::StubID exit_id;
if (ce->compilation()->has_fpu_code()) {
Expand Down
52 changes: 29 additions & 23 deletions src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,37 +445,43 @@ int LIR_Assembler::emit_unwind_handler() {

__ bind(_unwind_handler_entry);
__ verify_not_null_oop(rax);
if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
__ mov(rbx, rax); // Preserve the exception (rbx is always callee-saved)
}

// Perform needed unlocking
MonitorExitStub* stub = nullptr;
if (method()->is_synchronized()) {
monitor_address(0, FrameMap::rax_opr);
stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
if (LockingMode == LM_MONITOR) {
__ jmp(*stub->entry());
} else {
__ unlock_object(rdi, rsi, rax, *stub->entry());
if (!ObjectMonitorMode::java()) {

if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
__ mov(rbx, rax); // Preserve the exception (rbx is always callee-saved)
}

// Perform needed unlocking
if (method()->is_synchronized()) {
assert(!ObjectMonitorMode::java(), "use catchall exception handler");
monitor_address(0, FrameMap::rax_opr);
stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
if (LockingMode == LM_MONITOR) {
__ jmp(*stub->entry());
} else {
__ unlock_object(rdi, rsi, rax, *stub->entry());
}
__ bind(*stub->continuation());
}
__ bind(*stub->continuation());
}

if (compilation()->env()->dtrace_method_probes()) {
if (compilation()->env()->dtrace_method_probes()) {
#ifdef _LP64
__ mov(rdi, r15_thread);
__ mov_metadata(rsi, method()->constant_encoding());
__ mov(rdi, r15_thread);
__ mov_metadata(rsi, method()->constant_encoding());
#else
__ get_thread(rax);
__ movptr(Address(rsp, 0), rax);
__ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding(), noreg);
__ get_thread(rax);
__ movptr(Address(rsp, 0), rax);
__ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding(), noreg);
#endif
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
}
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit)));
}

if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
__ mov(rax, rbx); // Restore the exception
}

if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) {
__ mov(rax, rbx); // Restore the exception
}

// remove the activation and dispatch to the unwind handler
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
set_no_result(x);

// "lock" stores the address of the monitor stack slot, so this is not an oop
LIR_Opr lock = new_register(T_INT);
LIR_Opr lock = new_register(T_ADDRESS);

CodeEmitInfo* info_for_exception = nullptr;
if (x->needs_null_check()) {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
assert_different_registers(hdr, obj, disp_hdr, tmp);
int null_check_offset = -1;

assert(!ObjectMonitorMode::java(), "");

verify_oop(obj);

// save object being locked into the BasicObjectLock
Expand Down Expand Up @@ -119,6 +121,8 @@ void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_
assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
Label done;

assert(!ObjectMonitorMode::java(), "");

if (LockingMode != LM_LIGHTWEIGHT) {
// load displaced header
movptr(hdr, Address(disp_hdr, 0));
Expand Down
24 changes: 22 additions & 2 deletions src/hotspot/cpu/x86/interp_masm_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@ void InterpreterMacroAssembler::dispatch_only(TosState state, bool generate_poll
dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
}

void InterpreterMacroAssembler::dispatch_only_via(TosState state, address* table, bool verifyoop, bool generate_poll) {
dispatch_base(state, table, verifyoop, generate_poll);
}

void InterpreterMacroAssembler::dispatch_only_normal(TosState state) {
dispatch_base(state, Interpreter::normal_table(state));
}
Expand All @@ -906,12 +910,16 @@ void InterpreterMacroAssembler::dispatch_only_noverify(TosState state) {
}


void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
void InterpreterMacroAssembler::dispatch_next_via(TosState state, address* table, int step, bool generate_poll) {
// load next bytecode (load before advancing _bcp_register to prevent AGI)
load_unsigned_byte(rbx, Address(_bcp_register, step));
// advance _bcp_register
increment(_bcp_register, step);
dispatch_base(state, Interpreter::dispatch_table(state), true, generate_poll);
dispatch_base(state, table, true, generate_poll);
}

void InterpreterMacroAssembler::dispatch_next(TosState state, int step, bool generate_poll) {
dispatch_next_via(state, Interpreter::dispatch_table(state), step, generate_poll);
}

void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
Expand Down Expand Up @@ -2190,8 +2198,12 @@ void InterpreterMacroAssembler::java_lock_object() {
ExternalAddress fetch_addr((address) Universe::object_monitorEnter_addr());
movptr(method, fetch_addr);

#if 1
if (ProfileJOMCalls > 1) {
profile_call(rax);
profile_arguments_type(rax, rbx, LP64_ONLY(r13) NOT_LP64(rsi), false);
}
#endif

jump_from_interpreted(rbx, rdx);

Expand Down Expand Up @@ -2260,8 +2272,12 @@ void InterpreterMacroAssembler::java_unlock_object(Register lock_reg) {
ExternalAddress fetch_addr((address) Universe::object_monitorExit_addr());
movptr(method, fetch_addr);

#if 1
if (ProfileJOMCalls > 1) {
profile_call(rax);
profile_arguments_type(rax, rbx, LP64_ONLY(r13) NOT_LP64(rsi), false);
}
#endif

jump_from_interpreted(rbx, rdx);

Expand Down Expand Up @@ -2314,8 +2330,12 @@ void InterpreterMacroAssembler::java_unlock_all_objects() {
ExternalAddress fetch_addr((address) Universe::object_monitorExitAll_addr());
movptr(method, fetch_addr);

#if 0
if (ProfileJOMCalls > 2) {
profile_call(rax);
profile_arguments_type(rax, rbx, LP64_ONLY(r13) NOT_LP64(rsi), false);
}
#endif

jump_from_interpreted(rbx, rdx);

Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/cpu/x86/interp_masm_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ class InterpreterMacroAssembler: public MacroAssembler {
void dispatch_only_noverify(TosState state);
// load rbx from [_bcp_register + step] and dispatch via rbx
void dispatch_next(TosState state, int step = 0, bool generate_poll = false);
// load rbx from [_bcp_register + step] and dispatch via rbx and table
void dispatch_next_via(TosState state, address* table, int step, bool generate_poll);

// load rbx from [_bcp_register] and dispatch via rbx and table
void dispatch_via (TosState state, address* table);
// dispatch via rbx and table
void dispatch_only_via(TosState state, address* table, bool verifyoop = false, bool generate_poll = false);

// jump to an invoked target
void prepare_to_jump_from_interpreted();
Expand Down
59 changes: 52 additions & 7 deletions src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state,
return entry;
}

address TemplateInterpreterGenerator::generate_return_entry_for_monitor(int step) {
address TemplateInterpreterGenerator::generate_return_entry_for_monitor(
Bytecodes::Code code, bool from_compiled, bool skip_over, Bytecodes::Code next_bc)
{
assert(ObjectMonitorMode::java(), "must be");
address entry = __ pc();

Expand All @@ -270,12 +272,51 @@ address TemplateInterpreterGenerator::generate_return_entry_for_monitor(int step
__ restore_bcp();
__ restore_locals();

__ pop(rax);

// clear system java
__ decrementl(Address(r15_thread, JavaThread::system_java_offset()), 1);

__ dispatch_next(vtos, step, false);
TosState state = vtos;
// This assumes monitorenter and exit both have the same args size.
// FIXME: pass in Method* or ars size.
// __ lea(rsp, Address(rsp, -parm_size * Interpreter::stackElementScale()));
//
if (from_compiled) {
if (code == Bytecodes::_monitorenter) {
// compiledMonitorEnter(Object, int)
__ pop_i();
__ pop_ptr();
} else {
assert(code == Bytecodes::_monitorexit, "unsupported bytecode");
if (next_bc == Bytecodes::_athrow) {
// compiledMonitorExitWithException(Object, int, Object exception)
__ warn("XXX monitorexit with exception");
state = atos;
__ pop(state); // exception objects
__ pop_i(rbx);
__ pop_ptr(rbx);
} else {
// compiledMonitorExit(Object, int)
__ pop_i();
__ pop_ptr();
if (next_bc == Bytecodes::_areturn) {
state = atos;
__ pop(state);
}
}
}
} else {
__ pop(rax);
// clear system java
__ decrementl(Address(r15_thread, JavaThread::system_java_offset()), 1);
}
if (next_bc == Bytecodes::_illegal) {
int step = skip_over ? Bytecodes::length_for(code) : 0;
__ dispatch_next(vtos, step);
} else {
__ movl(rbx, next_bc);
#if 0
__ dispatch_only(vtos, false);
#else
__ dispatch_only_via(vtos, Interpreter::safept_table(vtos), true, true);
#endif
}

return entry;
}
Expand Down Expand Up @@ -340,7 +381,11 @@ address TemplateInterpreterGenerator::generate_deopt_entry_for(TosState state, i
__ bind(L);
}
if (continuation == nullptr) {
#if 0
__ dispatch_next(state, step);
#else
__ dispatch_next_via(state, Interpreter::safept_table(state), step, true);
#endif
} else {
__ jump_to_entry(continuation);
}
Expand Down
25 changes: 3 additions & 22 deletions src/hotspot/cpu/x86/templateInterpreterGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,20 +501,6 @@ address TemplateInterpreterGenerator::generate_Float_floatToRawIntBits_entry() {
address TemplateInterpreterGenerator::generate_Double_longBitsToDouble_entry() { return nullptr; }
address TemplateInterpreterGenerator::generate_Double_doubleToRawLongBits_entry() { return nullptr; }

address TemplateInterpreterGenerator::generate_caller_frame_id() {

address entry_point = __ pc();

__ movptr(rax, Address(rbp, frame::link_offset * wordSize));

__ pop(rcx);
__ mov(rsp, r13);
__ jmp(rcx);

return entry_point;
}


address TemplateInterpreterGenerator::generate_get_lock_state() {

address entry_point = __ pc();
Expand All @@ -538,21 +524,16 @@ address TemplateInterpreterGenerator::generate_cas_lock_state() {
const Register robj = rcx;
const Register rtmp = r8;
const Register rto = r10;
const Register rr2tmp = r11;
const Register rfrom = rax; // Must be rax

__ movptr(robj, Address(rsp, 3*wordSize));
__ movptr(rto, Address(rsp, 2*wordSize));
__ movptr(rfrom, Address(rsp, 1*wordSize));
__ movl (rto, Address(rsp, 2*wordSize));
__ movl (rfrom, Address(rsp, 1*wordSize));

__ movptr(rtmp, Address(robj, oopDesc::mark_offset_in_bytes()));

__ movq(rr2tmp, markWord::lock_mask_in_place);
__ notq(rr2tmp);

__ andptr(rtmp, rr2tmp);

// Clean MW in rtmp
__ andptr(rtmp, ~(int32_t)markWord::lock_mask_in_place);
__ orptr(rto, rtmp);
__ orptr(rfrom, rtmp);

Expand Down
13 changes: 13 additions & 0 deletions src/hotspot/cpu/x86/templateTable_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4339,6 +4339,9 @@ void TemplateTable::athrow() {
void TemplateTable::monitorenter() {
if (ObjectMonitorMode::java()) {

__ pop_ptr(rax);
__ push_ptr(rax);

// check for null object
__ null_check(rax);

Expand Down Expand Up @@ -4437,8 +4440,12 @@ void TemplateTable::monitorenter() {
ExternalAddress fetch_addr((address) Universe::object_monitorEnter_addr());
__ movptr(method, fetch_addr);

#if 1
if (ProfileJOMCalls) {
__ profile_call(rax);
__ profile_arguments_type(rax, rbx, rbcp, false);
}
#endif

__ jump_from_interpreted(method, rdx);

Expand Down Expand Up @@ -4545,6 +4552,8 @@ void TemplateTable::monitorenter() {
void TemplateTable::monitorexit() {

if (ObjectMonitorMode::java()) {
__ pop_ptr(rax);
__ push_ptr(rax);

// check for null object
__ null_check(rax);
Expand Down Expand Up @@ -4612,8 +4621,12 @@ void TemplateTable::monitorexit() {
ExternalAddress fetch_addr((address) Universe::object_monitorExit_addr());
__ movptr(method, fetch_addr);

#if 1
if (ProfileJOMCalls) {
__ profile_call(rax);
__ profile_arguments_type(rax, rbx, rbcp, false);
}
#endif

__ jump_from_interpreted(rbx, rdx);

Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/c1/X
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// exit the monitor in the context of the synchronized method
monitorexit(lock, bci);

1 change: 1 addition & 0 deletions src/hotspot/share/c1/c1_Canonicalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ void Canonicalizer::do_LookupSwitch(LookupSwitch* x) {
void Canonicalizer::do_Return (Return* x) {}
void Canonicalizer::do_Throw (Throw* x) {}
void Canonicalizer::do_Base (Base* x) {}
void Canonicalizer::do_Start (Start* x) {}
void Canonicalizer::do_OsrEntry (OsrEntry* x) {}
void Canonicalizer::do_ExceptionObject(ExceptionObject* x) {}
void Canonicalizer::do_RoundFP (RoundFP* x) {}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/c1/c1_Canonicalizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Canonicalizer: InstructionVisitor {
virtual void do_Return (Return* x);
virtual void do_Throw (Throw* x);
virtual void do_Base (Base* x);
virtual void do_Start (Start* x);
virtual void do_OsrEntry (OsrEntry* x);
virtual void do_ExceptionObject(ExceptionObject* x);
virtual void do_RoundFP (RoundFP* x);
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/c1/c1_CodeStubs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ class MonitorExitStub: public MonitorAccessStub {
_compute_lock(compute_lock), _monitor_ix(monitor_ix) { }
virtual void emit_code(LIR_Assembler* e);
virtual void visit(LIR_OpVisitState* visitor) {
assert(_obj_reg->is_illegal(), "unused");
if (_compute_lock) {
visitor->do_temp(_lock_reg);
} else {
Expand Down
Loading