< prev index next >

src/hotspot/cpu/x86/continuationHelper_x86.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,24 ---
    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()) {
+     // Patch the pc of the now old last Java frame (we already set the anchor to enterSpecial)
+     // so that when target goes back to Java it will actually return to the preempt cleanup stub.
+     intptr_t* sp = f.sp();
+     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;

*** 70,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 = *(address*)(sp - frame::sender_sp_ret_address_offset());
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
    assert(f.raw_pc() == pc, "f.ra_pc: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.raw_pc()), p2i(pc));
--- 84,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 = *(address*)(sp - frame::sender_sp_ret_address_offset());
    intptr_t* fp = *(intptr_t**)(sp - frame::sender_sp_offset);
    assert(f.raw_pc() == pc, "f.ra_pc: " INTPTR_FORMAT " actual: " INTPTR_FORMAT, p2i(f.raw_pc()), p2i(pc));
< prev index next >