< prev index next >

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Print this page
@@ -7138,10 +7138,43 @@
      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
+     __ strb(zr, Address(rthread, JavaThread::preempting_offset()));
+ 
+     // Set sp to enterSpecial frame and then remove it from the stack
+     __ ldr(rscratch2, Address(rthread, JavaThread::cont_entry_offset()));
+     __ mov(sp, rscratch2);
+ 
+     Label preemption_cancelled;
+     __ ldrb(rscratch1, Address(rthread, JavaThread::preemption_cancelled_offset()));
+     __ cbnz(rscratch1, preemption_cancelled);
+ 
+     // Remove enterSpecial frame from the stack and return to Continuation.run()
+     SharedRuntime::continuation_enter_cleanup(_masm);
+     __ leave();
+     __ ret(lr);
+ 
+     __ bind(preemption_cancelled);
+     __ strb(zr, Address(rthread, JavaThread::preemption_cancelled_offset()));
+     __ lea(rfp, Address(sp, checked_cast<int32_t>(ContinuationEntry::size())));
+     __ lea(rscratch1, ExternalAddress(ContinuationEntry::thaw_call_pc_address()));
+     __ ldr(rscratch1, Address(rscratch1));
+     __ br(rscratch1);
+ 
+     return start;
+   }
+ 
    // In sun.security.util.math.intpoly.IntegerPolynomial1305, integers
    // are represented as long[5], with BITS_PER_LIMB = 26.
    // Pack five 26-bit limbs into three 64-bit registers.
    void pack_26(Register dest0, Register dest1, Register dest2, Register src) {
      __ ldp(dest0, rscratch1, Address(src, 0));     // 26 bits

@@ -8220,10 +8253,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 >