824 jcc(Assembler::zero, done); 825 826 // Call the runtime routine for slow case. 827 movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), 828 obj_reg); // restore obj 829 call_VM(noreg, 830 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 831 lock_reg); 832 833 bind(done); 834 835 restore_bcp(); 836 } 837 } 838 839 #ifndef CC_INTERP 840 841 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, 842 Label& zero_continue) { 843 assert(ProfileInterpreter, "must be profiling interpreter"); 844 movptr(mdp, Address(rbp, frame::interpreter_frame_mdx_offset * wordSize)); 845 testptr(mdp, mdp); 846 jcc(Assembler::zero, zero_continue); 847 } 848 849 850 // Set the method data pointer for the current bcp. 851 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { 852 assert(ProfileInterpreter, "must be profiling interpreter"); 853 Label set_mdp; 854 push(rax); 855 push(rbx); 856 857 get_method(rbx); 858 // Test MDO to avoid the call if it is NULL. 859 movptr(rax, Address(rbx, in_bytes(Method::method_data_offset()))); 860 testptr(rax, rax); 861 jcc(Assembler::zero, set_mdp); 862 // rbx: method 863 // r13: bcp 864 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, r13); 865 // rax: mdi 866 // mdo is guaranteed to be non-zero here, we checked for it before the call. 867 movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset()))); 868 addptr(rbx, in_bytes(MethodData::data_offset())); 869 addptr(rax, rbx); 870 bind(set_mdp); 871 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), rax); 872 pop(rbx); 873 pop(rax); 874 } 875 876 void InterpreterMacroAssembler::verify_method_data_pointer() { 877 assert(ProfileInterpreter, "must be profiling interpreter"); 878 #ifdef ASSERT 879 Label verify_continue; 880 push(rax); 881 push(rbx); 882 push(c_rarg3); 883 push(c_rarg2); 884 test_method_data_pointer(c_rarg3, verify_continue); // If mdp is zero, continue 885 get_method(rbx); 886 887 // If the mdp is valid, it will point to a DataLayout header which is 888 // consistent with the bcp. The converse is highly probable also. 889 load_unsigned_short(c_rarg2, 890 Address(c_rarg3, in_bytes(DataLayout::bci_offset()))); 891 addptr(c_rarg2, Address(rbx, Method::const_offset())); 974 Register value, 975 Register test_value_out, 976 Label& not_equal_continue) { 977 assert(ProfileInterpreter, "must be profiling interpreter"); 978 if (test_value_out == noreg) { 979 cmpptr(value, Address(mdp_in, offset)); 980 } else { 981 // Put the test value into a register, so caller can use it: 982 movptr(test_value_out, Address(mdp_in, offset)); 983 cmpptr(test_value_out, value); 984 } 985 jcc(Assembler::notEqual, not_equal_continue); 986 } 987 988 989 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 990 int offset_of_disp) { 991 assert(ProfileInterpreter, "must be profiling interpreter"); 992 Address disp_address(mdp_in, offset_of_disp); 993 addptr(mdp_in, disp_address); 994 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); 995 } 996 997 998 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 999 Register reg, 1000 int offset_of_disp) { 1001 assert(ProfileInterpreter, "must be profiling interpreter"); 1002 Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp); 1003 addptr(mdp_in, disp_address); 1004 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); 1005 } 1006 1007 1008 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, 1009 int constant) { 1010 assert(ProfileInterpreter, "must be profiling interpreter"); 1011 addptr(mdp_in, constant); 1012 movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp_in); 1013 } 1014 1015 1016 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { 1017 assert(ProfileInterpreter, "must be profiling interpreter"); 1018 push(return_bci); // save/restore across call_VM 1019 call_VM(noreg, 1020 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), 1021 return_bci); 1022 pop(return_bci); 1023 } 1024 1025 1026 void InterpreterMacroAssembler::profile_taken_branch(Register mdp, 1027 Register bumped_count) { 1028 if (ProfileInterpreter) { 1029 Label profile_continue; 1030 1031 // If no method data exists, go to profile_continue. 1032 // Otherwise, assign to mdp | 824 jcc(Assembler::zero, done); 825 826 // Call the runtime routine for slow case. 827 movptr(Address(lock_reg, BasicObjectLock::obj_offset_in_bytes()), 828 obj_reg); // restore obj 829 call_VM(noreg, 830 CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorexit), 831 lock_reg); 832 833 bind(done); 834 835 restore_bcp(); 836 } 837 } 838 839 #ifndef CC_INTERP 840 841 void InterpreterMacroAssembler::test_method_data_pointer(Register mdp, 842 Label& zero_continue) { 843 assert(ProfileInterpreter, "must be profiling interpreter"); 844 movptr(mdp, Address(rbp, frame::interpreter_frame_mdp_offset * wordSize)); 845 testptr(mdp, mdp); 846 jcc(Assembler::zero, zero_continue); 847 } 848 849 850 // Set the method data pointer for the current bcp. 851 void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { 852 assert(ProfileInterpreter, "must be profiling interpreter"); 853 Label set_mdp; 854 push(rax); 855 push(rbx); 856 857 get_method(rbx); 858 // Test MDO to avoid the call if it is NULL. 859 movptr(rax, Address(rbx, in_bytes(Method::method_data_offset()))); 860 testptr(rax, rax); 861 jcc(Assembler::zero, set_mdp); 862 // rbx: method 863 // r13: bcp 864 call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::bcp_to_di), rbx, r13); 865 // rax: mdi 866 // mdo is guaranteed to be non-zero here, we checked for it before the call. 867 movptr(rbx, Address(rbx, in_bytes(Method::method_data_offset()))); 868 addptr(rbx, in_bytes(MethodData::data_offset())); 869 addptr(rax, rbx); 870 bind(set_mdp); 871 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), rax); 872 pop(rbx); 873 pop(rax); 874 } 875 876 void InterpreterMacroAssembler::verify_method_data_pointer() { 877 assert(ProfileInterpreter, "must be profiling interpreter"); 878 #ifdef ASSERT 879 Label verify_continue; 880 push(rax); 881 push(rbx); 882 push(c_rarg3); 883 push(c_rarg2); 884 test_method_data_pointer(c_rarg3, verify_continue); // If mdp is zero, continue 885 get_method(rbx); 886 887 // If the mdp is valid, it will point to a DataLayout header which is 888 // consistent with the bcp. The converse is highly probable also. 889 load_unsigned_short(c_rarg2, 890 Address(c_rarg3, in_bytes(DataLayout::bci_offset()))); 891 addptr(c_rarg2, Address(rbx, Method::const_offset())); 974 Register value, 975 Register test_value_out, 976 Label& not_equal_continue) { 977 assert(ProfileInterpreter, "must be profiling interpreter"); 978 if (test_value_out == noreg) { 979 cmpptr(value, Address(mdp_in, offset)); 980 } else { 981 // Put the test value into a register, so caller can use it: 982 movptr(test_value_out, Address(mdp_in, offset)); 983 cmpptr(test_value_out, value); 984 } 985 jcc(Assembler::notEqual, not_equal_continue); 986 } 987 988 989 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 990 int offset_of_disp) { 991 assert(ProfileInterpreter, "must be profiling interpreter"); 992 Address disp_address(mdp_in, offset_of_disp); 993 addptr(mdp_in, disp_address); 994 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); 995 } 996 997 998 void InterpreterMacroAssembler::update_mdp_by_offset(Register mdp_in, 999 Register reg, 1000 int offset_of_disp) { 1001 assert(ProfileInterpreter, "must be profiling interpreter"); 1002 Address disp_address(mdp_in, reg, Address::times_1, offset_of_disp); 1003 addptr(mdp_in, disp_address); 1004 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); 1005 } 1006 1007 1008 void InterpreterMacroAssembler::update_mdp_by_constant(Register mdp_in, 1009 int constant) { 1010 assert(ProfileInterpreter, "must be profiling interpreter"); 1011 addptr(mdp_in, constant); 1012 movptr(Address(rbp, frame::interpreter_frame_mdp_offset * wordSize), mdp_in); 1013 } 1014 1015 1016 void InterpreterMacroAssembler::update_mdp_for_ret(Register return_bci) { 1017 assert(ProfileInterpreter, "must be profiling interpreter"); 1018 push(return_bci); // save/restore across call_VM 1019 call_VM(noreg, 1020 CAST_FROM_FN_PTR(address, InterpreterRuntime::update_mdp_for_ret), 1021 return_bci); 1022 pop(return_bci); 1023 } 1024 1025 1026 void InterpreterMacroAssembler::profile_taken_branch(Register mdp, 1027 Register bumped_count) { 1028 if (ProfileInterpreter) { 1029 Label profile_continue; 1030 1031 // If no method data exists, go to profile_continue. 1032 // Otherwise, assign to mdp |