Skip to content

Commit b7ba787

Browse files
author
duke
committedOct 14, 2020
Automatic merge of jdk:master into master
2 parents 49af9e2 + 55d760d commit b7ba787

File tree

4 files changed

+23
-35
lines changed

4 files changed

+23
-35
lines changed
 

‎src/hotspot/share/runtime/handshake.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,10 @@ HandshakeOperation* HandshakeState::pop() {
406406
};
407407

408408
void HandshakeState::process_by_self() {
409+
assert(Thread::current() == _handshakee, "should call from _handshakee");
410+
assert(!_handshakee->is_terminated(), "should not be a terminated thread");
411+
assert(_handshakee->thread_state() != _thread_blocked, "should not be in a blocked state");
412+
assert(_handshakee->thread_state() != _thread_in_native, "should not be in native");
409413
ThreadInVMForHandshake tivm(_handshakee);
410414
{
411415
NoSafepointVerifier nsv;
@@ -414,11 +418,6 @@ void HandshakeState::process_by_self() {
414418
}
415419

416420
void HandshakeState::process_self_inner() {
417-
assert(Thread::current() == _handshakee, "should call from _handshakee");
418-
assert(!_handshakee->is_terminated(), "should not be a terminated thread");
419-
assert(_handshakee->thread_state() != _thread_blocked, "should not be in a blocked state");
420-
assert(_handshakee->thread_state() != _thread_in_native, "should not be in native");
421-
422421
while (should_process()) {
423422
HandleMark hm(_handshakee);
424423
CautiouslyPreserveExceptionMark pem(_handshakee);

‎src/hotspot/share/runtime/interfaceSupport.inline.hpp

+2-16
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,7 @@ class ThreadStateTransition : public StackObj {
128128

129129
class ThreadInVMForHandshake : public ThreadStateTransition {
130130
const JavaThreadState _original_state;
131-
132-
void transition_back() {
133-
// This can be invoked from transition states and must return to the original state properly
134-
assert(_thread->thread_state() == _thread_in_vm, "should only call when leaving VM after handshake");
135-
136-
_thread->set_thread_state(_original_state);
137-
138-
if (_original_state != _thread_blocked_trans && _original_state != _thread_in_vm_trans &&
139-
_thread->has_special_runtime_exit_condition()) {
140-
_thread->handle_special_runtime_exit_condition(
141-
!_thread->is_at_poll_safepoint() && (_original_state != _thread_in_native_trans));
142-
}
143-
}
144-
145131
public:
146-
147132
ThreadInVMForHandshake(JavaThread* thread) : ThreadStateTransition(thread),
148133
_original_state(thread->thread_state()) {
149134

@@ -158,7 +143,8 @@ class ThreadInVMForHandshake : public ThreadStateTransition {
158143
}
159144

160145
~ThreadInVMForHandshake() {
161-
transition_back();
146+
assert(_thread->thread_state() == _thread_in_vm, "should only call when leaving VM after handshake");
147+
_thread->set_thread_state(_original_state);
162148
}
163149

164150
};

‎src/hotspot/share/runtime/safepoint.cpp

+15-12
Original file line numberDiff line numberDiff line change
@@ -943,19 +943,21 @@ void ThreadSafepointState::print_on(outputStream *st) const {
943943

944944
// Process pending operation.
945945
void ThreadSafepointState::handle_polling_page_exception() {
946+
JavaThread* self = thread();
947+
assert(self == Thread::current()->as_Java_thread(), "must be self");
946948

947949
// Step 1: Find the nmethod from the return address
948-
address real_return_addr = thread()->saved_exception_pc();
950+
address real_return_addr = self->saved_exception_pc();
949951

950952
CodeBlob *cb = CodeCache::find_blob(real_return_addr);
951953
assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod");
952954
CompiledMethod* nm = (CompiledMethod*)cb;
953955

954956
// Find frame of caller
955-
frame stub_fr = thread()->last_frame();
957+
frame stub_fr = self->last_frame();
956958
CodeBlob* stub_cb = stub_fr.cb();
957959
assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
958-
RegisterMap map(thread(), true, false);
960+
RegisterMap map(self, true, false);
959961
frame caller_fr = stub_fr.sender(&map);
960962

961963
// Should only be poll_return or poll
@@ -976,17 +978,18 @@ void ThreadSafepointState::handle_polling_page_exception() {
976978
// to keep it in a handle.
977979
oop result = caller_fr.saved_oop_result(&map);
978980
assert(oopDesc::is_oop_or_null(result), "must be oop");
979-
return_value = Handle(thread(), result);
981+
return_value = Handle(self, result);
980982
assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
981983
}
982984

983985
// We get here if compiled return polls found a reason to call into the VM.
984986
// One condition for that is that the top frame is not yet safe to use.
985987
// The following stack watermark barrier poll will catch such situations.
986-
StackWatermarkSet::after_unwind(thread());
988+
StackWatermarkSet::after_unwind(self);
987989

988990
// Process pending operation
989-
SafepointMechanism::process_if_requested(thread());
991+
SafepointMechanism::process_if_requested(self);
992+
self->check_and_handle_async_exceptions();
990993

991994
// restore oop result, if any
992995
if (return_oop) {
@@ -1002,21 +1005,21 @@ void ThreadSafepointState::handle_polling_page_exception() {
10021005
assert(real_return_addr == caller_fr.pc(), "must match");
10031006

10041007
// Process pending operation
1005-
SafepointMechanism::process_if_requested(thread());
1008+
SafepointMechanism::process_if_requested(self);
10061009
set_at_poll_safepoint(false);
10071010

10081011
// If we have a pending async exception deoptimize the frame
10091012
// as otherwise we may never deliver it.
1010-
if (thread()->has_async_condition()) {
1011-
ThreadInVMfromJavaNoAsyncException __tiv(thread());
1012-
Deoptimization::deoptimize_frame(thread(), caller_fr.id());
1013+
if (self->has_async_condition()) {
1014+
ThreadInVMfromJavaNoAsyncException __tiv(self);
1015+
Deoptimization::deoptimize_frame(self, caller_fr.id());
10131016
}
10141017

10151018
// If an exception has been installed we must check for a pending deoptimization
10161019
// Deoptimize frame if exception has been thrown.
10171020

1018-
if (thread()->has_pending_exception() ) {
1019-
RegisterMap map(thread(), true, false);
1021+
if (self->has_pending_exception() ) {
1022+
RegisterMap map(self, true, false);
10201023
frame caller_fr = stub_fr.sender(&map);
10211024
if (caller_fr.is_deoptimized_frame()) {
10221025
// The exception patch will destroy registers that are still

‎src/hotspot/share/runtime/safepointMechanism.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void SafepointMechanism::process(JavaThread *thread) {
8080
// Any load in ::block must not pass the global poll load.
8181
// Otherwise we might load an old safepoint counter (for example).
8282
OrderAccess::loadload();
83-
SafepointSynchronize::block(thread);
83+
SafepointSynchronize::block(thread); // Recursive
8484
}
8585

8686
// The call to start_processing fixes the thread's oops and the first few frames.
@@ -92,7 +92,7 @@ void SafepointMechanism::process(JavaThread *thread) {
9292
StackWatermarkSet::start_processing(thread, StackWatermarkKind::gc);
9393

9494
if (thread->handshake_state()->should_process()) {
95-
thread->handshake_state()->process_by_self(); // Recursive
95+
thread->handshake_state()->process_by_self();
9696
}
9797
}
9898

0 commit comments

Comments
 (0)
Failed to load comments.