< prev index next >

src/hotspot/cpu/aarch64/continuationHelper_aarch64.inline.hpp

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 38,10 ***
--- 38,26 ---
    return FKind::interpreted
              ? (intptr_t**)(f.fp() + frame::link_offset)
              : (intptr_t**)(f.unextended_sp() + f.cb()->frame_size() - frame::sender_sp_offset);
  }
  
+ static inline void patch_return_pc_with_preempt_stub(frame& f) {
+   if (f.is_runtime_frame()) {
+     // Unlike x86 we don't know where in the callee frame the return pc is
+     // saved so we can't patch the return from the VM call back to Java.
+     // Instead, we will patch the return from the runtime stub back to the
+     // compiled method so that the target returns to the preempt cleanup stub.
+     intptr_t* caller_sp = f.sp() + f.cb()->frame_size();
+     caller_sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
+   } else {
+     // The target will check for preemption once it returns to the interpreter
+     // or the native wrapper code and will manually jump to the preempt stub.
+     JavaThread *thread = JavaThread::current();
+     thread->set_preempt_alternate_return(StubRoutines::cont_preempt_stub());
+   }
+ }
+ 
  inline int ContinuationHelper::frame_align_words(int size) {
  #ifdef _LP64
    return size & 1;
  #else
    return 0;

*** 81,16 ***
  
  inline void ContinuationHelper::set_anchor_to_entry_pd(JavaFrameAnchor* anchor, ContinuationEntry* entry) {
    anchor->set_last_Java_fp(entry->entry_fp());
  }
  
- #ifdef ASSERT
  inline void ContinuationHelper::set_anchor_pd(JavaFrameAnchor* anchor, intptr_t* sp) {
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
    anchor->set_last_Java_fp(fp);
  }
  
  inline bool ContinuationHelper::Frame::assert_frame_laid_out(frame f) {
    intptr_t* sp = f.sp();
    address pc = ContinuationHelper::return_address_at(
                   sp - frame::sender_sp_ret_address_offset());
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
--- 97,16 ---
  
  inline void ContinuationHelper::set_anchor_to_entry_pd(JavaFrameAnchor* anchor, ContinuationEntry* entry) {
    anchor->set_last_Java_fp(entry->entry_fp());
  }
  
  inline void ContinuationHelper::set_anchor_pd(JavaFrameAnchor* anchor, intptr_t* sp) {
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
    anchor->set_last_Java_fp(fp);
  }
  
+ #ifdef ASSERT
  inline bool ContinuationHelper::Frame::assert_frame_laid_out(frame f) {
    intptr_t* sp = f.sp();
    address pc = ContinuationHelper::return_address_at(
                   sp - frame::sender_sp_ret_address_offset());
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
< prev index next >