+ /* Eagerly raise a blocked exception, if there is one */
+ if (StgTSO_blocked_exceptions(CurrentTSO) != END_TSO_QUEUE) {
+ /*
+ * We have to be very careful here, as in killThread#, since
+ * we are about to raise an async exception in the current
+ * thread, which might result in the thread being killed.
+ */
+
+#ifndef REG_R1
+ /*
+ * raiseAsync assumes that the stack is in ThreadRunGHC state,
+ * i.e. with a return address on the top. In unreg mode, the
+ * return value for IO is on top of the return address, so we
+ * need to make a small adjustment here.
+ */
+ Sp_adj(1);
+#endif
+ SAVE_THREAD_STATE();
+ r = foreign "C" maybePerformBlockedException (MyCapability() "ptr",
+ CurrentTSO "ptr") [R1];
+
+ if (r != 0::CInt) {
+ if (StgTSO_what_next(CurrentTSO) == ThreadKilled::I16) {
+ jump stg_threadFinished;
+ } else {
+ LOAD_THREAD_STATE();
+ ASSERT(StgTSO_what_next(CurrentTSO) == ThreadRunGHC::I16);
+ jump %ENTRY_CODE(Sp(0));
+ }
+ }
+#ifndef REG_R1
+ /*
+ * Readjust stack in unregisterised mode if we didn't raise an
+ * exception, see above
+ */
+ else {
+ Sp_adj(-1);
+ }
+#endif
+ }
+