Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8275950: Use only _thread_in_vm in ~ThreadBlockInVMPreprocess() #6120

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/hotspot/share/runtime/interfaceSupport.inline.hpp
Expand Up @@ -229,14 +229,12 @@ class ThreadBlockInVMPreprocess : public ThreadStateTransition {
~ThreadBlockInVMPreprocess() {
assert(_thread->thread_state() == _thread_blocked, "coming from wrong thread state");
// Change to transition state and ensure it is seen by the VM thread.
_thread->set_thread_state_fence(_thread_blocked_trans);
_thread->set_thread_state_fence(_thread_in_vm);
Copy link
Member

Choose a reason for hiding this comment

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

The comment on L231 is now wrong since you're no longer using
a "transition" state. Perhaps, "Change to an unsafe state..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


if (SafepointMechanism::should_process(_thread, _allow_suspend)) {
_pr(_thread);
SafepointMechanism::process_if_requested(_thread, _allow_suspend);
}

_thread->set_thread_state(_thread_in_vm);
}

static void emptyOp(JavaThread* current) {}
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/runtime/safepoint.cpp
Expand Up @@ -706,7 +706,6 @@ void SafepointSynchronize::block(JavaThread *thread) {
}

JavaThreadState state = thread->thread_state();
assert(is_a_block_safe_state(state), "Illegal threadstate encountered: %d", state);
Copy link
Member

Choose a reason for hiding this comment

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

Getting rid of this assert makes me a bit nervous, but I have to
get used to the fact that @pchilano is making the safepointing
sub-system simpler and simpler...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about keeping it but not only we have a single caller(SafepointMechanism::process()) which already has that assert as a guarantee, but also there is no way to add new callers without basically copying all the logic from SafepointMechanism::process() since we cannot just call SS::block().

thread->frame_anchor()->make_walkable(thread);

uint64_t safepoint_id = SafepointSynchronize::safepoint_counter();
Expand Down
9 changes: 1 addition & 8 deletions src/hotspot/share/runtime/safepoint.hpp
Expand Up @@ -128,14 +128,7 @@ class SafepointSynchronize : AllStatic {

static bool is_a_block_safe_state(JavaThreadState state) {
// Check that we have a valid thread_state before blocking for safepoints
switch(state) {
case _thread_in_vm:
case _thread_in_Java: // From compiled code
case _thread_blocked_trans:
return true;
default:
return false;
}
return state == _thread_in_vm || state == _thread_in_Java;
}
// Called when a thread voluntarily blocks
static void block(JavaThread *thread);
Expand Down