X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FStorage.c;h=2e43bffdfc5ab6b39325664d99ca8e8acf1a3718;hb=cebecc110be6e53c310326940a311cab7fad84ca;hp=3b9775ede13d3004ec2df2be23461f350c0f89de;hpb=1373cd3085b8dec456e6118c58e940718cb9d559;p=ghc-hetmet.git diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 3b9775e..2e43bff 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -290,7 +290,9 @@ newCAF(StgRegTable *reg, StgClosure* caf) { // Put this CAF on the mutable list for the old generation. ((StgIndStatic *)caf)->saved_info = NULL; - recordMutableCap(caf, regTableToCapability(reg), oldest_gen->no); + if (oldest_gen->no != 0) { + recordMutableCap(caf, regTableToCapability(reg), oldest_gen->no); + } } } @@ -330,31 +332,45 @@ static bdescr * allocNursery (bdescr *tail, nat blocks) { bdescr *bd; - nat i; + nat i, n; - // Allocate a nursery: we allocate fresh blocks one at a time and - // cons them on to the front of the list, not forgetting to update - // the back pointer on the tail of the list to point to the new block. - for (i=0; i < blocks; i++) { - // @LDV profiling - /* - processNursery() in LdvProfile.c assumes that every block group in - the nursery contains only a single block. So, if a block group is - given multiple blocks, change processNursery() accordingly. - */ - bd = allocBlock(); - bd->link = tail; - // double-link the nursery: we might need to insert blocks - if (tail != NULL) { - tail->u.back = bd; - } - initBdescr(bd, g0, g0); - bd->flags = 0; - bd->free = bd->start; - tail = bd; + // We allocate the nursery as a single contiguous block and then + // divide it into single blocks manually. This way we guarantee + // that the nursery blocks are adjacent, so that the processor's + // automatic prefetching works across nursery blocks. This is a + // tiny optimisation (~0.5%), but it's free. + + while (blocks > 0) { + n = stg_min(blocks, BLOCKS_PER_MBLOCK); + blocks -= n; + + bd = allocGroup(n); + for (i = 0; i < n; i++) { + initBdescr(&bd[i], g0, g0); + + bd[i].blocks = 1; + bd[i].flags = 0; + + if (i > 0) { + bd[i].u.back = &bd[i-1]; + } + + if (i+1 < n) { + bd[i].link = &bd[i+1]; + } else { + bd[i].link = tail; + if (tail != NULL) { + tail->u.back = &bd[i]; + } + } + + bd[i].free = bd[i].start; + } + + tail = &bd[0]; } - tail->u.back = NULL; - return tail; + + return &bd[0]; } static void @@ -721,6 +737,16 @@ setTSOLink (Capability *cap, StgTSO *tso, StgTSO *target) } void +setTSOPrev (Capability *cap, StgTSO *tso, StgTSO *target) +{ + if (tso->dirty == 0 && (tso->flags & TSO_LINK_DIRTY) == 0) { + tso->flags |= TSO_LINK_DIRTY; + recordClosureMutated(cap,(StgClosure*)tso); + } + tso->block_info.prev = target; +} + +void dirty_TSO (Capability *cap, StgTSO *tso) { if (tso->dirty == 0 && (tso->flags & TSO_LINK_DIRTY) == 0) {