Ensure runhaskell is rebuild in stage2
[ghc-hetmet.git] / rts / HeapStackCheck.cmm
index 3c66e78..333d0c0 100644 (file)
 
 #include "Cmm.h"
 
+#ifdef __PIC__
+import pthread_mutex_unlock;
+#endif
+import EnterCriticalSection;
+import LeaveCriticalSection;
+
 /* Stack/Heap Check Failure
  * ------------------------
  *
@@ -551,8 +557,6 @@ INFO_TABLE_RET( stg_ut_1_0_unreg, RET_SMALL, "ptr" W_ unused )
         +---------------------+
          |      f_closure      |
         +---------------------+
-         |         tag         |
-        +- - - - - - - - - - -+
          |        size         |
         +---------------------+
          |   stg_gc_fun_info   |
@@ -569,10 +573,7 @@ __stg_gc_fun
     W_ size;
     W_ info;
     W_ type;
-    W_ tag;
-    W_ ret_fun;
 
-    tag  = GETTAG(R1);
     info = %GET_FUN_INFO(UNTAG(R1));
 
     // cache the size
@@ -596,11 +597,9 @@ __stg_gc_fun
 #ifdef NO_ARG_REGS
     // we don't have to save any registers away
     Sp_adj(-3);
+    Sp(2) = R1;
+    Sp(1) = size;
     Sp(0) = stg_gc_fun_info;
-    ret_fun = Sp;
-    StgRetFun_size(ret_fun) = HALF_W_(size);
-    StgRetFun_tag(ret_fun)  = HALF_W_(tag);
-    StgRetFun_fun(ret_fun)  = R1;
     GC_GENERIC
 #else
     W_ type;
@@ -609,11 +608,9 @@ __stg_gc_fun
     if (type == ARG_GEN || type == ARG_GEN_BIG) {
         // regs already saved by the heap check code
         Sp_adj(-3);
+        Sp(2) = R1;
+        Sp(1) = size;
         Sp(0) = stg_gc_fun_info;
-        ret_fun = Sp;
-        StgRetFun_size(ret_fun) = HALF_W_(size);
-        StgRetFun_tag(ret_fun)  = HALF_W_(tag);
-        StgRetFun_fun(ret_fun)  = R1;
         // DEBUG_ONLY(foreign "C" debugBelch("stg_fun_gc_gen(ARG_GEN)"););
         GC_GENERIC
     } else { 
@@ -633,12 +630,7 @@ __stg_gc_fun
 
 INFO_TABLE_RET( stg_gc_fun, RET_FUN )
 {
-    // Grab the fun, but remember to add in the tag.  The GC doesn't
-    // guarantee to retain the tag on the pointer, so we have to do
-    // it manually, because the function entry code assumes it.
-    W_ ret_fun;
-    ret_fun = Sp;
-    R1 = StgRetFun_fun(ret_fun) | TO_W_(StgRetFun_tag(ret_fun));
+    R1 = Sp(2);
     Sp_adj(3);
 #ifdef NO_ARG_REGS
     // Minor optimisation: there are no argument registers to load up,
@@ -835,7 +827,9 @@ INFO_TABLE_RET( stg_block_takemvar, RET_SMALL, "ptr" W_ unused )
 stg_block_takemvar_finally
 {
 #ifdef THREADED_RTS
-    unlockClosure(R3, stg_EMPTY_MVAR_info);
+    unlockClosure(R3, stg_MVAR_DIRTY_info);
+#else
+    SET_INFO(R3, stg_MVAR_DIRTY_info);
 #endif
     jump StgReturn;
 }
@@ -861,7 +855,9 @@ INFO_TABLE_RET( stg_block_putmvar, RET_SMALL, "ptr" W_ unused1, "ptr" W_ unused2
 stg_block_putmvar_finally
 {
 #ifdef THREADED_RTS
-    unlockClosure(R3, stg_FULL_MVAR_info);
+    unlockClosure(R3, stg_MVAR_DIRTY_info);
+#else
+    SET_INFO(R3, stg_MVAR_DIRTY_info);
 #endif
     jump StgReturn;
 }
@@ -883,7 +879,7 @@ stg_block_blackhole_finally
     // The last thing we do is release sched_lock, which is
     // preventing other threads from accessing blackhole_queue and
     // picking up this thread before we are finished with it.
-    foreign "C" RELEASE_LOCK(sched_mutex "ptr");
+    RELEASE_LOCK(sched_mutex "ptr");
 #endif
     jump StgReturn;
 }