X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=rts%2FSchedule.c;h=626c097a82ae47e9a1be8cc8b06eeeac1f2413fd;hb=e47c481d3e69601d902ce525f54de9246a80bcda;hp=8c254cc56a6d3011458d3502bee7ec0f530cf3e7;hpb=8f52645bd99ee3e636a34826c0cbfc5939920da1;p=ghc-hetmet.git diff --git a/rts/Schedule.c b/rts/Schedule.c index 8c254cc..626c097 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -150,7 +150,7 @@ static rtsBool scheduleGetRemoteWork(Capability *cap); static void scheduleSendPendingMessages(void); static void scheduleActivateSpark(Capability *cap); #endif -static void schedulePostRunThread(StgTSO *t); +static void schedulePostRunThread(Capability *cap, StgTSO *t); static rtsBool scheduleHandleHeapOverflow( Capability *cap, StgTSO *t ); static void scheduleHandleStackOverflow( Capability *cap, Task *task, StgTSO *t); @@ -622,7 +622,7 @@ run_thread: CCCS = CCS_SYSTEM; #endif - schedulePostRunThread(t); + schedulePostRunThread(cap,t); t = threadStackUnderflow(task,t); @@ -1064,7 +1064,7 @@ scheduleGetRemoteWork(Capability *cap) * ------------------------------------------------------------------------- */ static void -schedulePostRunThread (StgTSO *t) +schedulePostRunThread (Capability *cap, StgTSO *t) { // We have to be able to catch transactions that are in an // infinite loop as a result of seeing an inconsistent view of @@ -1085,8 +1085,7 @@ schedulePostRunThread (StgTSO *t) // ATOMICALLY_FRAME, aborting the (nested) // transaction, and saving the stack of any // partially-evaluated thunks on the heap. - throwToSingleThreaded_(&capabilities[0], t, - NULL, rtsTrue, NULL); + throwToSingleThreaded_(cap, t, NULL, rtsTrue, NULL); ASSERT(get_itbl((StgClosure *)t->sp)->type == ATOMICALLY_FRAME); } @@ -2126,10 +2125,17 @@ threadStackOverflow(Capability *cap, StgTSO *tso) } /* Try to double the current stack size. If that takes us over the - * maximum stack size for this thread, then use the maximum instead. - * Finally round up so the TSO ends up as a whole number of blocks. + * maximum stack size for this thread, then use the maximum instead + * (that is, unless we're already at or over the max size and we + * can't raise the StackOverflow exception (see above), in which + * case just double the size). Finally round up so the TSO ends up as + * a whole number of blocks. */ - new_stack_size = stg_min(tso->stack_size * 2, tso->max_stack_size); + if (tso->stack_size >= tso->max_stack_size) { + new_stack_size = tso->stack_size * 2; + } else { + new_stack_size = stg_min(tso->stack_size * 2, tso->max_stack_size); + } new_tso_size = (lnat)BLOCK_ROUND_UP(new_stack_size * sizeof(W_) + TSO_STRUCT_SIZE)/sizeof(W_); new_tso_size = round_to_mblocks(new_tso_size); /* Be MBLOCK-friendly */