< prev index next >

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp

Print this page

 726 }
 727 
 728 static void pass_arg1(MacroAssembler* masm, Register arg) {
 729   if (c_rarg1 != arg ) {
 730     masm->mov(c_rarg1, arg);
 731   }
 732 }
 733 
 734 static void pass_arg2(MacroAssembler* masm, Register arg) {
 735   if (c_rarg2 != arg ) {
 736     masm->mov(c_rarg2, arg);
 737   }
 738 }
 739 
 740 static void pass_arg3(MacroAssembler* masm, Register arg) {
 741   if (c_rarg3 != arg ) {
 742     masm->mov(c_rarg3, arg);
 743   }
 744 }
 745 
 746 static bool is_preemptable(address entry_point) {
 747   return entry_point == CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter);
 748 }
 749 
 750 void MacroAssembler::call_VM_base(Register oop_result,
 751                                   Register java_thread,
 752                                   Register last_java_sp,

 753                                   address  entry_point,
 754                                   int      number_of_arguments,
 755                                   bool     check_exceptions) {
 756    // determine java_thread register
 757   if (!java_thread->is_valid()) {
 758     java_thread = rthread;
 759   }
 760 
 761   // determine last_java_sp register
 762   if (!last_java_sp->is_valid()) {
 763     last_java_sp = esp;
 764   }
 765 
 766   // debugging support
 767   assert(number_of_arguments >= 0   , "cannot have negative number of arguments");
 768   assert(java_thread == rthread, "unexpected register");
 769 #ifdef ASSERT
 770   // TraceBytecodes does not use r12 but saves it over the call, so don't verify
 771   // if ((UseCompressedOops || UseCompressedClassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?");
 772 #endif // ASSERT
 773 
 774   assert(java_thread != oop_result  , "cannot use the same register for java_thread & oop_result");
 775   assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
 776 
 777   // push java thread (becomes first argument of C function)
 778 
 779   mov(c_rarg0, java_thread);
 780 
 781   // set last Java frame before call
 782   assert(last_java_sp != rfp, "can't use rfp");
 783 
 784   Label l;
 785   if (is_preemptable(entry_point)) {
 786     // skip setting last_pc since we already set it to desired value.
 787     set_last_Java_frame(last_java_sp, rfp, noreg, rscratch1);
 788   } else {
 789     set_last_Java_frame(last_java_sp, rfp, l, rscratch1);
 790   }
 791 
 792   // do the call, remove parameters
 793   MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments, &l);
 794 
 795   // lr could be poisoned with PAC signature during throw_pending_exception
 796   // if it was tail-call optimized by compiler, since lr is not callee-saved
 797   // reload it with proper value
 798   adr(lr, l);
 799 
 800   // reset last Java frame
 801   // Only interpreter should have to clear fp
 802   reset_last_Java_frame(true);
 803 
 804    // C++ interp handles this in the interpreter
 805   check_and_handle_popframe(java_thread);
 806   check_and_handle_earlyret(java_thread);
 807 
 808   if (check_exceptions) {
 809     // check for pending exceptions (java_thread is set upon return)
 810     ldr(rscratch1, Address(java_thread, in_bytes(Thread::pending_exception_offset())));
 811     Label ok;
 812     cbz(rscratch1, ok);
 813     lea(rscratch1, RuntimeAddress(StubRoutines::forward_exception_entry()));
 814     br(rscratch1);
 815     bind(ok);
 816   }
 817 
 818   // get oop result if there is one and reset the value in the thread
 819   if (oop_result->is_valid()) {
 820     get_vm_result_oop(oop_result, java_thread);
 821   }
 822 }
 823 
 824 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
 825   call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
 826 }
 827 
 828 // Check the entry target is always reachable from any branch.
 829 static bool is_always_within_branch_range(Address entry) {
 830   if (AOTCodeCache::is_on_for_dump()) {
 831     return false;
 832   }
 833   const address target = entry.target();
 834 
 835   if (!CodeCache::contains(target)) {
 836     // We always use trampolines for callees outside CodeCache.
 837     assert(entry.rspec().type() == relocInfo::runtime_call_type, "non-runtime call of an external target");
 838     return false;
 839   }
 840 
 841   if (!MacroAssembler::far_branches()) {
 842     return true;
 843   }
 844 
 845   if (entry.rspec().type() == relocInfo::runtime_call_type) {

1063                              address entry_point,
1064                              Register arg_1,
1065                              Register arg_2,
1066                              Register arg_3,
1067                              bool check_exceptions) {
1068   assert_different_registers(arg_1, c_rarg2, c_rarg3);
1069   assert_different_registers(arg_2, c_rarg3);
1070   pass_arg3(this, arg_3);
1071 
1072   pass_arg2(this, arg_2);
1073 
1074   pass_arg1(this, arg_1);
1075   call_VM_helper(oop_result, entry_point, 3, check_exceptions);
1076 }
1077 
1078 void MacroAssembler::call_VM(Register oop_result,
1079                              Register last_java_sp,
1080                              address entry_point,
1081                              int number_of_arguments,
1082                              bool check_exceptions) {
1083   call_VM_base(oop_result, rthread, last_java_sp, entry_point, number_of_arguments, check_exceptions);
1084 }
1085 
1086 void MacroAssembler::call_VM(Register oop_result,
1087                              Register last_java_sp,
1088                              address entry_point,
1089                              Register arg_1,
1090                              bool check_exceptions) {
1091   pass_arg1(this, arg_1);
1092   call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
1093 }
1094 
1095 void MacroAssembler::call_VM(Register oop_result,
1096                              Register last_java_sp,
1097                              address entry_point,
1098                              Register arg_1,
1099                              Register arg_2,
1100                              bool check_exceptions) {
1101 
1102   assert_different_registers(arg_1, c_rarg2);
1103   pass_arg2(this, arg_2);

 726 }
 727 
 728 static void pass_arg1(MacroAssembler* masm, Register arg) {
 729   if (c_rarg1 != arg ) {
 730     masm->mov(c_rarg1, arg);
 731   }
 732 }
 733 
 734 static void pass_arg2(MacroAssembler* masm, Register arg) {
 735   if (c_rarg2 != arg ) {
 736     masm->mov(c_rarg2, arg);
 737   }
 738 }
 739 
 740 static void pass_arg3(MacroAssembler* masm, Register arg) {
 741   if (c_rarg3 != arg ) {
 742     masm->mov(c_rarg3, arg);
 743   }
 744 }
 745 




 746 void MacroAssembler::call_VM_base(Register oop_result,
 747                                   Register java_thread,
 748                                   Register last_java_sp,
 749                                   Label*   return_pc,
 750                                   address  entry_point,
 751                                   int      number_of_arguments,
 752                                   bool     check_exceptions) {
 753    // determine java_thread register
 754   if (!java_thread->is_valid()) {
 755     java_thread = rthread;
 756   }
 757 
 758   // determine last_java_sp register
 759   if (!last_java_sp->is_valid()) {
 760     last_java_sp = esp;
 761   }
 762 
 763   // debugging support
 764   assert(number_of_arguments >= 0   , "cannot have negative number of arguments");
 765   assert(java_thread == rthread, "unexpected register");
 766 #ifdef ASSERT
 767   // TraceBytecodes does not use r12 but saves it over the call, so don't verify
 768   // if ((UseCompressedOops || UseCompressedClassPointers) && !TraceBytecodes) verify_heapbase("call_VM_base: heap base corrupted?");
 769 #endif // ASSERT
 770 
 771   assert(java_thread != oop_result  , "cannot use the same register for java_thread & oop_result");
 772   assert(java_thread != last_java_sp, "cannot use the same register for java_thread & last_java_sp");
 773 
 774   // push java thread (becomes first argument of C function)
 775 
 776   mov(c_rarg0, java_thread);
 777 
 778   // set last Java frame before call
 779   assert(last_java_sp != rfp, "can't use rfp");
 780 
 781   Label l;
 782   set_last_Java_frame(last_java_sp, rfp, return_pc != nullptr ? *return_pc : l, rscratch1);





 783 
 784   // do the call, remove parameters
 785   MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments, &l);
 786 
 787   // lr could be poisoned with PAC signature during throw_pending_exception
 788   // if it was tail-call optimized by compiler, since lr is not callee-saved
 789   // reload it with proper value
 790   adr(lr, l);
 791 
 792   // reset last Java frame
 793   // Only interpreter should have to clear fp
 794   reset_last_Java_frame(true);
 795 
 796    // C++ interp handles this in the interpreter
 797   check_and_handle_popframe(java_thread);
 798   check_and_handle_earlyret(java_thread);
 799 
 800   if (check_exceptions) {
 801     // check for pending exceptions (java_thread is set upon return)
 802     ldr(rscratch1, Address(java_thread, in_bytes(Thread::pending_exception_offset())));
 803     Label ok;
 804     cbz(rscratch1, ok);
 805     lea(rscratch1, RuntimeAddress(StubRoutines::forward_exception_entry()));
 806     br(rscratch1);
 807     bind(ok);
 808   }
 809 
 810   // get oop result if there is one and reset the value in the thread
 811   if (oop_result->is_valid()) {
 812     get_vm_result_oop(oop_result, java_thread);
 813   }
 814 }
 815 
 816 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
 817   call_VM_base(oop_result, noreg, noreg, nullptr, entry_point, number_of_arguments, check_exceptions);
 818 }
 819 
 820 // Check the entry target is always reachable from any branch.
 821 static bool is_always_within_branch_range(Address entry) {
 822   if (AOTCodeCache::is_on_for_dump()) {
 823     return false;
 824   }
 825   const address target = entry.target();
 826 
 827   if (!CodeCache::contains(target)) {
 828     // We always use trampolines for callees outside CodeCache.
 829     assert(entry.rspec().type() == relocInfo::runtime_call_type, "non-runtime call of an external target");
 830     return false;
 831   }
 832 
 833   if (!MacroAssembler::far_branches()) {
 834     return true;
 835   }
 836 
 837   if (entry.rspec().type() == relocInfo::runtime_call_type) {

1055                              address entry_point,
1056                              Register arg_1,
1057                              Register arg_2,
1058                              Register arg_3,
1059                              bool check_exceptions) {
1060   assert_different_registers(arg_1, c_rarg2, c_rarg3);
1061   assert_different_registers(arg_2, c_rarg3);
1062   pass_arg3(this, arg_3);
1063 
1064   pass_arg2(this, arg_2);
1065 
1066   pass_arg1(this, arg_1);
1067   call_VM_helper(oop_result, entry_point, 3, check_exceptions);
1068 }
1069 
1070 void MacroAssembler::call_VM(Register oop_result,
1071                              Register last_java_sp,
1072                              address entry_point,
1073                              int number_of_arguments,
1074                              bool check_exceptions) {
1075   call_VM_base(oop_result, rthread, last_java_sp, nullptr, entry_point, number_of_arguments, check_exceptions);
1076 }
1077 
1078 void MacroAssembler::call_VM(Register oop_result,
1079                              Register last_java_sp,
1080                              address entry_point,
1081                              Register arg_1,
1082                              bool check_exceptions) {
1083   pass_arg1(this, arg_1);
1084   call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
1085 }
1086 
1087 void MacroAssembler::call_VM(Register oop_result,
1088                              Register last_java_sp,
1089                              address entry_point,
1090                              Register arg_1,
1091                              Register arg_2,
1092                              bool check_exceptions) {
1093 
1094   assert_different_registers(arg_1, c_rarg2);
1095   pass_arg2(this, arg_2);
< prev index next >