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 __ vzeroupper();
966 }
967
968 int framesize = C->frame_size_in_bytes();
969 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
970 // Remove word for return adr already pushed
971 // and RBP
972 framesize -= 2*wordSize;
973
974 // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here
975
976 if (framesize) {
977 emit_opcode(cbuf, Assembler::REX_W);
978 if (framesize < 0x80) {
979 emit_opcode(cbuf, 0x83); // addq rsp, #framesize
980 emit_rm(cbuf, 0x3, 0x00, RSP_enc);
981 emit_d8(cbuf, framesize);
982 } else {
983 emit_opcode(cbuf, 0x81); // addq rsp, #framesize
984 emit_rm(cbuf, 0x3, 0x00, RSP_enc);
985 emit_d32(cbuf, framesize);
986 }
987 }
988
989 // popq rbp
990 emit_opcode(cbuf, 0x58 | RBP_enc);
991
992 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
993 __ reserved_stack_check();
994 }
995
996 if (do_polling() && C->is_method_compilation()) {
997 MacroAssembler _masm(&cbuf);
998 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
999 if (Assembler::is_polling_page_far()) {
1000 __ lea(rscratch1, polling_page);
1001 __ relocate(relocInfo::poll_return_type);
1002 __ testl(rax, Address(rscratch1, 0));
1003 } else {
1004 __ testl(rax, polling_page);
1005 }
1006 }
1007 }
1008
1009 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const
1010 {
1011 return MachNode::size(ra_); // too many variables; just compute it
1012 // the hard way
1013 }
1014
1015 int MachEpilogNode::reloc() const
|