X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreadPaused.c;h=75712b04d613364a3b2dabbf1f3e8b0429473cef;hb=0a5613f40b0e32cf59966e6b56b807cdbe80aa7b;hp=674d0d9ca37cee622ef7cb23bb3ecf18edb95dae;hpb=d600bf7a6afdbfc4a22f9379406a9c6f789a4c2d;p=ghc-hetmet.git diff --git a/rts/ThreadPaused.c b/rts/ThreadPaused.c index 674d0d9..75712b0 100644 --- a/rts/ThreadPaused.c +++ b/rts/ThreadPaused.c @@ -6,13 +6,14 @@ * * ---------------------------------------------------------------------------*/ +// #include "PosixSource.h" #include "Rts.h" -#include "Storage.h" -#include "LdvProfile.h" + +#include "ThreadPaused.h" +#include "sm/Storage.h" #include "Updates.h" #include "RaiseAsync.h" #include "Trace.h" -#include "RtsFlags.h" #include // for memmove() @@ -27,7 +28,7 @@ struct stack_gap { StgWord gap_size; struct stack_gap *next_gap; }; static void -stackSqueeze(StgTSO *tso, StgPtr bottom) +stackSqueeze(Capability *cap, StgTSO *tso, StgPtr bottom) { StgPtr frame; rtsBool prev_was_update_frame; @@ -74,7 +75,7 @@ stackSqueeze(StgTSO *tso, StgPtr bottom) * screw us up if we don't check. */ if (upd->updatee != updatee && !closure_IND(upd->updatee)) { - UPD_IND_NOLOCK(upd->updatee, updatee); + UPD_IND(cap, upd->updatee, updatee); } // now mark this update frame as a stack gap. The gap @@ -141,23 +142,23 @@ stackSqueeze(StgTSO *tso, StgPtr bottom) // indicates unused // { - void *sp; - void *gap_start, *next_gap_start, *gap_end; + StgWord8 *sp; + StgWord8 *gap_start, *next_gap_start, *gap_end; nat chunk_size; - next_gap_start = (void *)((unsigned char*)gap + sizeof(StgUpdateFrame)); + next_gap_start = (StgWord8*)gap + sizeof(StgUpdateFrame); sp = next_gap_start; while ((StgPtr)gap > tso->sp) { // we're working in *bytes* now... gap_start = next_gap_start; - gap_end = (void*) ((unsigned char*)gap_start - gap->gap_size * sizeof(W_)); + gap_end = gap_start - gap->gap_size * sizeof(W_); gap = gap->next_gap; - next_gap_start = (void *)((unsigned char*)gap + sizeof(StgUpdateFrame)); + next_gap_start = (StgWord8*)gap + sizeof(StgUpdateFrame); - chunk_size = (unsigned char*)gap_end - (unsigned char*)next_gap_start; + chunk_size = gap_end - next_gap_start; sp -= chunk_size; memmove(sp, next_gap_start, chunk_size); } @@ -195,6 +196,10 @@ threadPaused(Capability *cap, StgTSO *tso) maybePerformBlockedException (cap, tso); if (tso->what_next == ThreadKilled) { return; } + // NB. Blackholing is *not* optional, we must either do lazy + // blackholing, or eager blackholing consistently. See Note + // [upd-black-hole] in sm/Scav.c. + stack_end = &tso->stack[tso->stack_size]; frame = (StgClosure *)tso->sp; @@ -310,7 +315,13 @@ end: // the number of words we have to shift down is less than the // number of stack words we squeeze away by doing so. if (RtsFlags.GcFlags.squeezeUpdFrames == rtsTrue && - ((weight <= 5 && words_to_squeeze > 0) || weight < words_to_squeeze)) { - stackSqueeze(tso, (StgPtr)frame); + ((weight <= 8 && words_to_squeeze > 0) || weight < words_to_squeeze)) { + // threshold above bumped from 5 to 8 as a result of #2797 + stackSqueeze(cap, tso, (StgPtr)frame); + tso->flags |= TSO_SQUEEZED; + // This flag tells threadStackOverflow() that the stack was + // squeezed, because it may not need to be expanded. + } else { + tso->flags &= ~TSO_SQUEEZED; } }