1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-20 04:30:55 -08:00

Attach the pools using a format to a ring in the format, so that when we destroy the format, we can check that no pools are using it.

Copied from Perforce
 Change: 187253
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2014-10-13 22:44:20 +01:00
parent 33aeb61e59
commit f65f1db83e
9 changed files with 22 additions and 1 deletions

View file

@ -22,6 +22,7 @@ Bool FormatCheck(Format format)
CHECKU(Arena, format->arena); CHECKU(Arena, format->arena);
CHECKL(format->serial < format->arena->formatSerial); CHECKL(format->serial < format->arena->formatSerial);
CHECKD_NOSIG(Ring, &format->arenaRing); CHECKD_NOSIG(Ring, &format->arenaRing);
CHECKD_NOSIG(Ring, &format->poolRing);
CHECKL(AlignCheck(format->alignment)); CHECKL(AlignCheck(format->alignment));
/* TODO: Define the concept of the maximum alignment it is possible to /* TODO: Define the concept of the maximum alignment it is possible to
request from the MPS, document and provide an interface to it, and then request from the MPS, document and provide an interface to it, and then
@ -141,6 +142,7 @@ Res FormatCreate(Format *formatReturn, Arena arena, ArgList args)
format->arena = arena; format->arena = arena;
RingInit(&format->arenaRing); RingInit(&format->arenaRing);
RingInit(&format->poolRing);
format->alignment = fmtAlign; format->alignment = fmtAlign;
format->headerSize = fmtHeaderSize; format->headerSize = fmtHeaderSize;
format->scan = fmtScan; format->scan = fmtScan;
@ -168,12 +170,14 @@ Res FormatCreate(Format *formatReturn, Arena arena, ArgList args)
void FormatDestroy(Format format) void FormatDestroy(Format format)
{ {
AVERT(Format, format); AVERT(Format, format);
AVER(RingIsSingle(&format->poolRing));
RingRemove(&format->arenaRing); RingRemove(&format->arenaRing);
format->sig = SigInvalid; format->sig = SigInvalid;
RingFinish(&format->arenaRing); RingFinish(&format->arenaRing);
RingFinish(&format->poolRing);
ControlFree(format->arena, format, sizeof(FormatStruct)); ControlFree(format->arena, format, sizeof(FormatStruct));
} }

View file

@ -110,6 +110,7 @@ typedef struct mps_pool_s { /* generic structure */
RingStruct segRing; /* segs are attached to pool */ RingStruct segRing; /* segs are attached to pool */
Align alignment; /* alignment for units */ Align alignment; /* alignment for units */
Format format; /* format only if class->attr&AttrFMT */ Format format; /* format only if class->attr&AttrFMT */
RingStruct formatRing; /* link in list of pools using format */
PoolFixMethod fix; /* fix method */ PoolFixMethod fix; /* fix method */
double fillMutatorSize; /* bytes filled, mutator buffers */ double fillMutatorSize; /* bytes filled, mutator buffers */
double emptyMutatorSize; /* bytes emptied, mutator buffers */ double emptyMutatorSize; /* bytes emptied, mutator buffers */
@ -410,6 +411,7 @@ typedef struct mps_fmt_s {
Serial serial; /* from arena->formatSerial */ Serial serial; /* from arena->formatSerial */
Arena arena; /* owning arena */ Arena arena; /* owning arena */
RingStruct arenaRing; /* formats are attached to the arena */ RingStruct arenaRing; /* formats are attached to the arena */
RingStruct poolRing; /* ring of pools using the format */
Align alignment; /* alignment of formatted objects */ Align alignment; /* alignment of formatted objects */
mps_fmt_scan_t scan; mps_fmt_scan_t scan;
mps_fmt_skip_t skip; mps_fmt_skip_t skip;

View file

@ -153,6 +153,7 @@ Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args)
RingInit(&pool->arenaRing); RingInit(&pool->arenaRing);
RingInit(&pool->bufferRing); RingInit(&pool->bufferRing);
RingInit(&pool->segRing); RingInit(&pool->segRing);
RingInit(&pool->formatRing);
pool->bufferSerial = (Serial)0; pool->bufferSerial = (Serial)0;
pool->alignment = MPS_PF_ALIGN; pool->alignment = MPS_PF_ALIGN;
pool->format = NULL; pool->format = NULL;
@ -181,6 +182,7 @@ Res PoolInit(Pool pool, Arena arena, PoolClass class, ArgList args)
failInit: failInit:
pool->sig = SigInvalid; /* Leave arena->poolSerial incremented */ pool->sig = SigInvalid; /* Leave arena->poolSerial incremented */
RingFinish(&pool->formatRing);
RingFinish(&pool->segRing); RingFinish(&pool->segRing);
RingFinish(&pool->bufferRing); RingFinish(&pool->bufferRing);
RingFinish(&pool->arenaRing); RingFinish(&pool->arenaRing);
@ -237,10 +239,14 @@ void PoolFinish(Pool pool)
/* Do any class-specific finishing. */ /* Do any class-specific finishing. */
(*pool->class->finish)(pool); (*pool->class->finish)(pool);
/* Detach the pool from the arena, and unsig it. */ /* Detach the pool from the arena and format, and unsig it. */
RingRemove(&pool->arenaRing); RingRemove(&pool->arenaRing);
if (pool->format) {
RingRemove(&pool->formatRing);
}
pool->sig = SigInvalid; pool->sig = SigInvalid;
RingFinish(&pool->formatRing);
RingFinish(&pool->segRing); RingFinish(&pool->segRing);
RingFinish(&pool->bufferRing); RingFinish(&pool->bufferRing);
RingFinish(&pool->arenaRing); RingFinish(&pool->arenaRing);

View file

@ -832,6 +832,7 @@ static Res amcInitComm(Pool pool, RankSet rankSet, ArgList args)
ArgRequire(&arg, args, MPS_KEY_FORMAT); ArgRequire(&arg, args, MPS_KEY_FORMAT);
pool->format = arg.val.format; pool->format = arg.val.format;
RingAppend(&pool->format->poolRing, &pool->formatRing);
if (ArgPick(&arg, args, MPS_KEY_CHAIN)) if (ArgPick(&arg, args, MPS_KEY_CHAIN))
chain = arg.val.chain; chain = arg.val.chain;
else else

View file

@ -838,6 +838,7 @@ Res AMSInitInternal(AMS ams, Format format, Chain chain, unsigned gen,
pool = AMSPool(ams); pool = AMSPool(ams);
AVERT(Pool, pool); AVERT(Pool, pool);
pool->format = format; pool->format = format;
RingAppend(&format->poolRing, &pool->formatRing);
pool->alignment = pool->format->alignment; pool->alignment = pool->format->alignment;
ams->grainShift = SizeLog2(PoolAlignment(pool)); ams->grainShift = SizeLog2(PoolAlignment(pool));

View file

@ -576,6 +576,7 @@ static Res AWLInit(Pool pool, ArgList args)
AVERT(Format, format); AVERT(Format, format);
pool->format = format; pool->format = format;
RingAppend(&format->poolRing, &pool->formatRing);
pool->alignment = format->alignment; pool->alignment = format->alignment;
AVER(FUNCHECK(findDependent)); AVER(FUNCHECK(findDependent));

View file

@ -494,6 +494,7 @@ static Res LOInit(Pool pool, ArgList args)
ArgRequire(&arg, args, MPS_KEY_FORMAT); ArgRequire(&arg, args, MPS_KEY_FORMAT);
pool->format = arg.val.format; pool->format = arg.val.format;
RingAppend(&pool->format->poolRing, &pool->formatRing);
if (ArgPick(&arg, args, MPS_KEY_CHAIN)) if (ArgPick(&arg, args, MPS_KEY_CHAIN))
chain = arg.val.chain; chain = arg.val.chain;
else { else {

View file

@ -388,6 +388,7 @@ static Res SNCInit(Pool pool, ArgList args)
AVERT(Format, format); AVERT(Format, format);
pool->format = format; pool->format = format;
RingAppend(&format->poolRing, &pool->formatRing);
snc->freeSegs = NULL; snc->freeSegs = NULL;
snc->sig = SNCSig; snc->sig = SNCSig;

View file

@ -4,6 +4,10 @@ TEST_HEADER
summary = destroy a format though attached to a pool summary = destroy a format though attached to a pool
language = c language = c
link = testlib.o link = testlib.o
OUTPUT_SPEC
assert = true
assertfile P= format.c
assertcond = RingIsSingle(&format->poolRing)
END_HEADER END_HEADER
*/ */