Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ inline intptr_t* AnchorMark::anchor_mark_set_pd() {
assert(_last_sp_from_frame != nullptr, "");
_top_frame.interpreter_frame_set_last_sp(nullptr);
if (sp != _last_sp_from_frame) {
// We need to move up return pc and fp. They will be read next in
// set_anchor() and set as _last_Java_pc and _last_Java_fp respectively.
_last_sp_from_frame[-1] = (intptr_t)_top_frame.pc();
_last_sp_from_frame[-2] = (intptr_t)_top_frame.fp();
}
Expand Down Expand Up @@ -335,15 +337,16 @@ inline intptr_t* ThawBase::push_cleanup_continuation() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. rfp will be restored back in gen_continuation_enter().
sp[-1] = (intptr_t)ContinuationEntry::cleanup_pc();
sp[-2] = (intptr_t)enterSpecial.fp();
return sp;
}

inline intptr_t* ThawBase::push_preempt_adapter() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. rfp will be restored back in generate_cont_preempt_stub().
sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push_cleanup_continuation sets sp[-2]. This doesn't have to set that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push_cleanup_continuation() doesn’t need it. I removed it there and added a comment on both methods.

return sp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ inline intptr_t* AnchorMark::anchor_mark_set_pd() {
assert(_last_sp_from_frame != nullptr, "");
_top_frame.interpreter_frame_set_last_sp(nullptr);
if (sp != _last_sp_from_frame) {
// We need to move up return pc and fp. They will be read next in
// set_anchor() and set as _last_Java_pc and _last_Java_fp respectively.
_last_sp_from_frame[-1] = (intptr_t)_top_frame.pc();
_last_sp_from_frame[-2] = (intptr_t)_top_frame.fp();
}
Expand Down Expand Up @@ -336,15 +338,16 @@ inline intptr_t* ThawBase::push_cleanup_continuation() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. fp will be restored back in gen_continuation_enter().
sp[-1] = (intptr_t)ContinuationEntry::cleanup_pc();
sp[-2] = (intptr_t)enterSpecial.fp();
return sp;
}

inline intptr_t* ThawBase::push_preempt_adapter() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. fp will be restored back in generate_cont_preempt_stub().
sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
return sp;
}
Expand Down
5 changes: 4 additions & 1 deletion src/hotspot/cpu/x86/continuationFreezeThaw_x86.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ inline intptr_t* AnchorMark::anchor_mark_set_pd() {
assert(_last_sp_from_frame != nullptr, "");
_top_frame.interpreter_frame_set_last_sp(nullptr);
if (sp != _last_sp_from_frame) {
// We need to move up return pc and fp. They will be read next in
// set_anchor() and set as _last_Java_pc and _last_Java_fp respectively.
_last_sp_from_frame[-1] = (intptr_t)_top_frame.pc();
_last_sp_from_frame[-2] = (intptr_t)_top_frame.fp();
}
Expand Down Expand Up @@ -322,15 +324,16 @@ inline intptr_t* ThawBase::push_cleanup_continuation() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. rbp will be restored back in gen_continuation_enter().
sp[-1] = (intptr_t)ContinuationEntry::cleanup_pc();
sp[-2] = (intptr_t)enterSpecial.fp();
return sp;
}

inline intptr_t* ThawBase::push_preempt_adapter() {
frame enterSpecial = new_entry_frame();
intptr_t* sp = enterSpecial.sp();

// We only need to set the return pc. rbp will be restored back in generate_cont_preempt_stub().
sp[-1] = (intptr_t)StubRoutines::cont_preempt_stub();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here sp-2 ?

return sp;
}
Expand Down
16 changes: 7 additions & 9 deletions src/hotspot/share/runtime/continuationFreezeThaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,9 @@ static void jvmti_yield_cleanup(JavaThread* thread, ContinuationWrapper& cont) {
static void jvmti_mount_end(JavaThread* current, ContinuationWrapper& cont, frame top, Continuation::preempt_kind pk) {
assert(current->vthread() != nullptr, "must be");

HandleMarkCleaner hm(current); // Cleanup vth and so._conth Handles
HandleMarkCleaner hm(current); // Cleanup all handles (including so._conth) before returning to Java.
Handle vth(current, current->vthread());
ContinuationWrapper::SafepointOp so(current, cont);

AnchorMark am(current, top); // Set anchor so that the stack is walkable.

JRT_BLOCK
Expand Down Expand Up @@ -2352,12 +2351,12 @@ NOINLINE intptr_t* Thaw<ConfigT>::thaw_fast(stackChunkOop chunk) {
#endif

#ifdef ASSERT
set_anchor(_thread, rs.sp());
log_frames(_thread);
if (LoomDeoptAfterThaw) {
frame top(rs.sp());
AnchorMark am(_thread, top);
log_frames(_thread);
do_deopt_after_thaw(_thread);
}
clear_anchor(_thread);
#endif

return rs.sp();
Expand Down Expand Up @@ -2684,7 +2683,7 @@ intptr_t* ThawBase::redo_vmcall(JavaThread* current, frame& top) {
intptr_t* sp = top.sp();

{
HandleMarkCleaner hmc(current); // Cleanup so._conth Handle
HandleMarkCleaner hmc(current); // Cleanup all handles (including so._conth) before returning to Java.
ContinuationWrapper::SafepointOp so(current, _cont);
AnchorMark am(current, top); // Set the anchor so that the stack is walkable.

Expand Down Expand Up @@ -2731,10 +2730,9 @@ intptr_t* ThawBase::redo_vmcall(JavaThread* current, frame& top) {
}

void ThawBase::throw_interrupted_exception(JavaThread* current, frame& top) {
HandleMarkCleaner hm(current); // Cleanup so._conth Handle
HandleMarkCleaner hm(current); // Cleanup all handles (including so._conth) before returning to Java.
ContinuationWrapper::SafepointOp so(current, _cont);
// Since we might safepoint set the anchor so that the stack can be walked.
set_anchor(current, top.sp());
AnchorMark am(current, top); // Set the anchor so that the stack is walkable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you delete the clear_anchor at line 2739 below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch. Removed.

JRT_BLOCK
THROW(vmSymbols::java_lang_InterruptedException());
JRT_BLOCK_END
Expand Down
15 changes: 2 additions & 13 deletions src/hotspot/share/runtime/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,19 +939,8 @@ void frame::oops_interpreted_do(OopClosure* f, const RegisterMapT* map, bool que
ResourceMark rm(thread); // is this right ???
Symbol* signature = call.signature();
bool has_receiver = call.has_receiver();
// we are at a call site & the expression stack is not empty
// => process callee's arguments
//
// Note: The expression stack can be empty if an exception
// occurred during method resolution/execution. In all
// cases we empty the expression stack completely be-
// fore handling the exception (the exception handling
// code in the interpreter calls a blocking runtime
// routine which can cause this code to be executed).
// (was bug gri 7/27/98)
// if (dolog) {
// log_trace(continuations, tracking)("Processing arguments");
// }
// We are at a call site & the expression stack is not empty
// so we might have callee arguments we need to process.
oops_interpreted_arguments_do(signature, has_receiver, f);
}
}
Expand Down
19 changes: 13 additions & 6 deletions test/jdk/java/lang/Thread/virtual/KlassInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,49 @@
* @test id=default
* @library /test/lib
* @requires vm.continuations
* @run junit/othervm/timeout=480 -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit*
* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

/*
* @test id=Xint
* @library /test/lib
* @requires vm.continuations
* @run junit/othervm/timeout=480 -Xint -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -Xint -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit*
* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

/*
* @test id=Xcomp
* @library /test/lib
* @requires vm.continuations
* @run junit/othervm/timeout=480 -Xcomp -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -Xcomp -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit*
* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

/*
* @test id=Xcomp-TieredStopAtLevel1
* @library /test/lib
* @requires vm.continuations
* @run junit/othervm/timeout=480 -Xcomp -XX:TieredStopAtLevel=1 -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -Xcomp -XX:TieredStopAtLevel=1 -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit*
* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

/*
* @test id=Xcomp-noTieredCompilation
* @library /test/lib
* @requires vm.continuations
* @run junit/othervm/timeout=480 -Xcomp -XX:-TieredCompilation -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -Xcomp -XX:-TieredCompilation -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit*
* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

/*
* @test id=gc
* @library /test/lib
* @requires vm.debug == true & vm.continuations
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+FullGCALot -XX:FullGCALotInterval=1000 -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
* @run junit/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+FullGCALot -XX:FullGCALotInterval=1000
* -XX:CompileCommand=exclude,KlassInit::lambda$testReleaseAtKlassInit* -XX:CompileCommand=exclude,KlassInit$$Lambda*::run
* -XX:CompileCommand=exclude,KlassInit$1Driver::foo KlassInit
*/

import java.util.ArrayList;
Expand Down