mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-17 18:37:33 +00:00
Store reserved address space associated with chunk in a field in the chunkstruct, as suggested by rb in <https://info.ravenbrook.com/mail/2014/10/01/13-55-44/0/>.
Copied from Perforce Change: 187104 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
f7536195b3
commit
72209444c0
7 changed files with 14 additions and 36 deletions
|
|
@ -91,7 +91,6 @@ DEFINE_CLASS(AbstractArenaClass, class)
|
|||
class->free = NULL;
|
||||
class->chunkInit = NULL;
|
||||
class->chunkFinish = NULL;
|
||||
class->chunkReserved = NULL;
|
||||
class->compact = ArenaTrivCompact;
|
||||
class->describe = ArenaTrivDescribe;
|
||||
class->pagesMarkAllocated = NULL;
|
||||
|
|
@ -119,7 +118,6 @@ Bool ArenaClassCheck(ArenaClass class)
|
|||
CHECKL(FUNCHECK(class->free));
|
||||
CHECKL(FUNCHECK(class->chunkInit));
|
||||
CHECKL(FUNCHECK(class->chunkFinish));
|
||||
CHECKL(FUNCHECK(class->chunkReserved));
|
||||
CHECKL(FUNCHECK(class->compact));
|
||||
CHECKL(FUNCHECK(class->describe));
|
||||
CHECKL(FUNCHECK(class->pagesMarkAllocated));
|
||||
|
|
@ -669,7 +667,6 @@ Res ControlDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
|
|||
void ArenaChunkInsert(Arena arena, Chunk chunk) {
|
||||
Bool inserted;
|
||||
Tree tree, updatedTree = NULL;
|
||||
Size size;
|
||||
|
||||
AVERT(Arena, arena);
|
||||
AVERT(Chunk, chunk);
|
||||
|
|
@ -683,8 +680,7 @@ void ArenaChunkInsert(Arena arena, Chunk chunk) {
|
|||
arena->chunkTree = updatedTree;
|
||||
RingAppend(&arena->chunkRing, &chunk->arenaRing);
|
||||
|
||||
size = (*arena->class->chunkReserved)(chunk);
|
||||
arena->reserved += size;
|
||||
arena->reserved += ChunkReserved(chunk);
|
||||
|
||||
/* As part of the bootstrap, the first created chunk becomes the primary
|
||||
chunk. This step allows ArenaFreeLandInsert to allocate pages. */
|
||||
|
|
@ -708,7 +704,7 @@ void ArenaChunkRemoved(Arena arena, Chunk chunk)
|
|||
if (arena->primary == chunk)
|
||||
arena->primary = NULL;
|
||||
|
||||
size = (*arena->class->chunkReserved)(chunk);
|
||||
size = ChunkReserved(chunk);
|
||||
AVER(arena->reserved >= size);
|
||||
arena->reserved -= size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ static Res clientChunkCreate(Chunk *chunkReturn, ClientArena clientArena,
|
|||
clChunk = p; chunk = ClientChunk2Chunk(clChunk);
|
||||
|
||||
res = ChunkInit(chunk, arena, alignedBase,
|
||||
AddrAlignDown(limit, ArenaGrainSize(arena)), boot);
|
||||
AddrAlignDown(limit, ArenaGrainSize(arena)),
|
||||
AddrOffset(base, limit), boot);
|
||||
if (res != ResOK)
|
||||
goto failChunkInit;
|
||||
|
||||
|
|
@ -222,17 +223,6 @@ static void ClientChunkFinish(Chunk chunk)
|
|||
}
|
||||
|
||||
|
||||
/* ClientChunkReserved -- return the amount of reserved address space
|
||||
* in a client chunk.
|
||||
*/
|
||||
|
||||
static Size ClientChunkReserved(Chunk chunk)
|
||||
{
|
||||
AVERT(Chunk, chunk);
|
||||
return ChunkSize(chunk);
|
||||
}
|
||||
|
||||
|
||||
/* ClientArenaVarargs -- parse obsolete varargs */
|
||||
|
||||
static void ClientArenaVarargs(ArgStruct args[MPS_ARGS_MAX], va_list varargs)
|
||||
|
|
@ -469,7 +459,6 @@ DEFINE_ARENA_CLASS(ClientArenaClass, this)
|
|||
this->free = ClientArenaFree;
|
||||
this->chunkInit = ClientChunkInit;
|
||||
this->chunkFinish = ClientChunkFinish;
|
||||
this->chunkReserved = ClientChunkReserved;
|
||||
AVERT(ArenaClass, this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -323,7 +323,8 @@ static Res VMChunkCreate(Chunk *chunkReturn, VMArena vmArena, Size size)
|
|||
|
||||
/* Copy VM descriptor into its place in the chunk. */
|
||||
VMCopy(VMChunkVM(vmChunk), vm);
|
||||
res = ChunkInit(VMChunk2Chunk(vmChunk), arena, base, limit, boot);
|
||||
res = ChunkInit(VMChunk2Chunk(vmChunk), arena, base, limit,
|
||||
VMReserved(VMChunkVM(vmChunk)), boot);
|
||||
if (res != ResOK)
|
||||
goto failChunkInit;
|
||||
|
||||
|
|
@ -456,17 +457,6 @@ static void VMChunkFinish(Chunk chunk)
|
|||
}
|
||||
|
||||
|
||||
/* VMChunkReserved -- return the amount of reserved address space in a
|
||||
* VM chunk.
|
||||
*/
|
||||
|
||||
static Size VMChunkReserved(Chunk chunk)
|
||||
{
|
||||
AVERT(Chunk, chunk);
|
||||
return VMReserved(VMChunkVM(Chunk2VMChunk(chunk)));
|
||||
}
|
||||
|
||||
|
||||
/* VMArenaVarargs -- parse obsolete varargs */
|
||||
|
||||
static void VMArenaVarargs(ArgStruct args[MPS_ARGS_MAX], va_list varargs)
|
||||
|
|
@ -1198,7 +1188,6 @@ DEFINE_ARENA_CLASS(VMArenaClass, this)
|
|||
this->free = VMFree;
|
||||
this->chunkInit = VMChunkInit;
|
||||
this->chunkFinish = VMChunkFinish;
|
||||
this->chunkReserved = VMChunkReserved;
|
||||
this->compact = VMCompact;
|
||||
this->describe = VMArenaDescribe;
|
||||
this->pagesMarkAllocated = VMPagesMarkAllocated;
|
||||
|
|
|
|||
|
|
@ -536,7 +536,6 @@ typedef struct mps_arena_class_s {
|
|||
ArenaFreeMethod free;
|
||||
ArenaChunkInitMethod chunkInit;
|
||||
ArenaChunkFinishMethod chunkFinish;
|
||||
ArenaChunkReservedMethod chunkReserved;
|
||||
ArenaCompactMethod compact;
|
||||
ArenaDescribeMethod describe;
|
||||
ArenaPagesMarkAllocatedMethod pagesMarkAllocated;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ typedef Res (*ArenaExtendMethod)(Arena arena, Addr base, Size size);
|
|||
typedef Res (*ArenaGrowMethod)(Arena arena, LocusPref pref, Size size);
|
||||
typedef void (*ArenaFreeMethod)(Addr base, Size size, Pool pool);
|
||||
typedef Res (*ArenaChunkInitMethod)(Chunk chunk, BootBlock boot);
|
||||
typedef Size (*ArenaChunkReservedMethod)(Chunk chunk);
|
||||
typedef void (*ArenaChunkFinishMethod)(Chunk chunk);
|
||||
typedef void (*ArenaCompactMethod)(Arena arena, Trace trace);
|
||||
typedef Res (*ArenaDescribeMethod)(Arena arena, mps_lib_FILE *stream, Count depth);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,8 @@ Bool ChunkCheck(Chunk chunk)
|
|||
|
||||
/* ChunkInit -- initialize generic part of chunk */
|
||||
|
||||
Res ChunkInit(Chunk chunk, Arena arena, Addr base, Addr limit, BootBlock boot)
|
||||
Res ChunkInit(Chunk chunk, Arena arena, Addr base, Addr limit, Size reserved,
|
||||
BootBlock boot)
|
||||
{
|
||||
Size size;
|
||||
Count pages;
|
||||
|
|
@ -192,6 +193,7 @@ Res ChunkInit(Chunk chunk, Arena arena, Addr base, Addr limit, BootBlock boot)
|
|||
chunk->pageShift = pageShift = SizeLog2(chunk->pageSize);
|
||||
chunk->base = base;
|
||||
chunk->limit = limit;
|
||||
chunk->reserved = reserved;
|
||||
size = ChunkSize(chunk);
|
||||
|
||||
chunk->pages = pages = size >> pageShift;
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ typedef struct ChunkStruct {
|
|||
BT allocTable; /* page allocation table */
|
||||
Page pageTable; /* the page table */
|
||||
Count pageTablePages; /* number of pages occupied by page table */
|
||||
Size reserved; /* reserved address space for chunk (including overhead
|
||||
such as losses due to alignment): must not change
|
||||
(or arena reserved calculation will break) */
|
||||
} ChunkStruct;
|
||||
|
||||
|
||||
|
|
@ -159,10 +162,11 @@ typedef struct ChunkStruct {
|
|||
#define ChunkSizeToPages(chunk, size) ((Count)((size) >> (chunk)->pageShift))
|
||||
#define ChunkPage(chunk, pi) (&(chunk)->pageTable[pi])
|
||||
#define ChunkOfTree(tree) PARENT(ChunkStruct, chunkTree, tree)
|
||||
#define ChunkReserved(chunk) RVALUE((chunk)->reserved)
|
||||
|
||||
extern Bool ChunkCheck(Chunk chunk);
|
||||
extern Res ChunkInit(Chunk chunk, Arena arena, Addr base, Addr limit,
|
||||
BootBlock boot);
|
||||
Size reserved, BootBlock boot);
|
||||
extern void ChunkFinish(Chunk chunk);
|
||||
extern Compare ChunkCompare(Tree tree, TreeKey key);
|
||||
extern TreeKey ChunkKey(Tree tree);
|
||||
|
|
|
|||
Loading…
Reference in a new issue