Mercurial > hg > truffle
comparison src/cpu/x86/vm/stubGenerator_x86_64.cpp @ 124:b130b98db9cf
6689060: Escape Analysis does not work with Compressed Oops
Summary: 64-bits VM crashes with -XX:+AggresiveOpts (Escape Analysis + Compressed Oops)
Reviewed-by: never, sgoldman
author | kvn |
---|---|
date | Wed, 23 Apr 2008 11:20:36 -0700 |
parents | ba764ed4b6f2 |
children | d1605aabd0a1 37f87013dfd8 |
comparison
equal
deleted
inserted
replaced
123:9e5a7340635e | 124:b130b98db9cf |
---|---|
911 // all args on stack! | 911 // all args on stack! |
912 // | 912 // |
913 // Stack after saving c_rarg3: | 913 // Stack after saving c_rarg3: |
914 // [tos + 0]: saved c_rarg3 | 914 // [tos + 0]: saved c_rarg3 |
915 // [tos + 1]: saved c_rarg2 | 915 // [tos + 1]: saved c_rarg2 |
916 // [tos + 2]: saved flags | 916 // [tos + 2]: saved r12 (several TemplateTable methods use it) |
917 // [tos + 3]: return address | 917 // [tos + 3]: saved flags |
918 // * [tos + 4]: error message (char*) | 918 // [tos + 4]: return address |
919 // * [tos + 5]: object to verify (oop) | 919 // * [tos + 5]: error message (char*) |
920 // * [tos + 6]: saved rax - saved by caller and bashed | 920 // * [tos + 6]: object to verify (oop) |
921 // * [tos + 7]: saved rax - saved by caller and bashed | |
921 // * = popped on exit | 922 // * = popped on exit |
922 address generate_verify_oop() { | 923 address generate_verify_oop() { |
923 StubCodeMark mark(this, "StubRoutines", "verify_oop"); | 924 StubCodeMark mark(this, "StubRoutines", "verify_oop"); |
924 address start = __ pc(); | 925 address start = __ pc(); |
925 | 926 |
926 Label exit, error; | 927 Label exit, error; |
927 | 928 |
928 __ pushfq(); | 929 __ pushfq(); |
929 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); | 930 __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr())); |
930 | 931 |
932 __ pushq(r12); | |
933 | |
931 // save c_rarg2 and c_rarg3 | 934 // save c_rarg2 and c_rarg3 |
932 __ pushq(c_rarg2); | 935 __ pushq(c_rarg2); |
933 __ pushq(c_rarg3); | 936 __ pushq(c_rarg3); |
934 | 937 |
938 enum { | |
939 // After previous pushes. | |
940 oop_to_verify = 6 * wordSize, | |
941 saved_rax = 7 * wordSize, | |
942 | |
943 // Before the call to MacroAssembler::debug(), see below. | |
944 return_addr = 16 * wordSize, | |
945 error_msg = 17 * wordSize | |
946 }; | |
947 | |
935 // get object | 948 // get object |
936 __ movq(rax, Address(rsp, 5 * wordSize)); | 949 __ movq(rax, Address(rsp, oop_to_verify)); |
937 | 950 |
938 // make sure object is 'reasonable' | 951 // make sure object is 'reasonable' |
939 __ testq(rax, rax); | 952 __ testq(rax, rax); |
940 __ jcc(Assembler::zero, exit); // if obj is NULL it is OK | 953 __ jcc(Assembler::zero, exit); // if obj is NULL it is OK |
941 // Check if the oop is in the right area of memory | 954 // Check if the oop is in the right area of memory |
943 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_mask()); | 956 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_mask()); |
944 __ andq(c_rarg2, c_rarg3); | 957 __ andq(c_rarg2, c_rarg3); |
945 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_bits()); | 958 __ movptr(c_rarg3, (int64_t) Universe::verify_oop_bits()); |
946 __ cmpq(c_rarg2, c_rarg3); | 959 __ cmpq(c_rarg2, c_rarg3); |
947 __ jcc(Assembler::notZero, error); | 960 __ jcc(Assembler::notZero, error); |
961 | |
962 // set r12 to heapbase for load_klass() | |
963 __ reinit_heapbase(); | |
948 | 964 |
949 // make sure klass is 'reasonable' | 965 // make sure klass is 'reasonable' |
950 __ load_klass(rax, rax); // get klass | 966 __ load_klass(rax, rax); // get klass |
951 __ testq(rax, rax); | 967 __ testq(rax, rax); |
952 __ jcc(Assembler::zero, error); // if klass is NULL it is broken | 968 __ jcc(Assembler::zero, error); // if klass is NULL it is broken |
969 __ cmpq(rax, c_rarg3); | 985 __ cmpq(rax, c_rarg3); |
970 __ jcc(Assembler::notZero, error); | 986 __ jcc(Assembler::notZero, error); |
971 | 987 |
972 // return if everything seems ok | 988 // return if everything seems ok |
973 __ bind(exit); | 989 __ bind(exit); |
974 __ movq(rax, Address(rsp, 6 * wordSize)); // get saved rax back | 990 __ movq(rax, Address(rsp, saved_rax)); // get saved rax back |
975 __ popq(c_rarg3); // restore c_rarg3 | 991 __ popq(c_rarg3); // restore c_rarg3 |
976 __ popq(c_rarg2); // restore c_rarg2 | 992 __ popq(c_rarg2); // restore c_rarg2 |
993 __ popq(r12); // restore r12 | |
977 __ popfq(); // restore flags | 994 __ popfq(); // restore flags |
978 __ ret(3 * wordSize); // pop caller saved stuff | 995 __ ret(3 * wordSize); // pop caller saved stuff |
979 | 996 |
980 // handle errors | 997 // handle errors |
981 __ bind(error); | 998 __ bind(error); |
982 __ movq(rax, Address(rsp, 6 * wordSize)); // get saved rax back | 999 __ movq(rax, Address(rsp, saved_rax)); // get saved rax back |
983 __ popq(c_rarg3); // get saved c_rarg3 back | 1000 __ popq(c_rarg3); // get saved c_rarg3 back |
984 __ popq(c_rarg2); // get saved c_rarg2 back | 1001 __ popq(c_rarg2); // get saved c_rarg2 back |
1002 __ popq(r12); // get saved r12 back | |
985 __ popfq(); // get saved flags off stack -- | 1003 __ popfq(); // get saved flags off stack -- |
986 // will be ignored | 1004 // will be ignored |
987 | 1005 |
988 __ pushaq(); // push registers | 1006 __ pushaq(); // push registers |
989 // (rip is already | 1007 // (rip is already |
990 // already pushed) | 1008 // already pushed) |
991 // debug(char* msg, int64_t regs[]) | 1009 // debug(char* msg, int64_t pc, int64_t regs[]) |
992 // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and | 1010 // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and |
993 // pushed all the registers, so now the stack looks like: | 1011 // pushed all the registers, so now the stack looks like: |
994 // [tos + 0] 16 saved registers | 1012 // [tos + 0] 16 saved registers |
995 // [tos + 16] return address | 1013 // [tos + 16] return address |
996 // [tos + 17] error message (char*) | 1014 // * [tos + 17] error message (char*) |
997 | 1015 // * [tos + 18] object to verify (oop) |
998 __ movq(c_rarg0, Address(rsp, 17 * wordSize)); // pass address of error message | 1016 // * [tos + 19] saved rax - saved by caller and bashed |
999 __ movq(c_rarg1, rsp); // pass address of regs on stack | 1017 // * = popped on exit |
1018 | |
1019 __ movq(c_rarg0, Address(rsp, error_msg)); // pass address of error message | |
1020 __ movq(c_rarg1, Address(rsp, return_addr)); // pass return address | |
1021 __ movq(c_rarg2, rsp); // pass address of regs on stack | |
1000 __ movq(r12, rsp); // remember rsp | 1022 __ movq(r12, rsp); // remember rsp |
1001 __ subq(rsp, frame::arg_reg_save_area_bytes);// windows | 1023 __ subq(rsp, frame::arg_reg_save_area_bytes);// windows |
1002 __ andq(rsp, -16); // align stack as required by ABI | 1024 __ andq(rsp, -16); // align stack as required by ABI |
1003 BLOCK_COMMENT("call MacroAssembler::debug"); | 1025 BLOCK_COMMENT("call MacroAssembler::debug"); |
1004 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug))); | 1026 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug))); |
1005 __ movq(rsp, r12); // restore rsp | 1027 __ movq(rsp, r12); // restore rsp |
1006 __ reinit_heapbase(); // r12 is heapbase | 1028 __ popaq(); // pop registers (includes r12) |
1007 __ popaq(); // pop registers | |
1008 __ ret(3 * wordSize); // pop caller saved stuff | 1029 __ ret(3 * wordSize); // pop caller saved stuff |
1009 | 1030 |
1010 return start; | 1031 return start; |
1011 } | 1032 } |
1012 | 1033 |
1036 #ifdef ASSERT | 1057 #ifdef ASSERT |
1037 Label L; | 1058 Label L; |
1038 assert_different_registers(Rtmp, Rint); | 1059 assert_different_registers(Rtmp, Rint); |
1039 __ movslq(Rtmp, Rint); | 1060 __ movslq(Rtmp, Rint); |
1040 __ cmpq(Rtmp, Rint); | 1061 __ cmpq(Rtmp, Rint); |
1041 __ jccb(Assembler::equal, L); | 1062 __ jcc(Assembler::equal, L); |
1042 __ stop("high 32-bits of int value are not 0"); | 1063 __ stop("high 32-bits of int value are not 0"); |
1043 __ bind(L); | 1064 __ bind(L); |
1044 #endif | 1065 #endif |
1045 } | 1066 } |
1046 | 1067 |