@@ -609,6 +609,12 @@ int MachCallRuntimeNode::ret_addr_offset() {
609609 }
610610 return offset;
611611}
612+
613+ int MachSafePointNode::ret_addr_offset() {
614+ // Size of mov rax, [thread, #polling_page_offset]
615+ return 4;
616+ }
617+
612618//
613619// Compute padding required for nodes which need alignment
614620//
@@ -12385,18 +12391,21 @@ instruct cmpFastUnlockLightweight(rFlagsReg cr, rRegP object, rax_RegP rax_reg,
1238512391
1238612392// ============================================================================
1238712393// Safepoint Instructions
12388- instruct safePoint_poll_tls(rFlagsReg cr, rRegP poll)
12394+ // Note: MachSafePointNode::ret_addr_offset() should match this encoding.
12395+ // The return would happen to safepoint poll itself, not to polling page load.
12396+ instruct safePoint_poll_tls(rax_RegP rax_reg, rFlagsReg cr)
1238912397%{
12390- match(SafePoint poll );
12391- effect(KILL cr, USE poll );
12398+ match(SafePoint);
12399+ effect(KILL cr, KILL rax_reg );
1239212400
12393- format %{ "testl rax, [$poll] \t"
12394- "# Safepoint: poll for GC" %}
12401+ format %{ "mov rax, [thread, #polling_page_offset]\n \t"
12402+ "testl rax, [rax]\t # Safepoint: poll for GC" %}
1239512403 ins_cost(125);
1239612404 ins_encode %{
12405+ __ movptr(rax, Address(r15_thread, JavaThread::polling_page_offset()));
1239712406 __ relocate(relocInfo::poll_type);
1239812407 address pre_pc = __ pc();
12399- __ testl(rax, Address($poll$$Register , 0));
12408+ __ testl(rax, Address(rax , 0));
1240012409 assert(nativeInstruction_at(pre_pc)->is_safepoint_poll(), "must emit test %%eax [reg]");
1240112410 %}
1240212411 ins_pipe(ialu_reg_mem);
0 commit comments