Skip to content

Commit 134e22a

Browse files
committed
8255606: Enable concurrent stack processing on x86_32 platforms
Reviewed-by: shade, rkennke, eosterlund
1 parent ca216ba commit 134e22a

File tree

7 files changed

+49
-29
lines changed

7 files changed

+49
-29
lines changed

src/hotspot/cpu/x86/c1_CodeStubs_x86.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,29 @@ void ConversionStub::emit_code(LIR_Assembler* ce) {
8080
#endif // !_LP64
8181

8282
void C1SafepointPollStub::emit_code(LIR_Assembler* ce) {
83-
#ifdef _LP64
8483
__ bind(_entry);
8584
InternalAddress safepoint_pc(ce->masm()->pc() - ce->masm()->offset() + safepoint_offset());
85+
#ifdef _LP64
8686
__ lea(rscratch1, safepoint_pc);
8787
__ movptr(Address(r15_thread, JavaThread::saved_exception_pc_offset()), rscratch1);
88+
#else
89+
const Register tmp1 = rcx;
90+
const Register tmp2 = rdx;
91+
__ push(tmp1);
92+
__ push(tmp2);
93+
94+
__ lea(tmp1, safepoint_pc);
95+
__ get_thread(tmp2);
96+
__ movptr(Address(tmp2, JavaThread::saved_exception_pc_offset()), tmp1);
8897

98+
__ pop(tmp2);
99+
__ pop(tmp1);
100+
#endif /* _LP64 */
89101
assert(SharedRuntime::polling_page_return_handler_blob() != NULL,
90102
"polling page return stub not created yet");
103+
91104
address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
92105
__ jump(RuntimeAddress(stub));
93-
#else
94-
ShouldNotReachHere();
95-
#endif /* _LP64 */
96106
}
97107

98108
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {

src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,17 +535,14 @@ void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
535535
// the poll sets the condition code, but no data registers
536536

537537
#ifdef _LP64
538-
code_stub->set_safepoint_offset(__ offset());
539-
__ relocate(relocInfo::poll_return_type);
540-
__ safepoint_poll(*code_stub->entry(), r15_thread, true /* at_return */, true /* in_nmethod */);
538+
const Register thread = r15_thread;
541539
#else
542-
const Register poll_addr = rbx;
543-
assert(FrameMap::is_caller_save_register(poll_addr), "will overwrite");
544-
__ get_thread(poll_addr);
545-
__ movptr(poll_addr, Address(poll_addr, Thread::polling_page_offset()));
546-
__ relocate(relocInfo::poll_return_type);
547-
__ testl(rax, Address(poll_addr, 0));
540+
const Register thread = rbx;
541+
__ get_thread(thread);
548542
#endif
543+
code_stub->set_safepoint_offset(__ offset());
544+
__ relocate(relocInfo::poll_return_type);
545+
__ safepoint_poll(*code_stub->entry(), thread, true /* at_return */, true /* in_nmethod */);
549546
__ ret(0);
550547
}
551548

src/hotspot/cpu/x86/c2_safepointPollStubTable_x86.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

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

4140
__ bind(entry->_stub_label);
4241
InternalAddress safepoint_pc(masm.pc() - masm.offset() + entry->_safepoint_offset);
42+
#ifdef _LP64
4343
__ lea(rscratch1, safepoint_pc);
4444
__ movptr(Address(r15_thread, JavaThread::saved_exception_pc_offset()), rscratch1);
45-
__ jump(callback_addr);
4645
#else
47-
ShouldNotReachHere();
46+
const Register tmp1 = rcx;
47+
const Register tmp2 = rdx;
48+
__ push(tmp1);
49+
__ push(tmp2);
50+
51+
__ lea(tmp1, safepoint_pc);
52+
__ get_thread(tmp2);
53+
__ movptr(Address(tmp2, JavaThread::saved_exception_pc_offset()), tmp1);
54+
55+
__ pop(tmp2);
56+
__ pop(tmp1);
4857
#endif
58+
__ jump(callback_addr);
4959
}
5060
#undef __

src/hotspot/cpu/x86/macroAssembler_x86.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,15 +2761,13 @@ void MacroAssembler::save_rax(Register tmp) {
27612761
}
27622762

27632763
void MacroAssembler::safepoint_poll(Label& slow_path, Register thread_reg, bool at_return, bool in_nmethod) {
2764-
#ifdef _LP64
27652764
if (at_return) {
27662765
// Note that when in_nmethod is set, the stack pointer is incremented before the poll. Therefore,
27672766
// we may safely use rsp instead to perform the stack watermark check.
2768-
cmpq(in_nmethod ? rsp : rbp, Address(thread_reg, Thread::polling_word_offset()));
2767+
cmpptr(in_nmethod ? rsp : rbp, Address(thread_reg, Thread::polling_word_offset()));
27692768
jcc(Assembler::above, slow_path);
27702769
return;
27712770
}
2772-
#endif
27732771
testb(Address(thread_reg, Thread::polling_word_offset()), SafepointMechanism::poll_bit());
27742772
jcc(Assembler::notZero, slow_path); // handshake bit set implies poll
27752773
}

src/hotspot/cpu/x86/vm_version_x86.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ enum Extended_Family {
10231023
}
10241024

10251025
constexpr static bool supports_stack_watermark_barrier() {
1026-
return LP64_ONLY(true) NOT_LP64(false);
1026+
return true;
10271027
}
10281028

10291029
// there are several insns to force cache line sync to memory which

src/hotspot/cpu/x86/x86_32.ad

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,9 @@ void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
653653
}
654654
st->print_cr("POPL EBP"); st->print("\t");
655655
if (do_polling() && C->is_method_compilation()) {
656-
st->print("TEST PollPage,EAX\t! Poll Safepoint");
657-
st->cr(); st->print("\t");
656+
st->print("CMPL rsp, poll_offset[thread] \n\t"
657+
"JA #safepoint_stub\t"
658+
"# Safepoint: poll for GC");
658659
}
659660
}
660661
#endif
@@ -697,12 +698,16 @@ void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
697698
}
698699

699700
if (do_polling() && C->is_method_compilation()) {
700-
Register pollReg = as_Register(EBX_enc);
701+
Register thread = as_Register(EBX_enc);
701702
MacroAssembler masm(&cbuf);
702-
masm.get_thread(pollReg);
703-
masm.movl(pollReg, Address(pollReg, in_bytes(Thread::polling_page_offset())));
704-
masm.relocate(relocInfo::poll_return_type);
705-
masm.testl(rax, Address(pollReg, 0));
703+
__ get_thread(thread);
704+
Label dummy_label;
705+
Label* code_stub = &dummy_label;
706+
if (!C->output()->in_scratch_emit_size()) {
707+
code_stub = &C->output()->safepoint_poll_table()->add_safepoint(__ offset());
708+
}
709+
__ relocate(relocInfo::poll_return_type);
710+
__ safepoint_poll(*code_stub, thread, true /* at_return */, true /* in_nmethod */);
706711
}
707712
}
708713

src/hotspot/cpu/x86/x86_64.ad

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,8 @@ void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const
930930
st->print_cr("popq rbp");
931931
if (do_polling() && C->is_method_compilation()) {
932932
st->print("\t");
933-
st->print_cr("cmpq poll_offset[r15_thread], rsp\n\t"
934-
"ja #safepoint_stub\t"
933+
st->print_cr("cmpq rsp, poll_offset[r15_thread] \n\t"
934+
"ja #safepoint_stub\t"
935935
"# Safepoint: poll for GC");
936936
}
937937
}

0 commit comments

Comments
 (0)