@@ -943,19 +943,21 @@ void ThreadSafepointState::print_on(outputStream *st) const {
943
943
944
944
// Process pending operation.
945
945
void ThreadSafepointState::handle_polling_page_exception () {
946
+ JavaThread* self = thread ();
947
+ assert (self == Thread::current ()->as_Java_thread (), " must be self" );
946
948
947
949
// 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 ();
949
951
950
952
CodeBlob *cb = CodeCache::find_blob (real_return_addr);
951
953
assert (cb != NULL && cb->is_compiled (), " return address should be in nmethod" );
952
954
CompiledMethod* nm = (CompiledMethod*)cb;
953
955
954
956
// Find frame of caller
955
- frame stub_fr = thread () ->last_frame ();
957
+ frame stub_fr = self ->last_frame ();
956
958
CodeBlob* stub_cb = stub_fr.cb ();
957
959
assert (stub_cb->is_safepoint_stub (), " must be a safepoint stub" );
958
- RegisterMap map (thread () , true , false );
960
+ RegisterMap map (self , true , false );
959
961
frame caller_fr = stub_fr.sender (&map);
960
962
961
963
// Should only be poll_return or poll
@@ -976,17 +978,18 @@ void ThreadSafepointState::handle_polling_page_exception() {
976
978
// to keep it in a handle.
977
979
oop result = caller_fr.saved_oop_result (&map);
978
980
assert (oopDesc::is_oop_or_null (result), " must be oop" );
979
- return_value = Handle (thread () , result);
981
+ return_value = Handle (self , result);
980
982
assert (Universe::heap ()->is_in_or_null (result), " must be heap pointer" );
981
983
}
982
984
983
985
// We get here if compiled return polls found a reason to call into the VM.
984
986
// One condition for that is that the top frame is not yet safe to use.
985
987
// The following stack watermark barrier poll will catch such situations.
986
- StackWatermarkSet::after_unwind (thread () );
988
+ StackWatermarkSet::after_unwind (self );
987
989
988
990
// Process pending operation
989
- SafepointMechanism::process_if_requested (thread ());
991
+ SafepointMechanism::process_if_requested (self);
992
+ self->check_and_handle_async_exceptions ();
990
993
991
994
// restore oop result, if any
992
995
if (return_oop) {
@@ -1002,21 +1005,21 @@ void ThreadSafepointState::handle_polling_page_exception() {
1002
1005
assert (real_return_addr == caller_fr.pc (), " must match" );
1003
1006
1004
1007
// Process pending operation
1005
- SafepointMechanism::process_if_requested (thread () );
1008
+ SafepointMechanism::process_if_requested (self );
1006
1009
set_at_poll_safepoint (false );
1007
1010
1008
1011
// If we have a pending async exception deoptimize the frame
1009
1012
// 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 ());
1013
1016
}
1014
1017
1015
1018
// If an exception has been installed we must check for a pending deoptimization
1016
1019
// Deoptimize frame if exception has been thrown.
1017
1020
1018
- if (thread () ->has_pending_exception () ) {
1019
- RegisterMap map (thread () , true , false );
1021
+ if (self ->has_pending_exception () ) {
1022
+ RegisterMap map (self , true , false );
1020
1023
frame caller_fr = stub_fr.sender (&map);
1021
1024
if (caller_fr.is_deoptimized_frame ()) {
1022
1025
// The exception patch will destroy registers that are still
0 commit comments