Linker: some extra debugging / logging
[ghc.git] / rts / HeapStackCheck.cmm
index 0659fed..69bff74 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "Cmm.h"
 #include "Updates.h"
+#include "SMPClosureOps.h"
 
 #ifdef __PIC__
 import pthread_mutex_unlock;
@@ -97,10 +98,17 @@ stg_gc_noregs
             && bdescr_link(CurrentNursery) != NULL) {
             HpAlloc = 0;
             CLOSE_NURSERY();
+            Capability_total_allocated(MyCapability()) =
+              Capability_total_allocated(MyCapability()) +
+              BYTES_TO_WDS(bdescr_free(CurrentNursery) -
+                           bdescr_start(CurrentNursery));
             CurrentNursery = bdescr_link(CurrentNursery);
+            bdescr_free(CurrentNursery) = bdescr_start(CurrentNursery);
             OPEN_NURSERY();
             if (Capability_context_switch(MyCapability()) != 0 :: CInt ||
-                Capability_interrupt(MyCapability())      != 0 :: CInt) {
+                Capability_interrupt(MyCapability())      != 0 :: CInt ||
+                (StgTSO_alloc_limit(CurrentTSO) `lt` (0::I64) &&
+                 (TO_W_(StgTSO_flags(CurrentTSO)) & TSO_ALLOC_LIMIT) != 0)) {
                 ret = ThreadYielding;
                 goto sched;
             } else {
@@ -398,8 +406,9 @@ __stg_gc_fun /* explicit stack */
         if (type == ARG_GEN_BIG) {
 #ifdef TABLES_NEXT_TO_CODE
             // bitmap field holds an offset
-            size = StgLargeBitmap_size( StgFunInfoExtra_bitmap(info)
-                                        + %GET_ENTRY(UNTAG(R1)) /* ### */ );
+            size = StgLargeBitmap_size(
+                      TO_W_(StgFunInfoExtraRev_bitmap_offset(info))
+                      + %GET_ENTRY(UNTAG(R1)) /* ### */ );
 #else
             size = StgLargeBitmap_size( StgFunInfoExtra_bitmap(info) );
 #endif
@@ -602,10 +611,10 @@ stg_block_putmvar (P_ mvar, P_ val)
    }
 }
 
-stg_block_blackhole
+stg_block_blackhole (P_ node)
 {
     Sp_adj(-2);
-    Sp(1) = R1;
+    Sp(1) = node;
     Sp(0) = stg_enter_info;
     BLOCK_GENERIC;
 }