Skip to content

Commit

Permalink
Change generation accounting to match behaviour of the MPS before the…
Browse files Browse the repository at this point in the history
… job004007 pull request. Edits are currently hacky and manual, taking into account refactoring since job004007
  • Loading branch information
thejayps committed Nov 9, 2024
1 parent e2f9497 commit d71e84d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
21 changes: 11 additions & 10 deletions code/locus.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,16 @@ Res PoolGenAlloc(Seg *segReturn, PoolGen pgen, SegClass klass, Size size,
* <design/strategy#.accounting.op.fill>
*/

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;
}


Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/locus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion code/poolamc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/poolams.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/poolawl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion code/poollo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d71e84d

Please sign in to comment.