Skip to content
Permalink
Browse files
8252661: Change SafepointMechanism terminology to talk less about "bl…
…ocking"

Reviewed-by: rehn, shade, dholmes
  • Loading branch information
fisk committed Sep 7, 2020
1 parent e0c8d44 commit e29c3f61235b325d5397f0844badc377ddae7922
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 33 deletions.
@@ -419,7 +419,7 @@ int ZeroInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {

// Handle safepoint operations, pending suspend requests,
// and pending asynchronous exceptions.
if (SafepointMechanism::should_block(thread) ||
if (SafepointMechanism::should_process(thread) ||
thread->has_special_condition_for_native_trans()) {
JavaThread::check_special_condition_for_native_trans(thread);
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
@@ -551,7 +551,7 @@ int ZeroInterpreter::accessor_entry(Method* method, intptr_t UNUSED, TRAPS) {
intptr_t *locals = stack->sp();

// Drop into the slow path if we need a safepoint check
if (SafepointMechanism::should_block(THREAD)) {
if (SafepointMechanism::should_process(THREAD)) {
return normal_entry(method, 0, THREAD);
}

@@ -683,7 +683,7 @@ int ZeroInterpreter::empty_entry(Method* method, intptr_t UNUSED, TRAPS) {
ZeroStack *stack = thread->zero_stack();

// Drop into the slow path if we need a safepoint check
if (SafepointMechanism::should_block(THREAD)) {
if (SafepointMechanism::should_process(THREAD)) {
return normal_entry(method, 0, THREAD);
}

@@ -919,7 +919,7 @@ JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bo
last_pc_offset = pc_offset;

JavaThread* thread = JavaThread::current();
if (SafepointMechanism::should_block(thread)) {
if (SafepointMechanism::should_process(thread)) {
// this is a hacky way to force a safepoint check but nothing else was jumping out at me.
ThreadToNativeFromVM ttnfv(thread);
}
@@ -361,7 +361,7 @@ bool Handshake::execute_direct(HandshakeClosure* thread_cl, JavaThread* target)
hsy.add_result(pr);
// Check for pending handshakes to avoid possible deadlocks where our
// target is trying to handshake us.
if (SafepointMechanism::should_block(self)) {
if (SafepointMechanism::should_process(self)) {
ThreadBlockInVM tbivm(self);
}
hsy.process();
@@ -93,7 +93,7 @@ class ThreadStateTransition : public StackObj {
// Change to transition state and ensure it is seen by the VM thread.
thread->set_thread_state_fence((JavaThreadState)(from + 1));

SafepointMechanism::block_if_requested(thread);
SafepointMechanism::process_if_requested(thread);
thread->set_thread_state(to);
}

@@ -114,7 +114,7 @@ class ThreadStateTransition : public StackObj {
// We never install asynchronous exceptions when coming (back) in
// to the runtime from native code because the runtime is not set
// up to handle exceptions floating around at arbitrary points.
if (SafepointMechanism::should_block(thread) || thread->is_suspend_after_native()) {
if (SafepointMechanism::should_process(thread) || thread->is_suspend_after_native()) {
JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
}

@@ -135,7 +135,7 @@ class ThreadInVMForHandshake : public ThreadStateTransition {
// Change to transition state and ensure it is seen by the VM thread.
_thread->set_thread_state_fence(_thread_in_vm_trans);

SafepointMechanism::block_if_requested(_thread);
SafepointMechanism::process_if_requested(_thread);

_thread->set_thread_state(_original_state);

@@ -290,9 +290,9 @@ class ThreadBlockInVMWithDeadlockCheck : public ThreadStateTransition {
// Change to transition state and ensure it is seen by the VM thread.
_thread->set_thread_state_fence((JavaThreadState)(_thread_blocked_trans));

if (SafepointMechanism::should_block(_thread)) {
if (SafepointMechanism::should_process(_thread)) {
release_mutex();
SafepointMechanism::block_if_requested(_thread);
SafepointMechanism::process_if_requested(_thread);
}

_thread->set_thread_state(_thread_in_vm);
@@ -1783,7 +1783,7 @@ int ObjectMonitor::TrySpin(Thread * Self) {
// This is in keeping with the "no loitering in runtime" rule.
// We periodically check to see if there's a safepoint pending.
if ((ctr & 0xFF) == 0) {
if (SafepointMechanism::should_block(Self)) {
if (SafepointMechanism::should_process(Self)) {
goto Abort; // abrupt spin egress
}
SpinPause();
@@ -774,7 +774,7 @@ void SafepointSynchronize::block(JavaThread *thread) {
!thread->is_at_poll_safepoint() && (state != _thread_in_native_trans));
}

// cross_modify_fence is done by SafepointMechanism::block_if_requested_slow
// cross_modify_fence is done by SafepointMechanism::process_operation_if_requested_slow
// which is the only caller here.
}

@@ -924,7 +924,7 @@ void ThreadSafepointState::print_on(outputStream *st) const {

// ---------------------------------------------------------------------------------------------------------------------

// Block the thread at poll or poll return for safepoint/handshake.
// Process pending operation.
void ThreadSafepointState::handle_polling_page_exception() {

// Step 1: Find the nmethod from the return address
@@ -963,8 +963,8 @@ void ThreadSafepointState::handle_polling_page_exception() {
assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
}

// Block the thread
SafepointMechanism::block_if_requested(thread());
// Process pending operation
SafepointMechanism::process_if_requested(thread());

// restore oop result, if any
if (return_oop) {
@@ -979,8 +979,8 @@ void ThreadSafepointState::handle_polling_page_exception() {
// verify the blob built the "return address" correctly
assert(real_return_addr == caller_fr.pc(), "must match");

// Block the thread
SafepointMechanism::block_if_requested(thread());
// Process pending operation
SafepointMechanism::process_if_requested(thread());
set_at_poll_safepoint(false);

// If we have a pending async exception deoptimize the frame
@@ -71,7 +71,7 @@ void SafepointMechanism::default_initialize() {
_poll_disarmed_value = reinterpret_cast<void*>(poll_disarmed_value);
}

void SafepointMechanism::block_or_handshake(JavaThread *thread) {
void SafepointMechanism::process(JavaThread *thread) {
if (global_poll()) {
// Any load in ::block must not pass the global poll load.
// Otherwise we might load an old safepoint counter (for example).
@@ -83,12 +83,12 @@ void SafepointMechanism::block_or_handshake(JavaThread *thread) {
}
}

void SafepointMechanism::block_if_requested_slow(JavaThread *thread) {
void SafepointMechanism::process_if_requested_slow(JavaThread *thread) {
// Read global poll and has_handshake after local poll
OrderAccess::loadload();

// local poll already checked, if used.
block_or_handshake(thread);
process(thread);

OrderAccess::loadload();

@@ -47,8 +47,8 @@ class SafepointMechanism : public AllStatic {
static inline bool local_poll(Thread* thread);
static inline bool global_poll();

static void block_or_handshake(JavaThread *thread);
static void block_if_requested_slow(JavaThread *thread);
static void process(JavaThread *thread);
static void process_if_requested_slow(JavaThread *thread);

static void default_initialize();

@@ -64,10 +64,10 @@ class SafepointMechanism : public AllStatic {
static bool is_poll_address(address addr) { return addr >= _polling_page && addr < (_polling_page + os::vm_page_size()); }

// Call this method to see if this thread should block for a safepoint or process handshake.
static inline bool should_block(Thread* thread);
static inline bool should_process(Thread* thread);

// Blocks a thread until safepoint/handshake is completed.
static inline void block_if_requested(JavaThread* thread);
// Processes a pending requested operation.
static inline void process_if_requested(JavaThread* thread);

// Caller is responsible for using a memory barrier if needed.
static inline void arm_local_poll(JavaThread* thread);
@@ -47,15 +47,15 @@ bool SafepointMechanism::local_poll(Thread* thread) {
}
}

bool SafepointMechanism::should_block(Thread* thread) {
bool SafepointMechanism::should_process(Thread* thread) {
return local_poll(thread);
}

void SafepointMechanism::block_if_requested(JavaThread *thread) {
void SafepointMechanism::process_if_requested(JavaThread *thread) {
if (!local_poll_armed(thread)) {
return;
}
block_if_requested_slow(thread);
process_if_requested_slow(thread);
}

void SafepointMechanism::arm_local_poll(JavaThread* thread) {
@@ -267,7 +267,7 @@ void NMethodSweeper::force_sweep() {
*/
void NMethodSweeper::handle_safepoint_request() {
JavaThread* thread = JavaThread::current();
if (SafepointMechanism::should_block(thread)) {
if (SafepointMechanism::should_process(thread)) {
if (PrintMethodFlushing && Verbose) {
tty->print_cr("### Sweep at %d out of %d, yielding to safepoint", _seen, CodeCache::nmethod_count());
}
@@ -2313,7 +2313,7 @@ int ObjectSynchronizer::deflate_monitor_list_using_JT(ObjectMonitor** list_p,
mid = next; // mid keeps non-NULL next's locked state
next = next_next;

if (SafepointMechanism::should_block(self) &&
if (SafepointMechanism::should_process(self) &&
// Acquire semantics are not needed on this list load since
// it is not dependent on the following load which does have
// acquire semantics.
@@ -2507,7 +2507,7 @@ void ObjectSynchronizer::deflate_common_idle_monitors_using_JT(bool is_global, J
} else {
log_debug(monitorinflation)("jt=" INTPTR_FORMAT ": pausing deflation of per-thread idle monitors for a safepoint.", p2i(target));
}
assert(SafepointMechanism::should_block(self), "sanity check");
assert(SafepointMechanism::should_process(self), "sanity check");
ThreadBlockInVM blocker(self);
}
// Prepare for another loop after the safepoint.
@@ -2628,7 +2628,7 @@ void JavaThread::java_suspend_self_with_safepoint_check() {
// we must manually emit the instruction barrier after leaving a safe state.
OrderAccess::cross_modify_fence();
if (state != _thread_in_native) {
SafepointMechanism::block_if_requested(this);
SafepointMechanism::process_if_requested(this);
}
}

@@ -2658,7 +2658,7 @@ void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread
if (thread->is_external_suspend()) {
thread->java_suspend_self_with_safepoint_check();
} else {
SafepointMechanism::block_if_requested(thread);
SafepointMechanism::process_if_requested(thread);
}

JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)

1 comment on commit e29c3f6

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on e29c3f6 Sep 7, 2020

Choose a reason for hiding this comment

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

Review

Issues

Please sign in to comment.