From bbd83d25bc724ef3e3b2ebc466f1ef2ba0f65d59 Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Wed, 8 Apr 2009 16:04:09 +0100 Subject: [PATCH] Mps br/padding poolamc.c: change amcbufferfill, so that for large requests (> 8 arenaaligns) it gives only requested size; pad the rest. see job001811. the number 8 is provisional... Copied from Perforce Change: 167759 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index c4c57149e96..0895ef06c79 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -1073,11 +1073,29 @@ static Res AMCBufferFill(Addr *baseReturn, Addr *limitReturn, } PoolGenUpdateZones(&gen->pgen, seg); - /* Give the buffer the entire segment to allocate in. */ base = SegBase(seg); *baseReturn = base; - limit = AddrAdd(base, alignedSize); - AVER(limit == SegLimit(seg)); + if(size < 8 * ArenaAlign(arena)) { + /* Small segment: give the buffer the entire seg to allocate in. */ + limit = AddrAdd(base, alignedSize); + AVER(limit == SegLimit(seg)); + } else { + /* Big segment: ONLY give the buffer the size requested, and pad */ + /* the remainder of the segment: see job001811. */ + Size padSize; + + limit = AddrAdd(base, size); + AVER(limit <= SegLimit(seg)); + + padSize = alignedSize - size; + AVER(SizeIsAligned(padSize, pool->alignment)); + AVER(AddrAdd(limit, padSize) == SegLimit(seg)); + if(padSize > 0) { + ShieldExpose(arena, seg); + (*pool->format->pad)(limit, padSize); + ShieldCover(arena, seg); + } + } *limitReturn = limit; return ResOK; }