src/cpu/x86/vm/stubGenerator_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6689060 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/stubGenerator_x86_64.cpp

Print this page




 896     __ subq(rsp, frame::arg_reg_save_area_bytes);
 897     BLOCK_COMMENT("call handle_unsafe_access");
 898     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
 899     __ addq(rsp, frame::arg_reg_save_area_bytes);
 900 
 901     __ movq(next_pc, rax);            // stuff next address
 902     __ popaq();
 903     __ ret(0);                        // jump to next address
 904 
 905     return start;
 906   }
 907 
 908   // Non-destructive plausibility checks for oops
 909   //
 910   // Arguments:
 911   //    all args on stack!
 912   //
 913   // Stack after saving c_rarg3:
 914   //    [tos + 0]: saved c_rarg3
 915   //    [tos + 1]: saved c_rarg2
 916   //    [tos + 2]: saved flags
 917   //    [tos + 3]: return address
 918   //  * [tos + 4]: error message (char*)
 919   //  * [tos + 5]: object to verify (oop)
 920   //  * [tos + 6]: saved rax - saved by caller and bashed

 921   //  * = popped on exit
 922   address generate_verify_oop() {
 923     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 924     address start = __ pc();
 925 
 926     Label exit, error;
 927 
 928     __ pushfq();
 929     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
 930 


 931     // save c_rarg2 and c_rarg3
 932     __ pushq(c_rarg2);
 933     __ pushq(c_rarg3);
 934 










 935     // get object
 936     __ movq(rax, Address(rsp, 5 * wordSize));
 937 
 938     // make sure object is 'reasonable'
 939     __ testq(rax, rax);
 940     __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
 941     // Check if the oop is in the right area of memory
 942     __ movq(c_rarg2, rax);
 943     __ movptr(c_rarg3, (int64_t) Universe::verify_oop_mask());
 944     __ andq(c_rarg2, c_rarg3);
 945     __ movptr(c_rarg3, (int64_t) Universe::verify_oop_bits());
 946     __ cmpq(c_rarg2, c_rarg3);
 947     __ jcc(Assembler::notZero, error);
 948 



 949     // make sure klass is 'reasonable'
 950     __ load_klass(rax, rax);  // get klass
 951     __ testq(rax, rax);
 952     __ jcc(Assembler::zero, error); // if klass is NULL it is broken
 953     // Check if the klass is in the right area of memory
 954     __ movq(c_rarg2, rax);
 955     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
 956     __ andq(c_rarg2, c_rarg3);
 957     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
 958     __ cmpq(c_rarg2, c_rarg3);
 959     __ jcc(Assembler::notZero, error);
 960 
 961     // make sure klass' klass is 'reasonable'
 962     __ load_klass(rax, rax);
 963     __ testq(rax, rax);
 964     __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken
 965     // Check if the klass' klass is in the right area of memory
 966     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
 967     __ andq(rax, c_rarg3);
 968     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
 969     __ cmpq(rax, c_rarg3);
 970     __ jcc(Assembler::notZero, error);
 971 
 972     // return if everything seems ok
 973     __ bind(exit);
 974     __ movq(rax, Address(rsp, 6 * wordSize));    // get saved rax back
 975     __ popq(c_rarg3);                              // restore c_rarg3
 976     __ popq(c_rarg2);                              // restore c_rarg2

 977     __ popfq();                                  // restore flags
 978     __ ret(3 * wordSize);                        // pop caller saved stuff
 979 
 980     // handle errors
 981     __ bind(error);
 982     __ movq(rax, Address(rsp, 6 * wordSize));    // get saved rax back
 983     __ popq(c_rarg3);                              // get saved c_rarg3 back
 984     __ popq(c_rarg2);                              // get saved c_rarg2 back

 985     __ popfq();                                  // get saved flags off stack --
 986                                                  // will be ignored
 987 
 988     __ pushaq();                                 // push registers
 989                                                  // (rip is already
 990                                                  // already pushed)
 991     // debug(char* msg, int64_t regs[])
 992     // 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:
 994     //     [tos +  0] 16 saved registers
 995     //     [tos + 16] return address
 996     //     [tos + 17] error message (char*)



 997 
 998     __ movq(c_rarg0, Address(rsp, 17 * wordSize)); // pass address of error message
 999     __ movq(c_rarg1, rsp);                         // pass address of regs on stack

1000     __ movq(r12, rsp);                           // remember rsp
1001     __ subq(rsp, frame::arg_reg_save_area_bytes);// windows
1002     __ andq(rsp, -16);                           // align stack as required by ABI
1003     BLOCK_COMMENT("call MacroAssembler::debug");
1004     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
1005     __ movq(rsp, r12);                           // restore rsp
1006     __ reinit_heapbase();                        // r12 is heapbase
1007     __ popaq();                                  // pop registers
1008     __ ret(3 * wordSize);                        // pop caller saved stuff
1009 
1010     return start;
1011   }
1012 
1013   static address disjoint_byte_copy_entry;
1014   static address disjoint_short_copy_entry;
1015   static address disjoint_int_copy_entry;
1016   static address disjoint_long_copy_entry;
1017   static address disjoint_oop_copy_entry;
1018 
1019   static address byte_copy_entry;
1020   static address short_copy_entry;
1021   static address int_copy_entry;
1022   static address long_copy_entry;
1023   static address oop_copy_entry;
1024 
1025   static address checkcast_copy_entry;
1026 
1027   //
1028   // Verify that a register contains clean 32-bits positive value
1029   // (high 32-bits are 0) so it could be used in 64-bits shifts.
1030   //
1031   //  Input:
1032   //    Rint  -  32-bits value
1033   //    Rtmp  -  scratch
1034   //
1035   void assert_clean_int(Register Rint, Register Rtmp) {
1036 #ifdef ASSERT
1037     Label L;
1038     assert_different_registers(Rtmp, Rint);
1039     __ movslq(Rtmp, Rint);
1040     __ cmpq(Rtmp, Rint);
1041     __ jccb(Assembler::equal, L);
1042     __ stop("high 32-bits of int value are not 0");
1043     __ bind(L);
1044 #endif
1045   }
1046 
1047   //  Generate overlap test for array copy stubs
1048   //
1049   //  Input:
1050   //     c_rarg0 - from
1051   //     c_rarg1 - to
1052   //     c_rarg2 - element count
1053   //
1054   //  Output:
1055   //     rax   - &from[element count - 1]
1056   //
1057   void array_overlap_test(address no_overlap_target, Address::ScaleFactor sf) {
1058     assert(no_overlap_target != NULL, "must be generated");
1059     array_overlap_test(no_overlap_target, NULL, sf);
1060   }
1061   void array_overlap_test(Label& L_no_overlap, Address::ScaleFactor sf) {




 896     __ subq(rsp, frame::arg_reg_save_area_bytes);
 897     BLOCK_COMMENT("call handle_unsafe_access");
 898     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
 899     __ addq(rsp, frame::arg_reg_save_area_bytes);
 900 
 901     __ movq(next_pc, rax);            // stuff next address
 902     __ popaq();
 903     __ ret(0);                        // jump to next address
 904 
 905     return start;
 906   }
 907 
 908   // Non-destructive plausibility checks for oops
 909   //
 910   // Arguments:
 911   //    all args on stack!
 912   //
 913   // Stack after saving c_rarg3:
 914   //    [tos + 0]: saved c_rarg3
 915   //    [tos + 1]: saved c_rarg2
 916   //    [tos + 2]: saved r12 (several TemplateTable methods use it)
 917   //    [tos + 3]: saved flags
 918   //    [tos + 4]: return address
 919   //  * [tos + 5]: error message (char*)
 920   //  * [tos + 6]: object to verify (oop)
 921   //  * [tos + 7]: saved rax - saved by caller and bashed
 922   //  * = popped on exit
 923   address generate_verify_oop() {
 924     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 925     address start = __ pc();
 926 
 927     Label exit, error;
 928 
 929     __ pushfq();
 930     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
 931 
 932     __ pushq(r12);
 933 
 934     // save c_rarg2 and c_rarg3
 935     __ pushq(c_rarg2);
 936     __ pushq(c_rarg3);
 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 
 948     // get object
 949     __ movq(rax, Address(rsp, oop_to_verify));
 950 
 951     // make sure object is 'reasonable'
 952     __ testq(rax, rax);
 953     __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
 954     // Check if the oop is in the right area of memory
 955     __ movq(c_rarg2, rax);
 956     __ movptr(c_rarg3, (int64_t) Universe::verify_oop_mask());
 957     __ andq(c_rarg2, c_rarg3);
 958     __ movptr(c_rarg3, (int64_t) Universe::verify_oop_bits());
 959     __ cmpq(c_rarg2, c_rarg3);
 960     __ jcc(Assembler::notZero, error);
 961 
 962     // set r12 to heapbase for load_klass()
 963     __ reinit_heapbase();
 964 
 965     // make sure klass is 'reasonable'
 966     __ load_klass(rax, rax);  // get klass
 967     __ testq(rax, rax);
 968     __ jcc(Assembler::zero, error); // if klass is NULL it is broken
 969     // Check if the klass is in the right area of memory
 970     __ movq(c_rarg2, rax);
 971     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
 972     __ andq(c_rarg2, c_rarg3);
 973     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
 974     __ cmpq(c_rarg2, c_rarg3);
 975     __ jcc(Assembler::notZero, error);
 976 
 977     // make sure klass' klass is 'reasonable'
 978     __ load_klass(rax, rax);
 979     __ testq(rax, rax);
 980     __ jcc(Assembler::zero, error); // if klass' klass is NULL it is broken
 981     // Check if the klass' klass is in the right area of memory
 982     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_mask());
 983     __ andq(rax, c_rarg3);
 984     __ movptr(c_rarg3, (int64_t) Universe::verify_klass_bits());
 985     __ cmpq(rax, c_rarg3);
 986     __ jcc(Assembler::notZero, error);
 987 
 988     // return if everything seems ok
 989     __ bind(exit);
 990     __ movq(rax, Address(rsp, saved_rax));       // get saved rax back
 991     __ popq(c_rarg3);                            // restore c_rarg3
 992     __ popq(c_rarg2);                            // restore c_rarg2
 993     __ popq(r12);                                // restore r12
 994     __ popfq();                                  // restore flags
 995     __ ret(3 * wordSize);                        // pop caller saved stuff
 996 
 997     // handle errors
 998     __ bind(error);
 999     __ movq(rax, Address(rsp, saved_rax));       // get saved rax back
1000     __ popq(c_rarg3);                            // get saved c_rarg3 back
1001     __ popq(c_rarg2);                            // get saved c_rarg2 back
1002     __ popq(r12);                                // get saved r12 back
1003     __ popfq();                                  // get saved flags off stack --
1004                                                  // will be ignored
1005 
1006     __ pushaq();                                 // push registers
1007                                                  // (rip is already
1008                                                  // already pushed)
1009     // debug(char* msg, int64_t pc, int64_t regs[])
1010     // We've popped the registers we'd saved (c_rarg3, c_rarg2 and flags), and
1011     // pushed all the registers, so now the stack looks like:
1012     //     [tos +  0] 16 saved registers
1013     //     [tos + 16] return address
1014     //   * [tos + 17] error message (char*)
1015     //   * [tos + 18] object to verify (oop)
1016     //   * [tos + 19] saved rax - saved by caller and bashed
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
1022     __ movq(r12, rsp);                           // remember rsp
1023     __ subq(rsp, frame::arg_reg_save_area_bytes);// windows
1024     __ andq(rsp, -16);                           // align stack as required by ABI
1025     BLOCK_COMMENT("call MacroAssembler::debug");
1026     __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, MacroAssembler::debug)));
1027     __ movq(rsp, r12);                           // restore rsp
1028     __ popaq();                                  // pop registers (includes r12)

1029     __ ret(3 * wordSize);                        // pop caller saved stuff
1030 
1031     return start;
1032   }
1033 
1034   static address disjoint_byte_copy_entry;
1035   static address disjoint_short_copy_entry;
1036   static address disjoint_int_copy_entry;
1037   static address disjoint_long_copy_entry;
1038   static address disjoint_oop_copy_entry;
1039 
1040   static address byte_copy_entry;
1041   static address short_copy_entry;
1042   static address int_copy_entry;
1043   static address long_copy_entry;
1044   static address oop_copy_entry;
1045 
1046   static address checkcast_copy_entry;
1047 
1048   //
1049   // Verify that a register contains clean 32-bits positive value
1050   // (high 32-bits are 0) so it could be used in 64-bits shifts.
1051   //
1052   //  Input:
1053   //    Rint  -  32-bits value
1054   //    Rtmp  -  scratch
1055   //
1056   void assert_clean_int(Register Rint, Register Rtmp) {
1057 #ifdef ASSERT
1058     Label L;
1059     assert_different_registers(Rtmp, Rint);
1060     __ movslq(Rtmp, Rint);
1061     __ cmpq(Rtmp, Rint);
1062     __ jcc(Assembler::equal, L);
1063     __ stop("high 32-bits of int value are not 0");
1064     __ bind(L);
1065 #endif
1066   }
1067 
1068   //  Generate overlap test for array copy stubs
1069   //
1070   //  Input:
1071   //     c_rarg0 - from
1072   //     c_rarg1 - to
1073   //     c_rarg2 - element count
1074   //
1075   //  Output:
1076   //     rax   - &from[element count - 1]
1077   //
1078   void array_overlap_test(address no_overlap_target, Address::ScaleFactor sf) {
1079     assert(no_overlap_target != NULL, "must be generated");
1080     array_overlap_test(no_overlap_target, NULL, sf);
1081   }
1082   void array_overlap_test(Label& L_no_overlap, Address::ScaleFactor sf) {


src/cpu/x86/vm/stubGenerator_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File