1093 // This is a poll immediately before a return. The exception handling code
1094 // has already had the effect of causing the return to occur, so the execution
1095 // will continue immediately after the call. In addition, the oopmap at the
1096 // return point does not mark the return value as an oop (if it is), so
1097 // it needs a handle here to be updated.
1098 if( nm->is_at_poll_return(real_return_addr) ) {
1099 // See if return type is an oop.
1100 bool return_oop = nm->method()->is_returning_oop();
1101 Handle return_value;
1102 if (return_oop) {
1103 // The oop result has been saved on the stack together with all
1104 // the other registers. In order to preserve it over GCs we need
1105 // to keep it in a handle.
1106 oop result = caller_fr.saved_oop_result(&map);
1107 assert(oopDesc::is_oop_or_null(result), "must be oop");
1108 return_value = Handle(thread(), result);
1109 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
1110 }
1111
1112 // Block the thread
1113 SafepointSynchronize::block(thread());
1114
1115 // restore oop result, if any
1116 if (return_oop) {
1117 caller_fr.set_saved_oop_result(&map, return_value());
1118 }
1119 }
1120
1121 // This is a safepoint poll. Verify the return address and block.
1122 else {
1123 set_at_poll_safepoint(true);
1124
1125 // verify the blob built the "return address" correctly
1126 assert(real_return_addr == caller_fr.pc(), "must match");
1127
1128 // Block the thread
1129 SafepointSynchronize::block(thread());
1130 set_at_poll_safepoint(false);
1131
1132 // If we have a pending async exception deoptimize the frame
1133 // as otherwise we may never deliver it.
1134 if (thread()->has_async_condition()) {
1135 ThreadInVMfromJavaNoAsyncException __tiv(thread());
1136 Deoptimization::deoptimize_frame(thread(), caller_fr.id());
1137 }
1138
1139 // If an exception has been installed we must check for a pending deoptimization
1140 // Deoptimize frame if exception has been thrown.
1141
1142 if (thread()->has_pending_exception() ) {
1143 RegisterMap map(thread(), true);
1144 frame caller_fr = stub_fr.sender(&map);
1145 if (caller_fr.is_deoptimized_frame()) {
1146 // The exception patch will destroy registers that are still
1147 // live and will be needed during deoptimization. Defer the
1148 // Async exception should have deferred the exception until the
1149 // next safepoint which will be detected when we get into
|
1093 // This is a poll immediately before a return. The exception handling code
1094 // has already had the effect of causing the return to occur, so the execution
1095 // will continue immediately after the call. In addition, the oopmap at the
1096 // return point does not mark the return value as an oop (if it is), so
1097 // it needs a handle here to be updated.
1098 if( nm->is_at_poll_return(real_return_addr) ) {
1099 // See if return type is an oop.
1100 bool return_oop = nm->method()->is_returning_oop();
1101 Handle return_value;
1102 if (return_oop) {
1103 // The oop result has been saved on the stack together with all
1104 // the other registers. In order to preserve it over GCs we need
1105 // to keep it in a handle.
1106 oop result = caller_fr.saved_oop_result(&map);
1107 assert(oopDesc::is_oop_or_null(result), "must be oop");
1108 return_value = Handle(thread(), result);
1109 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
1110 }
1111
1112 // Block the thread
1113 SafepointMechanism::block_if_requested(thread());
1114
1115 // restore oop result, if any
1116 if (return_oop) {
1117 caller_fr.set_saved_oop_result(&map, return_value());
1118 }
1119 }
1120
1121 // This is a safepoint poll. Verify the return address and block.
1122 else {
1123 set_at_poll_safepoint(true);
1124
1125 // verify the blob built the "return address" correctly
1126 assert(real_return_addr == caller_fr.pc(), "must match");
1127
1128 // Block the thread
1129 SafepointMechanism::block_if_requested(thread());
1130 set_at_poll_safepoint(false);
1131
1132 // If we have a pending async exception deoptimize the frame
1133 // as otherwise we may never deliver it.
1134 if (thread()->has_async_condition()) {
1135 ThreadInVMfromJavaNoAsyncException __tiv(thread());
1136 Deoptimization::deoptimize_frame(thread(), caller_fr.id());
1137 }
1138
1139 // If an exception has been installed we must check for a pending deoptimization
1140 // Deoptimize frame if exception has been thrown.
1141
1142 if (thread()->has_pending_exception() ) {
1143 RegisterMap map(thread(), true);
1144 frame caller_fr = stub_fr.sender(&map);
1145 if (caller_fr.is_deoptimized_frame()) {
1146 // The exception patch will destroy registers that are still
1147 // live and will be needed during deoptimization. Defer the
1148 // Async exception should have deferred the exception until the
1149 // next safepoint which will be detected when we get into
|