940 } 941 942 st->print_cr("popq rbp"); 943 if (do_polling() && C->is_method_compilation()) { 944 st->print("\t"); 945 if (Assembler::is_polling_page_far()) { 946 st->print_cr("movq rscratch1, #polling_page_address\n\t" 947 "testl rax, [rscratch1]\t" 948 "# Safepoint: poll for GC"); 949 } else { 950 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t" 951 "# Safepoint: poll for GC"); 952 } 953 } 954 } 955 #endif 956 957 void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const 958 { 959 Compile* C = ra_->C; 960 if (C->max_vector_size() > 16) { 961 // Clear upper bits of YMM registers when current compiled code uses 962 // wide vectors to avoid AVX <-> SSE transition penalty during call. 963 MacroAssembler _masm(&cbuf); 964 __ vzeroupper(); 965 } 966 967 int framesize = C->frame_size_in_bytes(); 968 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); 969 // Remove word for return adr already pushed 970 // and RBP 971 framesize -= 2*wordSize; 972 973 // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here 974 975 if (framesize) { 976 emit_opcode(cbuf, Assembler::REX_W); 977 if (framesize < 0x80) { 978 emit_opcode(cbuf, 0x83); // addq rsp, #framesize 979 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 980 emit_d8(cbuf, framesize); 981 } else { 982 emit_opcode(cbuf, 0x81); // addq rsp, #framesize 983 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 984 emit_d32(cbuf, framesize); 985 } 986 } 987 988 // popq rbp 989 emit_opcode(cbuf, 0x58 | RBP_enc); 990 991 if (do_polling() && C->is_method_compilation()) { 992 MacroAssembler _masm(&cbuf); 993 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); 994 if (Assembler::is_polling_page_far()) { 995 __ lea(rscratch1, polling_page); 996 __ relocate(relocInfo::poll_return_type); 997 __ testl(rax, Address(rscratch1, 0)); 998 } else { 999 __ testl(rax, polling_page); 1000 } 1001 } 1002 } 1003 1004 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const 1005 { 1006 return MachNode::size(ra_); // too many variables; just compute it 1007 // the hard way 1008 } 1009 1010 int MachEpilogNode::reloc() const | 940 } 941 942 st->print_cr("popq rbp"); 943 if (do_polling() && C->is_method_compilation()) { 944 st->print("\t"); 945 if (Assembler::is_polling_page_far()) { 946 st->print_cr("movq rscratch1, #polling_page_address\n\t" 947 "testl rax, [rscratch1]\t" 948 "# Safepoint: poll for GC"); 949 } else { 950 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t" 951 "# Safepoint: poll for GC"); 952 } 953 } 954 } 955 #endif 956 957 void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const 958 { 959 Compile* C = ra_->C; 960 MacroAssembler _masm(&cbuf); 961 962 if (C->max_vector_size() > 16) { 963 // Clear upper bits of YMM registers when current compiled code uses 964 // wide vectors to avoid AVX <-> SSE transition penalty during call. 965 MacroAssembler _masm(&cbuf); 966 __ vzeroupper(); 967 } 968 969 int framesize = C->frame_size_in_bytes(); 970 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); 971 // Remove word for return adr already pushed 972 // and RBP 973 framesize -= 2*wordSize; 974 975 // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here 976 977 if (framesize) { 978 emit_opcode(cbuf, Assembler::REX_W); 979 if (framesize < 0x80) { 980 emit_opcode(cbuf, 0x83); // addq rsp, #framesize 981 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 982 emit_d8(cbuf, framesize); 983 } else { 984 emit_opcode(cbuf, 0x81); // addq rsp, #framesize 985 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 986 emit_d32(cbuf, framesize); 987 } 988 } 989 990 // popq rbp 991 emit_opcode(cbuf, 0x58 | RBP_enc); 992 993 if (StackReservedPages > 0 && C->has_reserved_stack_access()) { 994 __ reserved_stack_check(); 995 } 996 997 if (do_polling() && C->is_method_compilation()) { 998 MacroAssembler _masm(&cbuf); 999 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); 1000 if (Assembler::is_polling_page_far()) { 1001 __ lea(rscratch1, polling_page); 1002 __ relocate(relocInfo::poll_return_type); 1003 __ testl(rax, Address(rscratch1, 0)); 1004 } else { 1005 __ testl(rax, polling_page); 1006 } 1007 } 1008 } 1009 1010 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const 1011 { 1012 return MachNode::size(ra_); // too many variables; just compute it 1013 // the hard way 1014 } 1015 1016 int MachEpilogNode::reloc() const |