Skip to content

Commit

Permalink
Automatic merge of jdk:master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Nov 3, 2020
2 parents 57663be + 134e22a commit 21b5bdb
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 29 deletions.
18 changes: 14 additions & 4 deletions src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp
Expand Up @@ -80,19 +80,29 @@ void ConversionStub::emit_code(LIR_Assembler* ce) {
#endif // !_LP64

void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
#ifdef _LP64
__ bind(_entry);
InternalAddress safepoint_pc(ce->masm()->pc() - ce->masm()->offset() + safepoint_offset());
#ifdef _LP64
__ lea(rscratch1, safepoint_pc);
__ movptr(Address(r15_thread, JavaThread::saved_exception_pc_offset()), rscratch1);
#else
const Register tmp1 = rcx;
const Register tmp2 = rdx;
__ push(tmp1);
__ push(tmp2);

__ lea(tmp1, safepoint_pc);
__ get_thread(tmp2);
__ movptr(Address(tmp2, JavaThread::saved_exception_pc_offset()), tmp1);

__ pop(tmp2);
__ pop(tmp1);
#endif /* _LP64 */
assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
"polling page return stub not created yet");

address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
__ jump(RuntimeAddress(stub));
#else
ShouldNotReachHere();
#endif /* _LP64 */
}

void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
Expand Down
15 changes: 6 additions & 9 deletions src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
Expand Up @@ -535,17 +535,14 @@ void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
// the poll sets the condition code, but no data registers

#ifdef _LP64
code_stub->set_safepoint_offset(__ offset());
__ relocate(relocInfo::poll_return_type);
__ safepoint_poll(*code_stub->entry(), r15_thread, true /* at_return */, true /* in_nmethod */);
const Register thread = r15_thread;
#else
const Register poll_addr = rbx;
assert(FrameMap::is_caller_save_register(poll_addr), "will overwrite");
__ get_thread(poll_addr);
__ movptr(poll_addr, Address(poll_addr, Thread::polling_page_offset()));
__ relocate(relocInfo::poll_return_type);
__ testl(rax, Address(poll_addr, 0));
const Register thread = rbx;
__ get_thread(thread);
#endif
code_stub->set_safepoint_offset(__ offset());
__ relocate(relocInfo::poll_return_type);
__ safepoint_poll(*code_stub->entry(), thread, true /* at_return */, true /* in_nmethod */);
__ ret(0);
}

Expand Down
16 changes: 13 additions & 3 deletions src/hotspot/cpu/x86/c2_safepointPollStubTable_x86.cpp
Expand Up @@ -31,7 +31,6 @@

#define __ masm.
void C2SafepointPollStubTable::emit_stub_impl(MacroAssembler& masm, C2SafepointPollStub* entry) const {
#ifdef _LP64
assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
"polling page return stub not created yet");
address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
Expand All @@ -40,11 +39,22 @@ void C2SafepointPollStubTable::emit_stub_impl(MacroAssembler& masm, C2SafepointP

__ bind(entry->_stub_label);
InternalAddress safepoint_pc(masm.pc() - masm.offset() + entry->_safepoint_offset);
#ifdef _LP64
__ lea(rscratch1, safepoint_pc);
__ movptr(Address(r15_thread, JavaThread::saved_exception_pc_offset()), rscratch1);
__ jump(callback_addr);
#else
ShouldNotReachHere();
const Register tmp1 = rcx;
const Register tmp2 = rdx;
__ push(tmp1);
__ push(tmp2);

__ lea(tmp1, safepoint_pc);
__ get_thread(tmp2);
__ movptr(Address(tmp2, JavaThread::saved_exception_pc_offset()), tmp1);

__ pop(tmp2);
__ pop(tmp1);
#endif
__ jump(callback_addr);
}
#undef __
4 changes: 1 addition & 3 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Expand Up @@ -2761,15 +2761,13 @@ void MacroAssembler::save_rax(Register tmp) {
}

void MacroAssembler::safepoint_poll(Label& slow_path, Register thread_reg, bool at_return, bool in_nmethod) {
#ifdef _LP64
if (at_return) {
// Note that when in_nmethod is set, the stack pointer is incremented before the poll. Therefore,
// we may safely use rsp instead to perform the stack watermark check.
cmpq(in_nmethod ? rsp : rbp, Address(thread_reg, Thread::polling_word_offset()));
cmpptr(in_nmethod ? rsp : rbp, Address(thread_reg, Thread::polling_word_offset()));
jcc(Assembler::above, slow_path);
return;
}
#endif
testb(Address(thread_reg, Thread::polling_word_offset()), SafepointMechanism::poll_bit());
jcc(Assembler::notZero, slow_path); // handshake bit set implies poll
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/vm_version_x86.hpp
Expand Up @@ -1023,7 +1023,7 @@ enum Extended_Family {
}

constexpr static bool supports_stack_watermark_barrier() {
return LP64_ONLY(true) NOT_LP64(false);
return true;
}

// there are several insns to force cache line sync to memory which
Expand Down
19 changes: 12 additions & 7 deletions src/hotspot/cpu/x86/x86_32.ad
Expand Up @@ -653,8 +653,9 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
}
st->print_cr("POPL EBP"); st->print("\t");
if (do_polling() && C->is_method_compilation()) {
st->print("TEST PollPage,EAX\t! Poll Safepoint");
st->cr(); st->print("\t");
st->print("CMPL rsp, poll_offset[thread] \n\t"
"JA #safepoint_stub\t"
"# Safepoint: poll for GC");
}
}
#endif
Expand Down Expand Up @@ -697,12 +698,16 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
}

if (do_polling() && C->is_method_compilation()) {
Register pollReg = as_Register(EBX_enc);
Register thread = as_Register(EBX_enc);
MacroAssembler masm(&cbuf);
masm.get_thread(pollReg);
masm.movl(pollReg, Address(pollReg, in_bytes(Thread::polling_page_offset())));
masm.relocate(relocInfo::poll_return_type);
masm.testl(rax, Address(pollReg, 0));
__ get_thread(thread);
Label dummy_label;
Label* code_stub = &dummy_label;
if (!C->output()->in_scratch_emit_size()) {
code_stub = &C->output()->safepoint_poll_table()->add_safepoint(__ offset());
}
__ relocate(relocInfo::poll_return_type);
__ safepoint_poll(*code_stub, thread, true /* at_return */, true /* in_nmethod */);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/x86_64.ad
Expand Up @@ -930,8 +930,8 @@ void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const
st->print_cr("popq rbp");
if (do_polling() && C->is_method_compilation()) {
st->print("\t");
st->print_cr("cmpq poll_offset[r15_thread], rsp\n\t"
"ja #safepoint_stub\t"
st->print_cr("cmpq rsp, poll_offset[r15_thread] \n\t"
"ja #safepoint_stub\t"
"# Safepoint: poll for GC");
}
}
Expand Down

0 comments on commit 21b5bdb

Please sign in to comment.