315 reg_class ptr_rsp_reg(RSP, RSP_H); |
315 reg_class ptr_rsp_reg(RSP, RSP_H); |
316 |
316 |
317 // Singleton class for TLS pointer |
317 // Singleton class for TLS pointer |
318 reg_class ptr_r15_reg(R15, R15_H); |
318 reg_class ptr_r15_reg(R15, R15_H); |
319 |
319 |
|
320 // The registers which can be used for |
|
321 // a thread local safepoint poll |
|
322 // * R12 is reserved for heap base |
|
323 // * R13 cannot be encoded for addressing without an offset byte |
|
324 // * R15 is reserved for the JavaThread |
|
325 reg_class ptr_rex_reg(R8, R8_H, |
|
326 R9, R9_H, |
|
327 R10, R10_H, |
|
328 R11, R11_H, |
|
329 R14, R14_H); |
|
330 |
|
331 |
320 // Class for all long registers (excluding RSP) |
332 // Class for all long registers (excluding RSP) |
321 reg_class long_reg_with_rbp(RAX, RAX_H, |
333 reg_class long_reg_with_rbp(RAX, RAX_H, |
322 RDX, RDX_H, |
334 RDX, RDX_H, |
323 RBP, RBP_H, |
335 RBP, RBP_H, |
324 RDI, RDI_H, |
336 RDI, RDI_H, |
564 |
576 |
565 // Indicate if the safepoint node needs the polling page as an input, |
577 // Indicate if the safepoint node needs the polling page as an input, |
566 // it does if the polling page is more than disp32 away. |
578 // it does if the polling page is more than disp32 away. |
567 bool SafePointNode::needs_polling_address_input() |
579 bool SafePointNode::needs_polling_address_input() |
568 { |
580 { |
569 return Assembler::is_polling_page_far(); |
581 return SafepointMechanism::uses_thread_local_poll() || Assembler::is_polling_page_far(); |
570 } |
582 } |
571 |
583 |
572 // |
584 // |
573 // Compute padding required for nodes which need alignment |
585 // Compute padding required for nodes which need alignment |
574 // |
586 // |
936 } |
948 } |
937 |
949 |
938 st->print_cr("popq rbp"); |
950 st->print_cr("popq rbp"); |
939 if (do_polling() && C->is_method_compilation()) { |
951 if (do_polling() && C->is_method_compilation()) { |
940 st->print("\t"); |
952 st->print("\t"); |
941 if (Assembler::is_polling_page_far()) { |
953 if (SafepointMechanism::uses_thread_local_poll()) { |
|
954 st->print_cr("movq rscratch1, poll_offset[r15_thread] #polling_page_address\n\t" |
|
955 "testl rax, [rscratch1]\t" |
|
956 "# Safepoint: poll for GC"); |
|
957 } else if (Assembler::is_polling_page_far()) { |
942 st->print_cr("movq rscratch1, #polling_page_address\n\t" |
958 st->print_cr("movq rscratch1, #polling_page_address\n\t" |
943 "testl rax, [rscratch1]\t" |
959 "testl rax, [rscratch1]\t" |
944 "# Safepoint: poll for GC"); |
960 "# Safepoint: poll for GC"); |
945 } else { |
961 } else { |
946 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t" |
962 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t" |
987 __ reserved_stack_check(); |
1003 __ reserved_stack_check(); |
988 } |
1004 } |
989 |
1005 |
990 if (do_polling() && C->is_method_compilation()) { |
1006 if (do_polling() && C->is_method_compilation()) { |
991 MacroAssembler _masm(&cbuf); |
1007 MacroAssembler _masm(&cbuf); |
992 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); |
1008 if (SafepointMechanism::uses_thread_local_poll()) { |
993 if (Assembler::is_polling_page_far()) { |
1009 __ movq(rscratch1, Address(r15_thread, Thread::polling_page_offset())); |
994 __ lea(rscratch1, polling_page); |
|
995 __ relocate(relocInfo::poll_return_type); |
1010 __ relocate(relocInfo::poll_return_type); |
996 __ testl(rax, Address(rscratch1, 0)); |
1011 __ testl(rax, Address(rscratch1, 0)); |
997 } else { |
1012 } else { |
998 __ testl(rax, polling_page); |
1013 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); |
|
1014 if (Assembler::is_polling_page_far()) { |
|
1015 __ lea(rscratch1, polling_page); |
|
1016 __ relocate(relocInfo::poll_return_type); |
|
1017 __ testl(rax, Address(rscratch1, 0)); |
|
1018 } else { |
|
1019 __ testl(rax, polling_page); |
|
1020 } |
999 } |
1021 } |
1000 } |
1022 } |
1001 } |
1023 } |
1002 |
1024 |
1003 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const |
1025 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const |
12058 |
12090 |
12059 // ============================================================================ |
12091 // ============================================================================ |
12060 // Safepoint Instructions |
12092 // Safepoint Instructions |
12061 instruct safePoint_poll(rFlagsReg cr) |
12093 instruct safePoint_poll(rFlagsReg cr) |
12062 %{ |
12094 %{ |
12063 predicate(!Assembler::is_polling_page_far()); |
12095 predicate(!Assembler::is_polling_page_far() && SafepointMechanism::uses_global_page_poll()); |
12064 match(SafePoint); |
12096 match(SafePoint); |
12065 effect(KILL cr); |
12097 effect(KILL cr); |
12066 |
12098 |
12067 format %{ "testl rax, [rip + #offset_to_poll_page]\t" |
12099 format %{ "testl rax, [rip + #offset_to_poll_page]\t" |
12068 "# Safepoint: poll for GC" %} |
12100 "# Safepoint: poll for GC" %} |
12074 ins_pipe(ialu_reg_mem); |
12106 ins_pipe(ialu_reg_mem); |
12075 %} |
12107 %} |
12076 |
12108 |
12077 instruct safePoint_poll_far(rFlagsReg cr, rRegP poll) |
12109 instruct safePoint_poll_far(rFlagsReg cr, rRegP poll) |
12078 %{ |
12110 %{ |
12079 predicate(Assembler::is_polling_page_far()); |
12111 predicate(Assembler::is_polling_page_far() && SafepointMechanism::uses_global_page_poll()); |
12080 match(SafePoint poll); |
12112 match(SafePoint poll); |
12081 effect(KILL cr, USE poll); |
12113 effect(KILL cr, USE poll); |
12082 |
12114 |
12083 format %{ "testl rax, [$poll]\t" |
12115 format %{ "testl rax, [$poll]\t" |
12084 "# Safepoint: poll for GC" %} |
12116 "# Safepoint: poll for GC" %} |
12085 ins_cost(125); |
12117 ins_cost(125); |
12086 ins_encode %{ |
12118 ins_encode %{ |
12087 __ relocate(relocInfo::poll_type); |
12119 __ relocate(relocInfo::poll_type); |
12088 __ testl(rax, Address($poll$$Register, 0)); |
12120 __ testl(rax, Address($poll$$Register, 0)); |
|
12121 %} |
|
12122 ins_pipe(ialu_reg_mem); |
|
12123 %} |
|
12124 |
|
12125 instruct safePoint_poll_tls(rFlagsReg cr, rex_RegP poll) |
|
12126 %{ |
|
12127 predicate(SafepointMechanism::uses_thread_local_poll()); |
|
12128 match(SafePoint poll); |
|
12129 effect(KILL cr, USE poll); |
|
12130 |
|
12131 format %{ "testl rax, [$poll]\t" |
|
12132 "# Safepoint: poll for GC" %} |
|
12133 ins_cost(125); |
|
12134 size(3); /* setting an explicit size will cause debug builds to assert if size is incorrect */ |
|
12135 ins_encode %{ |
|
12136 __ relocate(relocInfo::poll_type); |
|
12137 address pre_pc = __ pc(); |
|
12138 __ testl(rax, Address($poll$$Register, 0)); |
|
12139 address post_pc = __ pc(); |
|
12140 guarantee(pre_pc[0] == 0x41 && pre_pc[1] == 0x85, "must emit #rex test-ax [reg]"); |
12089 %} |
12141 %} |
12090 ins_pipe(ialu_reg_mem); |
12142 ins_pipe(ialu_reg_mem); |
12091 %} |
12143 %} |
12092 |
12144 |
12093 // ============================================================================ |
12145 // ============================================================================ |