Skip to content

Commit e745d52

Browse files
committed
generate_cont_preempt_stub
1 parent e6049ed commit e745d52

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/hotspot/cpu/s390/sharedRuntime_s390.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,10 @@ static void gen_continuation_yield(MacroAssembler* masm,
17311731
__ z_br(Z_R1_scratch);
17321732
}
17331733

1734+
void SharedRuntime::continuation_enter_cleanup(MacroAssembler* masm) {
1735+
::continuation_enter_cleanup(masm);
1736+
}
1737+
17341738
nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
17351739
const methodHandle& method,
17361740
int compile_id,

src/hotspot/cpu/s390/stubGenerator_s390.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "oops/oop.inline.hpp"
3838
#include "prims/methodHandles.hpp"
3939
#include "prims/upcallLinker.hpp"
40+
#include "runtime/continuation.hpp"
41+
#include "runtime/continuationEntry.inline.hpp"
4042
#include "runtime/frame.inline.hpp"
4143
#include "runtime/handles.inline.hpp"
4244
#include "runtime/javaThread.hpp"
@@ -3325,7 +3327,7 @@ class StubGenerator: public StubCodeGenerator {
33253327
__ push_frame_abi160(0 + 2 * BytesPerWord);
33263328
__ z_stg(Z_RET , 0 * BytesPerWord + frame::z_abi_160_size, Z_SP); // save return value containing the exception oop
33273329

3328-
__ z_stg(Z_ARG2, 1 * BytesPerWord + frame::z_abi_160_size, Z_SP); // save exception_pc
3330+
__ z_stg(Z_ARG2, 1 * BytesPerWord + frame::z_abi_160_size, Z_SP); // save exception_pc
33293331
__ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), Z_thread, Z_ARG2);
33303332

33313333
// Copy handler's address.
@@ -3335,7 +3337,7 @@ class StubGenerator: public StubCodeGenerator {
33353337
// - Z_ARG1: exception oop
33363338
// - Z_ARG2: exception pc
33373339
__ z_lg(Z_ARG1, 0 * BytesPerWord + frame::z_abi_160_size, Z_SP); // load the exception oop
3338-
__ z_lg(Z_ARG2, 1 * BytesPerWord + frame::z_abi_160_size, Z_SP); // load the exception pc
3340+
__ z_lg(Z_ARG2, 1 * BytesPerWord + frame::z_abi_160_size, Z_SP); // load the exception pc
33393341
__ pop_frame();
33403342
__ restore_return_pc();
33413343
} else {
@@ -3364,7 +3366,36 @@ class StubGenerator: public StubCodeGenerator {
33643366
StubId stub_id = StubId::stubgen_cont_preempt_id;
33653367
StubCodeMark mark(this, stub_id);
33663368
address start = __ pc();
3367-
__ stop("generate_cont_preempt_stub not yet implemented");
3369+
// __ reset_last_Java_frame(false);
3370+
// _last_Java_sp = 0
3371+
// Clearing storage must be atomic here, so don't use clear_mem()!
3372+
__ store_const(Address(Z_thread, JavaThread::last_Java_sp_offset()), 0);
3373+
3374+
// _last_Java_pc = 0
3375+
__ store_const(Address(Z_thread, JavaThread::last_Java_pc_offset()), 0);
3376+
3377+
// Set sp to enterSpecial frame, i.e. remove all frames copied into the heap.
3378+
__ z_lg(Z_SP, Address(Z_thread, JavaThread::cont_entry_offset()));
3379+
3380+
Label preemption_cancelled;
3381+
3382+
__ z_cli(in_bytes(JavaThread::preemption_cancelled_offset()), Z_thread, 0);
3383+
__ z_brne(preemption_cancelled);
3384+
3385+
// Remove enterSpecial frame from the stack and return to Continuation.run() to unmount.
3386+
SharedRuntime::continuation_enter_cleanup(_masm);
3387+
__ pop_frame();
3388+
__ restore_return_pc();
3389+
__ z_br(Z_R14);
3390+
3391+
// We acquired the monitor after freezing the frames so call thaw to continue execution.
3392+
__ bind(preemption_cancelled);
3393+
__ z_mvi(in_bytes(JavaThread::preemption_cancelled_offset()), Z_thread, 0);
3394+
3395+
__ load_const_optimized(Z_R1, ContinuationEntry::thaw_call_pc_address());
3396+
__ z_lg(Z_R1, Address(Z_R1));
3397+
__ z_br(Z_R1);
3398+
33683399
return start;
33693400
}
33703401

0 commit comments

Comments
 (0)