vectoriser: fix warning
[ghc-hetmet.git] / rts / Interpreter.c
index 9a38a7e..fa4a46f 100644 (file)
@@ -1356,6 +1356,7 @@ run_BCO:
            void *tok;
            int stk_offset            = BCO_NEXT;
            int o_itbl                = BCO_NEXT;
+           int interruptible         = BCO_NEXT;
            void(*marshall_fn)(void*) = (void (*)(void*))BCO_LIT(o_itbl);
            int ret_dyn_size = 
                RET_DYN_BITMAP_SIZE + RET_DYN_NONPTR_REGS_SIZE
@@ -1444,7 +1445,7 @@ run_BCO:
             ((StgRetDyn *)Sp)->payload[0] = (StgClosure *)obj;
 
            SAVE_STACK_POINTERS;
-           tok = suspendThread(&cap->r);
+           tok = suspendThread(&cap->r, interruptible ? rtsTrue : rtsFalse);
 
            // We already made a copy of the arguments above.
             ffi_call(cif, fn, ret, argptrs);
@@ -1453,6 +1454,14 @@ run_BCO:
            cap = (Capability *)((void *)((unsigned char*)resumeThread(tok) - STG_FIELD_OFFSET(Capability,r)));
            LOAD_STACK_POINTERS;
 
+            if (Sp[0] != (W_)&stg_gc_gen_info) {
+                // the stack is not how we left it.  This probably
+                // means that an exception got raised on exit from the
+                // foreign call, so we should just continue with
+                // whatever is on top of the stack now.
+                RETURN_TO_SCHEDULER_NO_PAUSE(ThreadRunGHC, ThreadYielding);
+            }
+
             // Re-load the pointer to the BCO from the RET_DYN frame,
             // it might have moved during the call.  Also reload the
             // pointers to the components of the BCO.