don't shrink the stack smaller than the value set by +RTS -k<size>
authorSimon Marlow <marlowsd@gmail.com>
Fri, 29 May 2009 09:08:27 +0000 (09:08 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Fri, 29 May 2009 09:08:27 +0000 (09:08 +0000)
includes/Block.h
rts/Schedule.c

index 28e0374..ec894da 100644 (file)
@@ -258,5 +258,14 @@ round_to_mblocks(StgWord words)
     return words;
 }
 
+INLINE_HEADER StgWord
+round_up_to_mblocks(StgWord words)
+{
+    words += FIRST_BLOCK_OFF/sizeof(W_);
+    words = ((words / MBLOCK_SIZE_W) + 1) * MBLOCK_SIZE_W;
+    words -= FIRST_BLOCK_OFF/sizeof(W_);
+    return words;
+}
+
 #endif /* !CMINUSMINUS */
 #endif /* BLOCK_H */
index f376286..66860a7 100644 (file)
@@ -2442,6 +2442,8 @@ threadStackUnderflow (Task *task STG_UNUSED, StgTSO *tso)
         (tso_size_w - BLOCKS_PER_MBLOCK*BLOCK_SIZE_W) % MBLOCK_SIZE_W != 0 ||
           // or TSO is not a whole number of megablocks (ensuring
           // precondition of splitLargeBlock() below)
+        (tso_size_w <= round_up_to_mblocks(RtsFlags.GcFlags.initialStkSize)) ||
+          // or TSO is smaller than the minimum stack size (rounded up)
         (nat)(tso->stack + tso->stack_size - tso->sp) > tso->stack_size / 4) 
           // or stack is using more than 1/4 of the available space
     {