< prev index next >

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Print this page
@@ -34,10 +34,11 @@
  #include "gc/shared/cardTable.hpp"
  #include "gc/shared/cardTableBarrierSet.hpp"
  #include "gc/shared/collectedHeap.hpp"
  #include "interpreter/bytecodeHistogram.hpp"
  #include "interpreter/interpreter.hpp"
+ #include "interpreter/interpreterRuntime.hpp"
  #include "memory/resourceArea.hpp"
  #include "memory/universe.hpp"
  #include "oops/accessDecorators.hpp"
  #include "oops/compressedKlass.inline.hpp"
  #include "oops/compressedOops.inline.hpp"

@@ -224,10 +225,40 @@
    bltu(sp, t0, done);
    sd(zr, Address(java_thread, JavaThread::cont_fastpath_offset()));
    bind(done);
  }
  
+ void MacroAssembler::inc_held_monitor_count(Register tmp) {
+   Address dst = Address(xthread, JavaThread::held_monitor_count_offset());
+   ld(tmp, dst);
+   addi(tmp, tmp, 1);
+   sd(tmp, dst);
+ #ifdef ASSERT
+   Label ok;
+   test_bit(tmp, tmp, 63);
+   beqz(tmp, ok);
+   STOP("assert(held monitor count overflow)");
+   should_not_reach_here();
+   bind(ok);
+ #endif
+ }
+ 
+ void MacroAssembler::dec_held_monitor_count(Register tmp) {
+   Address dst = Address(xthread, JavaThread::held_monitor_count_offset());
+   ld(tmp, dst);
+   addi(tmp, tmp, -1);
+   sd(tmp, dst);
+ #ifdef ASSERT
+   Label ok;
+   test_bit(tmp, tmp, 63);
+   beqz(tmp, ok);
+   STOP("assert(held monitor count underflow)");
+   should_not_reach_here();
+   bind(ok);
+ #endif
+ }
+ 
  int MacroAssembler::align(int modulus, int extra_offset) {
    CompressibleRegion cr(this);
    intptr_t before = offset();
    while ((offset() + extra_offset) % modulus != 0) { nop(); }
    return (int)(offset() - before);

@@ -405,10 +436,14 @@
  
    // Always clear the pc because it could have been set by make_walkable()
    sd(zr, Address(xthread, JavaThread::last_Java_pc_offset()));
  }
  
+ static bool is_preemptable(address entry_point) {
+   return entry_point == CAST_FROM_FN_PTR(address, InterpreterRuntime::monitorenter);
+ }
+ 
  void MacroAssembler::call_VM_base(Register oop_result,
                                    Register java_thread,
                                    Register last_java_sp,
                                    address  entry_point,
                                    int      number_of_arguments,

@@ -434,11 +469,16 @@
  
    // set last Java frame before call
    assert(last_java_sp != fp, "can't use fp");
  
    Label l;
-   set_last_Java_frame(last_java_sp, fp, l, t0);
+   if (is_preemptable(entry_point)) {
+     // skip setting last_pc since we already set it to desired value.
+     set_last_Java_frame(last_java_sp, fp, noreg);
+   } else {
+     set_last_Java_frame(last_java_sp, fp, l, t0);
+   }
  
    // do the call, remove parameters
    MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments, &l);
  
    // reset last Java frame
< prev index next >