1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 10:31:37 -08:00

Ams->segring is redundant: we can use pool->segring instead.

Copied from Perforce
 Change: 191044
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2016-04-12 21:58:13 +01:00
parent 9b819498d3
commit 35d2ae678f
2 changed files with 10 additions and 45 deletions

View file

@ -51,7 +51,6 @@ Bool AMSSegCheck(AMSSeg amsseg)
CHECKD(GCSeg, &amsseg->gcSegStruct);
CHECKU(AMS, amsseg->ams);
CHECKL(AMSPool(amsseg->ams) == SegPool(seg));
CHECKD_NOSIG(Ring, &amsseg->segRing);
CHECKL(amsseg->grains == AMSGrains(amsseg->ams, SegSize(seg)));
CHECKL(amsseg->grains > 0);
@ -254,12 +253,7 @@ static Res AMSSegInit(Seg seg, Pool pool, Addr base, Size size, ArgList args)
amsseg->allocTableInUse = FALSE;
amsseg->firstFree = 0;
amsseg->colourTablesInUse = FALSE;
amsseg->ams = ams;
RingInit(&amsseg->segRing);
RingAppend((ams->allocRing)(ams, SegRankSet(seg), size),
&amsseg->segRing);
amsseg->sig = AMSSegSig;
AVERT(AMSSeg, amsseg);
@ -293,9 +287,6 @@ static void AMSSegFinish(Seg seg)
amsDestroyTables(ams, amsseg->allocTable, amsseg->nongreyTable,
amsseg->nonwhiteTable, arena, amsseg->grains);
RingRemove(&amsseg->segRing);
RingFinish(&amsseg->segRing);
amsseg->sig = SigInvalid;
/* finish the superclass fields last */
@ -391,8 +382,6 @@ static Res AMSSegMerge(Seg seg, Seg segHi,
amsseg->newGrains = amsseg->newGrains + amssegHi->newGrains;
/* other fields in amsseg are unaffected */
RingRemove(&amssegHi->segRing);
RingFinish(&amssegHi->segRing);
amssegHi->sig = SigInvalid;
AVERT(AMSSeg, amsseg);
@ -492,12 +481,7 @@ static Res AMSSegSplit(Seg seg, Seg segHi,
amssegHi->firstFree = 0;
/* use colour tables if the segment is white */
amssegHi->colourTablesInUse = (SegWhite(segHi) != TraceSetEMPTY);
amssegHi->ams = ams;
RingInit(&amssegHi->segRing);
RingAppend((ams->allocRing)(ams, SegRankSet(segHi), SegSize(segHi)),
&amssegHi->segRing);
amssegHi->sig = AMSSegSig;
AVERT(AMSSeg, amsseg);
AVERT(AMSSeg, amssegHi);
@ -637,16 +621,6 @@ DEFINE_CLASS(AMSSegClass, class)
}
/* AMSPoolRing -- the ring of segments in the pool */
static Ring AMSPoolRing(AMS ams, RankSet rankSet, Size size)
{
/* arguments checked in the caller */
UNUSED(rankSet); UNUSED(size);
return &ams->segRing;
}
/* AMSSegSizePolicy
*
* Picks a segment size. This policy simply rounds the size
@ -843,11 +817,8 @@ Res AMSInitInternal(AMS ams, Format format, Chain chain, unsigned gen,
ams->shareAllocTable = shareAllocTable;
RingInit(&ams->segRing);
/* The next four might be overridden by a subclass. */
ams->segSize = AMSSegSizePolicy;
ams->allocRing = AMSPoolRing;
ams->segsDestroy = AMSSegsDestroy;
ams->segClass = AMSSegClassGet;
@ -873,7 +844,6 @@ void AMSFinish(Pool pool)
(ams->segsDestroy)(ams);
/* can't invalidate the AMS until we've destroyed all the segs */
ams->sig = SigInvalid;
RingFinish(&ams->segRing);
PoolGenFinish(&ams->pgen);
}
@ -945,6 +915,7 @@ static Res AMSBufferFill(Addr *baseReturn, Addr *limitReturn,
Res res;
AMS ams;
Seg seg;
AMSSeg amsseg;
Ring node, ring, nextNode; /* for iterating over the segments */
Index base = 0, limit = 0; /* suppress "may be used uninitialized" */
Addr baseAddr, limitAddr;
@ -966,14 +937,13 @@ static Res AMSBufferFill(Addr *baseReturn, Addr *limitReturn,
AVER(PoolArena(pool)->busyTraces == PoolArena(pool)->flippedTraces);
rankSet = BufferRankSet(buffer);
ring = (ams->allocRing)(ams, rankSet, size);
ring = PoolSegRing(AMSPool(ams));
/* <design/poolams/#fill.slow> */
RING_FOR(node, ring, nextNode) {
AMSSeg amsseg = RING_ELT(AMSSeg, segRing, node);
seg = SegOfPoolRing(node);
amsseg = Seg2AMSSeg(seg);
AVERT_CRITICAL(AMSSeg, amsseg);
if (amsseg->freeGrains >= AMSGrains(ams, size)) {
seg = AMSSeg2Seg(amsseg);
if (SegRankSet(seg) == rankSet
&& SegBuffer(seg) == NULL
/* Can't use a white or grey segment, see d.m.p.fill.colour. */
@ -1658,9 +1628,9 @@ static void AMSFreeWalk(Pool pool, FreeBlockVisitor f, void *p)
ams = PoolAMS(pool);
AVERT(AMS, ams);
ring = &ams->segRing;
ring = PoolSegRing(AMSPool(ams));
RING_FOR(node, ring, nextNode) {
AMSSegFreeWalk(RING_ELT(AMSSeg, segRing, node), f, p);
AMSSegFreeWalk(Seg2AMSSeg(SegOfPoolRing(node)), f, p);
}
}
@ -1700,7 +1670,7 @@ static Size AMSFreeSize(Pool pool)
static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
{
AMS ams;
Ring node, nextNode;
Ring ring, node, nextNode;
Res res;
if (!TESTT(Pool, pool))
@ -1727,9 +1697,9 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
if (res != ResOK)
return res;
RING_FOR(node, &ams->segRing, nextNode) {
AMSSeg amsseg = RING_ELT(AMSSeg, segRing, node);
res = SegDescribe(AMSSeg2Seg(amsseg), stream, depth + 2);
ring = PoolSegRing(AMSPool(ams));
RING_FOR(node, ring, nextNode) {
res = SegDescribe(SegOfPoolRing(node), stream, depth + 2);
if (res != ResOK)
return res;
}
@ -1830,8 +1800,6 @@ Bool AMSCheck(AMS ams)
CHECKL(PoolAlignment(AMSPool(ams)) == AMSPool(ams)->format->alignment);
CHECKD(PoolGen, &ams->pgen);
CHECKL(FUNCHECK(ams->segSize));
CHECKD_NOSIG(Ring, &ams->segRing);
CHECKL(FUNCHECK(ams->allocRing));
CHECKL(FUNCHECK(ams->segsDestroy));
CHECKL(FUNCHECK(ams->segClass));

View file

@ -44,8 +44,6 @@ typedef struct AMSStruct {
PoolGenStruct pgen; /* generation representing the pool */
Size size; /* total segment size of the pool */
AMSSegSizePolicyFunction segSize; /* SegSize policy */
RingStruct segRing; /* ring of segments in the pool */
AMSRingFunction allocRing; /* fn to get the ring to allocate from */
AMSSegsDestroyFunction segsDestroy;
AMSSegClassFunction segClass;/* fn to get the class for segments */
Bool shareAllocTable; /* the alloc table is also used as white table */
@ -56,7 +54,6 @@ typedef struct AMSStruct {
typedef struct AMSSegStruct {
GCSegStruct gcSegStruct; /* superclass fields must come first */
AMS ams; /* owning ams */
RingStruct segRing; /* ring that this seg belongs to */
Count grains; /* total grains */
Count freeGrains; /* free grains */
Count oldGrains; /* grains allocated prior to last collection */