+
+ StgTSO_flags(CurrentTSO) = %lobits32(
+ TO_W_(StgTSO_flags(CurrentTSO)) & ~(TSO_BLOCKEX|TSO_INTERRUPTIBLE));
+
+ /* 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.
+ *
+ * Now, if we are to raise an exception in the current
+ * thread, there might be an update frame above us on the
+ * stack due to unsafePerformIO. Hence, the stack must
+ * make sense, because it is about to be snapshotted into
+ * an AP_STACK.
+ */
+ Sp_adj(-3);
+ Sp(2) = stg_ap_v_info;
+ Sp(1) = R1;
+ Sp(0) = stg_enter_info;
+
+ 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));
+ }
+ } else {
+ /* we'll just call R1 directly, below */
+ Sp_adj(3);
+ }
+ }
+