diff --git a/code/locus.c b/code/locus.c index d4fb3a86c6..aaf3ac81ab 100644 --- a/code/locus.c +++ b/code/locus.c @@ -652,13 +652,16 @@ Res PoolGenAlloc(Seg *segReturn, PoolGen pgen, SegClass klass, Size size, * */ -void PoolGenAccountForFill(PoolGen pgen, Size size) +void PoolGenAccountForFill(PoolGen pgen, Size size, Bool deferred) { AVERT(PoolGen, pgen); AVER(pgen->freeSize >= size); pgen->freeSize -= size; - pgen->bufferedSize += size; + if (deferred) + pgen->newDeferredSize += size; + else + pgen->newSize += size; } @@ -676,13 +679,13 @@ void PoolGenAccountForEmpty(PoolGen pgen, Size used, Size unused, Bool deferred) { AVERT(PoolGen, pgen); AVERT(Bool, deferred); + + UNUSED(used); - AVER(pgen->bufferedSize >= used + unused); - pgen->bufferedSize -= used + unused; if (deferred) { - pgen->newDeferredSize += used; + pgen->newDeferredSize -= unused; } else { - pgen->newSize += used; + pgen->newSize -= unused; } pgen->freeSize += unused; } @@ -704,15 +707,13 @@ void PoolGenAccountForAge(PoolGen pgen, Size wasBuffered, Size wasNew, AVERT(PoolGen, pgen); AVERT(Bool, deferred); - AVER(pgen->bufferedSize >= wasBuffered); - pgen->bufferedSize -= wasBuffered; if (deferred) { AVER(pgen->newDeferredSize >= wasNew); - pgen->newDeferredSize -= wasNew; + pgen->newDeferredSize -= wasNew + wasBuffered; pgen->oldDeferredSize += wasBuffered + wasNew; } else { AVER(pgen->newSize >= wasNew); - pgen->newSize -= wasNew; + pgen->newSize -= wasNew + wasBuffered; pgen->oldSize += wasBuffered + wasNew; } } diff --git a/code/locus.h b/code/locus.h index 10867596d7..1ab41eb206 100644 --- a/code/locus.h +++ b/code/locus.h @@ -116,7 +116,7 @@ extern Res PoolGenAlloc(Seg *segReturn, PoolGen pgen, SegClass klass, Size size, ArgList args); extern void PoolGenFree(PoolGen pgen, Seg seg, Size freeSize, Size oldSize, Size newSize, Bool deferred); -extern void PoolGenAccountForFill(PoolGen pgen, Size size); +extern void PoolGenAccountForFill(PoolGen pgen, Size size, Bool deferred); extern void PoolGenAccountForEmpty(PoolGen pgen, Size used, Size unused, Bool deferred); extern void PoolGenAccountForAge(PoolGen pgen, Size wasBuffered, Size wasNew, Bool deferred); extern void PoolGenAccountForReclaim(PoolGen pgen, Size reclaimed, Bool deferred); diff --git a/code/poolamc.c b/code/poolamc.c index c526c8e56f..f07d67a80d 100644 --- a/code/poolamc.c +++ b/code/poolamc.c @@ -990,7 +990,7 @@ static Res AMCBufferFill(Addr *baseReturn, Addr *limitReturn, } } - PoolGenAccountForFill(pgen, SegSize(seg)); + PoolGenAccountForFill(pgen, SegSize(seg), MustBeA(amcSeg, seg)->deferred); MustBeA(amcSeg, seg)->accountedAsBuffered = TRUE; *baseReturn = base; diff --git a/code/poolams.c b/code/poolams.c index a76c5a86d8..1762632a69 100644 --- a/code/poolams.c +++ b/code/poolams.c @@ -939,7 +939,7 @@ static Bool amsSegBufferFill(Addr *baseReturn, Addr *limitReturn, segBase = SegBase(seg); base = PoolAddrOfIndex(segBase, pool, baseIndex); limit = PoolAddrOfIndex(segBase, pool, limitIndex); - PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit)); + PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit), FALSE); DebugPoolFreeCheck(pool, base, limit); *baseReturn = base; diff --git a/code/poolawl.c b/code/poolawl.c index 17347d7af5..34f689b4f1 100644 --- a/code/poolawl.c +++ b/code/poolawl.c @@ -500,7 +500,7 @@ static Bool awlSegBufferFill(Addr *baseReturn, Addr *limitReturn, segBase = SegBase(seg); base = PoolAddrOfIndex(segBase, pool, baseIndex); limit = PoolAddrOfIndex(segBase, pool, limitIndex); - PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit)); + PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit), FALSE); *baseReturn = base; *limitReturn = limit; diff --git a/code/poollo.c b/code/poollo.c index 61311f049b..15c41f0c3b 100644 --- a/code/poollo.c +++ b/code/poollo.c @@ -250,7 +250,7 @@ static Bool loSegBufferFill(Addr *baseReturn, Addr *limitReturn, segBase = SegBase(seg); base = PoolAddrOfIndex(segBase, pool, baseIndex); limit = PoolAddrOfIndex(segBase, pool, limitIndex); - PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit)); + PoolGenAccountForFill(PoolSegPoolGen(pool, seg), AddrOffset(base, limit), FALSE); *baseReturn = base; *limitReturn = limit;