< prev index next >

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

Print this page
*** 537,10 ***
--- 537,42 ---
    __ membar(MacroAssembler::AnyAny);
    __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos));
    return entry;
  }
  
+ address TemplateInterpreterGenerator::generate_cont_resume_interpreter_adapter() {
+   if (!Continuations::enabled()) return nullptr;
+   address start = __ pc();
+ 
+   __ restore_bcp();
+   __ restore_locals();
+ 
+   // Restore constant pool cache
+   __ ld(xcpool, Address(fp, frame::interpreter_frame_cache_offset * wordSize));
+ 
+   // Restore Java expression stack pointer
+   __ ld(t0, Address(fp, frame::interpreter_frame_last_sp_offset * wordSize));
+   __ shadd(esp, t0, fp, t0, Interpreter::logStackElementSize);
+   // and NULL it as marker that esp is now tos until next java call
+   __ sd(zr, Address(fp, frame::interpreter_frame_last_sp_offset * wordSize));
+ 
+   // Restore machine SP
+   __ ld(t0, Address(fp, frame::interpreter_frame_extended_sp_offset * wordSize));
+   __ shadd(sp, t0, fp, t0, LogBytesPerWord);
+ 
+   // Restore method
+   __ ld(xmethod, Address(fp, frame::interpreter_frame_method_offset * wordSize));
+ 
+   // Restore dispatch
+   __ la(xdispatch, ExternalAddress((address)Interpreter::dispatch_table()));
+ 
+   __ ret();
+ 
+   return start;
+ }
+ 
+ 
  // Helpers for commoning out cases in the various type of method entries.
  //
  
  
  // increment invocation count & check for overflow

*** 1090,10 ***
--- 1122,12 ---
  
  
    // result handler is in x10
    // set result handler
    __ mv(result_handler, x10);
+   __ sd(x10, Address(fp, frame::interpreter_frame_result_handler_offset * wordSize));
+ 
    // pass mirror handle if static call
    {
      Label L;
      __ lwu(t, Address(xmethod, Method::access_flags_offset()));
      __ test_bit(t0, t, exact_log2(JVM_ACC_STATIC));

*** 1128,10 ***
--- 1162,12 ---
    // pass JNIEnv
    __ add(c_rarg0, xthread, in_bytes(JavaThread::jni_environment_offset()));
  
    // It is enough that the pc() points into the right code
    // segment. It does not have to be the correct return pc.
+   // For convenience we use the pc we want to resume to in
+   // case of preemption on Object.wait.
    Label native_return;
    __ set_last_Java_frame(esp, fp, native_return, x30);
  
    // change thread state
  #ifdef ASSERT

*** 1149,13 ***
    __ la(t1, Address(xthread, JavaThread::thread_state_offset()));
    __ mv(t0, _thread_in_native);
    __ membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore);
    __ sw(t0, Address(t1));
  
    // Call the native method.
    __ jalr(x28);
!   __ bind(native_return);
    __ get_method(xmethod);
    // result potentially in x10 or f10
  
    // Restore cpu control state after JNI call
    __ restore_cpu_control_state_after_jni(t0);
--- 1185,17 ---
    __ la(t1, Address(xthread, JavaThread::thread_state_offset()));
    __ mv(t0, _thread_in_native);
    __ membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore);
    __ sw(t0, Address(t1));
  
+   __ push_cont_fastpath();
+ 
    // Call the native method.
    __ jalr(x28);
! 
+   __ pop_cont_fastpath();
+ 
    __ get_method(xmethod);
    // result potentially in x10 or f10
  
    // Restore cpu control state after JNI call
    __ restore_cpu_control_state_after_jni(t0);

*** 1217,10 ***
--- 1257,25 ---
    __ membar(MacroAssembler::LoadStore | MacroAssembler::StoreStore);
  
    __ mv(t0, _thread_in_Java);
    __ sw(t0, Address(xthread, JavaThread::thread_state_offset()));
  
+   if (LockingMode != LM_LEGACY) {
+     // Check preemption for Object.wait()
+     Label not_preempted;
+     __ ld(t0, Address(xthread, JavaThread::preempt_alternate_return_offset()));
+     __ beqz(t0, not_preempted);
+     __ sd(zr, Address(xthread, JavaThread::preempt_alternate_return_offset()));
+     __ jr(t0);
+     __ bind(native_return);
+     __ restore_after_resume(true /* is_native */);
+     __ bind(not_preempted);
+   } else {
+     // any pc will do so just use this one for LM_LEGACY to keep code together.
+     __ bind(native_return);
+   }
+ 
    // reset_last_Java_frame
    __ reset_last_Java_frame(true);
  
    if (CheckJNICalls) {
      // clear_pending_jni_exception_check

*** 1235,10 ***
--- 1290,11 ---
    // and result handler will pick it up
  
    {
      Label no_oop;
      __ la(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
+     __ ld(result_handler, Address(fp, frame::interpreter_frame_result_handler_offset * wordSize));
      __ bne(t, result_handler, no_oop);
      // Unbox oop result, e.g. JNIHandles::resolve result.
      __ pop(ltos);
      __ resolve_jobject(x10, t, t1);
      __ sd(x10, Address(fp, frame::interpreter_frame_oop_temp_offset * wordSize));
< prev index next >