< prev index next >

src/cpu/x86/vm/stubGenerator_x86_64.cpp

Print this page




 978   // Non-destructive plausibility checks for oops
 979   //
 980   // Arguments:
 981   //    all args on stack!
 982   //
 983   // Stack after saving c_rarg3:
 984   //    [tos + 0]: saved c_rarg3
 985   //    [tos + 1]: saved c_rarg2
 986   //    [tos + 2]: saved r12 (several TemplateTable methods use it)
 987   //    [tos + 3]: saved flags
 988   //    [tos + 4]: return address
 989   //  * [tos + 5]: error message (char*)
 990   //  * [tos + 6]: object to verify (oop)
 991   //  * [tos + 7]: saved rax - saved by caller and bashed
 992   //  * [tos + 8]: saved r10 (rscratch1) - saved by caller
 993   //  * = popped on exit
 994   address generate_verify_oop() {
 995     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 996     address start = __ pc();
 997 
 998     Label exit, error;
 999 
1000     __ pushf();
1001     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
1002 
1003     __ push(r12);
1004 
1005     // save c_rarg2 and c_rarg3
1006     __ push(c_rarg2);
1007     __ push(c_rarg3);
1008 
1009     enum {
1010            // After previous pushes.
1011            oop_to_verify = 6 * wordSize,
1012            saved_rax     = 7 * wordSize,
1013            saved_r10     = 8 * wordSize,
1014 
1015            // Before the call to MacroAssembler::debug(), see below.
1016            return_addr   = 16 * wordSize,
1017            error_msg     = 17 * wordSize
1018     };
1019 
1020     // get object
1021     __ movptr(rax, Address(rsp, oop_to_verify));
1022 
1023     // make sure object is 'reasonable'
1024     __ testptr(rax, rax);
1025     __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
1026     // Check if the oop is in the right area of memory
1027     __ movptr(c_rarg2, rax);
1028     __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_mask());
1029     __ andptr(c_rarg2, c_rarg3);
1030     __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_bits());
1031     __ cmpptr(c_rarg2, c_rarg3);
1032     __ jcc(Assembler::notZero, error);







1033 
1034     // set r12 to heapbase for load_klass()
1035     __ reinit_heapbase();
1036 
1037     // make sure klass is 'reasonable', which is not zero.
1038     __ load_klass(rax, rax);  // get klass
1039     __ testptr(rax, rax);
1040     __ jcc(Assembler::zero, error); // if klass is NULL it is broken
1041 
1042     // return if everything seems ok
1043     __ bind(exit);
1044     __ movptr(rax, Address(rsp, saved_rax));     // get saved rax back
1045     __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
1046     __ pop(c_rarg3);                             // restore c_rarg3
1047     __ pop(c_rarg2);                             // restore c_rarg2
1048     __ pop(r12);                                 // restore r12
1049     __ popf();                                   // restore flags
1050     __ ret(4 * wordSize);                        // pop caller saved stuff
1051 
1052     // handle errors




 978   // Non-destructive plausibility checks for oops
 979   //
 980   // Arguments:
 981   //    all args on stack!
 982   //
 983   // Stack after saving c_rarg3:
 984   //    [tos + 0]: saved c_rarg3
 985   //    [tos + 1]: saved c_rarg2
 986   //    [tos + 2]: saved r12 (several TemplateTable methods use it)
 987   //    [tos + 3]: saved flags
 988   //    [tos + 4]: return address
 989   //  * [tos + 5]: error message (char*)
 990   //  * [tos + 6]: object to verify (oop)
 991   //  * [tos + 7]: saved rax - saved by caller and bashed
 992   //  * [tos + 8]: saved r10 (rscratch1) - saved by caller
 993   //  * = popped on exit
 994   address generate_verify_oop() {
 995     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 996     address start = __ pc();
 997 
 998     Label exit, error, in_Java_heap;
 999 
1000     __ pushf();
1001     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));
1002 
1003     __ push(r12);
1004 
1005     // save c_rarg2 and c_rarg3
1006     __ push(c_rarg2);
1007     __ push(c_rarg3);
1008 
1009     enum {
1010            // After previous pushes.
1011            oop_to_verify = 6 * wordSize,
1012            saved_rax     = 7 * wordSize,
1013            saved_r10     = 8 * wordSize,
1014 
1015            // Before the call to MacroAssembler::debug(), see below.
1016            return_addr   = 16 * wordSize,
1017            error_msg     = 17 * wordSize
1018     };
1019 
1020     // get object
1021     __ movptr(rax, Address(rsp, oop_to_verify));
1022 
1023     // make sure object is 'reasonable'
1024     __ testptr(rax, rax);
1025     __ jcc(Assembler::zero, exit); // if obj is NULL it is OK
1026     // Check if the oop is in the right area of memory
1027     __ movptr(c_rarg2, rax);
1028     __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_mask());
1029     __ andptr(c_rarg2, c_rarg3);
1030     __ movptr(c_rarg3, (intptr_t) Universe::verify_oop_bits());
1031     __ cmpptr(c_rarg2, c_rarg3);
1032     __ jcc(Assembler::zero, in_Java_heap);
1033     // Not in Java heap, but could be valid if it's a bufferable value type
1034     __ load_klass(c_rarg2, rax);
1035     __ movbool(c_rarg2, Address(c_rarg2, InstanceKlass::extra_flags_offset()));
1036     __ andptr(c_rarg2, InstanceKlass::_extra_is_bufferable);
1037     __ testbool(c_rarg2);
1038     __ jcc(Assembler::zero, error);
1039     __ bind(in_Java_heap);
1040 
1041     // set r12 to heapbase for load_klass()
1042     __ reinit_heapbase();
1043 
1044     // make sure klass is 'reasonable', which is not zero.
1045     __ load_klass(rax, rax);  // get klass
1046     __ testptr(rax, rax);
1047     __ jcc(Assembler::zero, error); // if klass is NULL it is broken
1048 
1049     // return if everything seems ok
1050     __ bind(exit);
1051     __ movptr(rax, Address(rsp, saved_rax));     // get saved rax back
1052     __ movptr(rscratch1, Address(rsp, saved_r10)); // get saved r10 back
1053     __ pop(c_rarg3);                             // restore c_rarg3
1054     __ pop(c_rarg2);                             // restore c_rarg2
1055     __ pop(r12);                                 // restore r12
1056     __ popf();                                   // restore flags
1057     __ ret(4 * wordSize);                        // pop caller saved stuff
1058 
1059     // handle errors


< prev index next >