< prev index next >

src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

Print this page
*** 3863,10 ***
--- 3863,42 ---
      generate_cont_thaw(Continuation::thaw_return_barrier_exception);
  
      return start;
    }
  
+   address generate_cont_preempt_stub() {
+     if (!Continuations::enabled()) return nullptr;
+     StubCodeMark mark(this, "StubRoutines","Continuation preempt stub");
+     address start = __ pc();
+ 
+     __ reset_last_Java_frame(true);
+ 
+     // reset the flag
+     __ sb(zr, Address(xthread, JavaThread::preempting_offset()));
+ 
+     // Set sp to enterSpecial frame and then remove it from the stack
+     __ ld(sp, Address(xthread, JavaThread::cont_entry_offset()));
+ 
+     Label preemption_cancelled;
+     __ lbu(t0, Address(xthread, JavaThread::preemption_cancelled_offset()));
+     __ bnez(t0, preemption_cancelled);
+ 
+     // Remove enterSpecial frame from the stack and return to Continuation.run()
+     SharedRuntime::continuation_enter_cleanup(_masm);
+     __ leave();
+     __ ret();
+ 
+     __ bind(preemption_cancelled);
+     __ sb(zr, Address(xthread, JavaThread::preemption_cancelled_offset()));
+     __ la(fp, Address(sp, checked_cast<int32_t>(ContinuationEntry::size() + 2 * wordSize)));
+     __ la(t0, ExternalAddress(ContinuationEntry::thaw_call_pc_address()));
+     __ ld(t0, Address(t0));
+     __ jr(t0);
+ 
+     return start;
+   }
+ 
  #if COMPILER2_OR_JVMCI
  
  #undef __
  #define __ this->
  

*** 6155,10 ***
--- 6187,11 ---
    void generate_continuation_stubs() {
      // Continuation stubs:
      StubRoutines::_cont_thaw             = generate_cont_thaw();
      StubRoutines::_cont_returnBarrier    = generate_cont_returnBarrier();
      StubRoutines::_cont_returnBarrierExc = generate_cont_returnBarrier_exception();
+     StubRoutines::_cont_preempt_stub     = generate_cont_preempt_stub();
    }
  
    void generate_final_stubs() {
      // support for verify_oop (must happen after universe_init)
      if (VerifyOops) {
< prev index next >