< prev index next >

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Print this page

  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  *
  25  */
  26 
  27 #include "precompiled.hpp"
  28 #include "asm/assembler.hpp"
  29 #include "asm/assembler.inline.hpp"
  30 #include "code/compiledIC.hpp"
  31 #include "compiler/disassembler.hpp"
  32 #include "gc/shared/barrierSet.hpp"
  33 #include "gc/shared/barrierSetAssembler.hpp"
  34 #include "gc/shared/cardTable.hpp"
  35 #include "gc/shared/cardTableBarrierSet.hpp"
  36 #include "gc/shared/collectedHeap.hpp"
  37 #include "interpreter/bytecodeHistogram.hpp"
  38 #include "interpreter/interpreter.hpp"

  39 #include "memory/resourceArea.hpp"
  40 #include "memory/universe.hpp"
  41 #include "oops/accessDecorators.hpp"
  42 #include "oops/compressedKlass.inline.hpp"
  43 #include "oops/compressedOops.inline.hpp"
  44 #include "oops/klass.inline.hpp"
  45 #include "oops/oop.hpp"
  46 #include "runtime/interfaceSupport.inline.hpp"
  47 #include "runtime/javaThread.hpp"
  48 #include "runtime/jniHandles.inline.hpp"
  49 #include "runtime/sharedRuntime.hpp"
  50 #include "runtime/stubRoutines.hpp"
  51 #include "utilities/globalDefinitions.hpp"
  52 #include "utilities/powerOfTwo.hpp"
  53 #ifdef COMPILER2
  54 #include "opto/compile.hpp"
  55 #include "opto/node.hpp"
  56 #include "opto/output.hpp"
  57 #endif
  58 

 209 }
 210 
 211 void MacroAssembler::push_cont_fastpath(Register java_thread) {
 212   if (!Continuations::enabled()) return;
 213   Label done;
 214   ld(t0, Address(java_thread, JavaThread::cont_fastpath_offset()));
 215   bleu(sp, t0, done);
 216   sd(sp, Address(java_thread, JavaThread::cont_fastpath_offset()));
 217   bind(done);
 218 }
 219 
 220 void MacroAssembler::pop_cont_fastpath(Register java_thread) {
 221   if (!Continuations::enabled()) return;
 222   Label done;
 223   ld(t0, Address(java_thread, JavaThread::cont_fastpath_offset()));
 224   bltu(sp, t0, done);
 225   sd(zr, Address(java_thread, JavaThread::cont_fastpath_offset()));
 226   bind(done);
 227 }
 228 






























 229 int MacroAssembler::align(int modulus, int extra_offset) {
 230   CompressibleRegion cr(this);
 231   intptr_t before = offset();
 232   while ((offset() + extra_offset) % modulus != 0) { nop(); }
 233   return (int)(offset() - before);
 234 }
 235 
 236 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
 237   call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
 238 }
 239 
 240 // Implementation of call_VM versions
 241 
 242 void MacroAssembler::call_VM(Register oop_result,
 243                              address entry_point,
 244                              bool check_exceptions) {
 245   call_VM_helper(oop_result, entry_point, 0, check_exceptions);
 246 }
 247 
 248 void MacroAssembler::call_VM(Register oop_result,

 751 }
 752 
 753 void MacroAssembler::emit_static_call_stub() {
 754   IncompressibleRegion ir(this);  // Fixed length: see CompiledDirectCall::to_interp_stub_size().
 755   // CompiledDirectCall::set_to_interpreted knows the
 756   // exact layout of this stub.
 757 
 758   mov_metadata(xmethod, (Metadata*)nullptr);
 759 
 760   // Jump to the entry point of the c2i stub.
 761   int32_t offset = 0;
 762   movptr(t0, 0, offset, t1); // lui + lui + slli + add
 763   jr(t0, offset);
 764 }
 765 
 766 void MacroAssembler::call_VM_leaf_base(address entry_point,
 767                                        int number_of_arguments,
 768                                        Label *retaddr) {
 769   int32_t offset = 0;
 770   push_reg(RegSet::of(t0, xmethod), sp);   // push << t0 & xmethod >> to sp

 771   mv(t0, entry_point, offset);
 772   jalr(t0, offset);
 773   if (retaddr != nullptr) {
 774     bind(*retaddr);
 775   }










 776   pop_reg(RegSet::of(t0, xmethod), sp);   // pop << t0 & xmethod >> from sp
 777 }
 778 
 779 void MacroAssembler::call_VM_leaf(address entry_point, int number_of_arguments) {
 780   call_VM_leaf_base(entry_point, number_of_arguments);
 781 }
 782 
 783 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0) {
 784   pass_arg0(this, arg_0);
 785   call_VM_leaf_base(entry_point, 1);
 786 }
 787 
 788 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0, Register arg_1) {
 789   assert_different_registers(arg_1, c_rarg0);
 790   pass_arg0(this, arg_0);
 791   pass_arg1(this, arg_1);
 792   call_VM_leaf_base(entry_point, 2);
 793 }
 794 
 795 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0,

  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  *
  25  */
  26 
  27 #include "precompiled.hpp"
  28 #include "asm/assembler.hpp"
  29 #include "asm/assembler.inline.hpp"
  30 #include "code/compiledIC.hpp"
  31 #include "compiler/disassembler.hpp"
  32 #include "gc/shared/barrierSet.hpp"
  33 #include "gc/shared/barrierSetAssembler.hpp"
  34 #include "gc/shared/cardTable.hpp"
  35 #include "gc/shared/cardTableBarrierSet.hpp"
  36 #include "gc/shared/collectedHeap.hpp"
  37 #include "interpreter/bytecodeHistogram.hpp"
  38 #include "interpreter/interpreter.hpp"
  39 #include "interpreter/interpreterRuntime.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "memory/universe.hpp"
  42 #include "oops/accessDecorators.hpp"
  43 #include "oops/compressedKlass.inline.hpp"
  44 #include "oops/compressedOops.inline.hpp"
  45 #include "oops/klass.inline.hpp"
  46 #include "oops/oop.hpp"
  47 #include "runtime/interfaceSupport.inline.hpp"
  48 #include "runtime/javaThread.hpp"
  49 #include "runtime/jniHandles.inline.hpp"
  50 #include "runtime/sharedRuntime.hpp"
  51 #include "runtime/stubRoutines.hpp"
  52 #include "utilities/globalDefinitions.hpp"
  53 #include "utilities/powerOfTwo.hpp"
  54 #ifdef COMPILER2
  55 #include "opto/compile.hpp"
  56 #include "opto/node.hpp"
  57 #include "opto/output.hpp"
  58 #endif
  59 

 210 }
 211 
 212 void MacroAssembler::push_cont_fastpath(Register java_thread) {
 213   if (!Continuations::enabled()) return;
 214   Label done;
 215   ld(t0, Address(java_thread, JavaThread::cont_fastpath_offset()));
 216   bleu(sp, t0, done);
 217   sd(sp, Address(java_thread, JavaThread::cont_fastpath_offset()));
 218   bind(done);
 219 }
 220 
 221 void MacroAssembler::pop_cont_fastpath(Register java_thread) {
 222   if (!Continuations::enabled()) return;
 223   Label done;
 224   ld(t0, Address(java_thread, JavaThread::cont_fastpath_offset()));
 225   bltu(sp, t0, done);
 226   sd(zr, Address(java_thread, JavaThread::cont_fastpath_offset()));
 227   bind(done);
 228 }
 229 
 230 void MacroAssembler::inc_held_monitor_count(Register tmp) {
 231   Address dst = Address(xthread, JavaThread::held_monitor_count_offset());
 232   ld(tmp, dst);
 233   addi(tmp, tmp, 1);
 234   sd(tmp, dst);
 235 #ifdef ASSERT
 236   Label ok;
 237   test_bit(tmp, tmp, 63);
 238   beqz(tmp, ok);
 239   STOP("assert(held monitor count overflow)");
 240   should_not_reach_here();
 241   bind(ok);
 242 #endif
 243 }
 244 
 245 void MacroAssembler::dec_held_monitor_count(Register tmp) {
 246   Address dst = Address(xthread, JavaThread::held_monitor_count_offset());
 247   ld(tmp, dst);
 248   addi(tmp, tmp, -1);
 249   sd(tmp, dst);
 250 #ifdef ASSERT
 251   Label ok;
 252   test_bit(tmp, tmp, 63);
 253   beqz(tmp, ok);
 254   STOP("assert(held monitor count underflow)");
 255   should_not_reach_here();
 256   bind(ok);
 257 #endif
 258 }
 259 
 260 int MacroAssembler::align(int modulus, int extra_offset) {
 261   CompressibleRegion cr(this);
 262   intptr_t before = offset();
 263   while ((offset() + extra_offset) % modulus != 0) { nop(); }
 264   return (int)(offset() - before);
 265 }
 266 
 267 void MacroAssembler::call_VM_helper(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
 268   call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
 269 }
 270 
 271 // Implementation of call_VM versions
 272 
 273 void MacroAssembler::call_VM(Register oop_result,
 274                              address entry_point,
 275                              bool check_exceptions) {
 276   call_VM_helper(oop_result, entry_point, 0, check_exceptions);
 277 }
 278 
 279 void MacroAssembler::call_VM(Register oop_result,

 782 }
 783 
 784 void MacroAssembler::emit_static_call_stub() {
 785   IncompressibleRegion ir(this);  // Fixed length: see CompiledDirectCall::to_interp_stub_size().
 786   // CompiledDirectCall::set_to_interpreted knows the
 787   // exact layout of this stub.
 788 
 789   mov_metadata(xmethod, (Metadata*)nullptr);
 790 
 791   // Jump to the entry point of the c2i stub.
 792   int32_t offset = 0;
 793   movptr(t0, 0, offset, t1); // lui + lui + slli + add
 794   jr(t0, offset);
 795 }
 796 
 797 void MacroAssembler::call_VM_leaf_base(address entry_point,
 798                                        int number_of_arguments,
 799                                        Label *retaddr) {
 800   int32_t offset = 0;
 801   push_reg(RegSet::of(t0, xmethod), sp);   // push << t0 & xmethod >> to sp
 802 
 803   mv(t0, entry_point, offset);
 804   jalr(t0, offset);
 805   if (retaddr != nullptr) {
 806     bind(*retaddr);
 807   }
 808 
 809   Label not_preempted;
 810   if (entry_point == CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter)) {
 811     ld(t0, Address(xthread, JavaThread::preempt_alternate_return_offset()));
 812     beqz(t0, not_preempted);
 813     sd(zr, Address(xthread, JavaThread::preempt_alternate_return_offset()));
 814     jr(t0);
 815   }
 816   bind(not_preempted);
 817 
 818   pop_reg(RegSet::of(t0, xmethod), sp);   // pop << t0 & xmethod >> from sp
 819 }
 820 
 821 void MacroAssembler::call_VM_leaf(address entry_point, int number_of_arguments) {
 822   call_VM_leaf_base(entry_point, number_of_arguments);
 823 }
 824 
 825 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0) {
 826   pass_arg0(this, arg_0);
 827   call_VM_leaf_base(entry_point, 1);
 828 }
 829 
 830 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0, Register arg_1) {
 831   assert_different_registers(arg_1, c_rarg0);
 832   pass_arg0(this, arg_0);
 833   pass_arg1(this, arg_1);
 834   call_VM_leaf_base(entry_point, 2);
 835 }
 836 
 837 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_0,
< prev index next >