if (prev_poll_word != poll_word ||
prev_poll_word == _poll_word_armed_value) { // While updating the poll value, we allow entering new nmethods // through stack unwinding. The nmethods might have been processed in // a concurrent thread by the GC. So we need to run a cross modify // fence to ensure patching becomes visible. We may also wake up from // a safepoint that has patched code. This cross modify fence will // ensure such paths can observe patched code. // Note that while other threads may arm the thread-local poll of // a thread, only the thread itself has permission to disarm its own // poll value, in any way making it less restrictive. Therefore, whenever // the frontier of what the mutator allows itself to do is increased, // we will catch that here, and ensure a cross modifying fence is used.
OrderAccess::cross_modify_fence();
}
thread->poll_data()->set_polling_page(poll_page);
thread->poll_data()->set_polling_word(poll_word);
OrderAccess::fence(); if (!armed && (global_poll() || thread->handshake_state()->has_operation())) { // We disarmed an old safepoint, but a new one is synchronizing. // We need to arm the poll for the subsequent safepoint poll. continue;
} break;
}
}
void SafepointMechanism::process(JavaThread *thread, bool allow_suspend, bool check_async_exception) {
DEBUG_ONLY(intptr_t* sp_before = thread->last_Java_sp();) // Read global poll and has_handshake after local poll
OrderAccess::loadload();
// local poll already checked, if used. bool need_rechecking; do {
JavaThreadState state = thread->thread_state();
guarantee(state == _thread_in_vm, "Illegal threadstate encountered: %d", state); if (global_poll()) { // Any load in ::block() must not pass the global poll load. // Otherwise we might load an old safepoint counter (for example).
OrderAccess::loadload();
SafepointSynchronize::block(thread);
}
// The call to on_safepoint fixes the thread's oops and the first few frames. // // The call has been carefully placed here to cater to a few situations: // 1) After we exit from block after a global poll // 2) After a thread races with the disarming of the global poll and transitions from native/blocked // 3) Before the handshake code is run
StackWatermarkSet::on_safepoint(thread);
need_rechecking = thread->handshake_state()->has_operation() && thread->handshake_state()->process_by_self(allow_suspend, check_async_exception);
} while (need_rechecking);
update_poll_values(thread);
assert(sp_before == thread->last_Java_sp(), "Anchor has changed");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.