mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-18 08:51:45 -08:00
Adding fault to space. adding access methods
Copied from Perforce Change: 15068 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
ff573855f4
commit
c85dab178d
4 changed files with 122 additions and 98 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== POOLS ====
|
||||
*
|
||||
* $HopeName: MMsrc/!pool.c(trunk.3)$
|
||||
* $HopeName: MMsrc/!pool.c(trunk.4)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include "space.h"
|
||||
#include "ref.h"
|
||||
#include "trace.h"
|
||||
#include "prot.h"
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
|
@ -173,6 +174,12 @@ void PoolReclaim(Pool pool, Trace trace)
|
|||
(*pool->class->reclaim)(pool, trace);
|
||||
}
|
||||
|
||||
void PoolAccess(Pool pool, Addr seg, ProtMode mode)
|
||||
{
|
||||
if(pool->class->access != NULL)
|
||||
(*pool->class->access)(pool, seg, mode);
|
||||
}
|
||||
|
||||
|
||||
Error PoolDescribe(Pool pool, LibStream stream)
|
||||
{
|
||||
|
|
@ -180,12 +187,12 @@ Error PoolDescribe(Pool pool, LibStream stream)
|
|||
AVER(stream != NULL);
|
||||
|
||||
LibFormat(stream,
|
||||
"Pool %p {\n"
|
||||
" Class %s\n"
|
||||
" alignment %lu\n",
|
||||
pool,
|
||||
pool->class->name,
|
||||
(unsigned long)pool->alignment);
|
||||
"Pool %p {\n"
|
||||
" Class %s\n"
|
||||
" alignment %lu\n",
|
||||
pool,
|
||||
pool->class->name,
|
||||
(unsigned long)pool->alignment);
|
||||
|
||||
if(DequeLength(&pool->bufferDeque) > 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== MANUAL FIXED SMALL UNIT POOL ====
|
||||
*
|
||||
* $HopeName: MMsrc/!poolmfs.c(trunk.4)$
|
||||
* $HopeName: MMsrc/!poolmfs.c(trunk.5)$
|
||||
*
|
||||
* Copyright (C) 1994,1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -70,9 +70,10 @@ PoolClass PoolClassMFS(void)
|
|||
sizeof(PoolMFSStruct), offsetof(PoolMFSStruct, poolStruct),
|
||||
create, destroy,
|
||||
alloc, free_,
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* comdemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* comdemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
NULL, /* access */
|
||||
describe);
|
||||
return(&PoolClassMFSStruct);
|
||||
}
|
||||
|
|
|
|||
153
mps/src/poolmv.c
153
mps/src/poolmv.c
|
|
@ -1,6 +1,6 @@
|
|||
/* ==== MANUAL VARIABLE POOL ====
|
||||
*
|
||||
* $HopeName: MMsrc/!poolmv.c(trunk.4)$
|
||||
* $HopeName: MMsrc/!poolmv.c(trunk.5)$
|
||||
*
|
||||
* Copyright (C) 1994, 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -44,8 +44,8 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
|
||||
#define BLOCKPOOL(mv) (PoolMFSPool(&(mv)->blockPoolStruct))
|
||||
#define SPANPOOL(mv) (PoolMFSPool(&(mv)->spanPoolStruct))
|
||||
#define BLOCKPOOL(mv) (PoolMFSPool(&(mv)->blockPoolStruct))
|
||||
#define SPANPOOL(mv) (PoolMFSPool(&(mv)->spanPoolStruct))
|
||||
|
||||
|
||||
/* == Class Structure == */
|
||||
|
|
@ -65,9 +65,10 @@ PoolClass PoolClassMV(void)
|
|||
sizeof(PoolMVStruct), offsetof(PoolMVStruct, poolStruct),
|
||||
create, destroy,
|
||||
alloc, free_,
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* condemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
NULL, NULL, /* bufferCreate, bufferDestroy */
|
||||
NULL, NULL, NULL, /* condemn, mark, scan */
|
||||
NULL, NULL, /* fix, relcaim */
|
||||
NULL, /* access */
|
||||
describe);
|
||||
return(&PoolClassMVStruct);
|
||||
}
|
||||
|
|
@ -115,12 +116,12 @@ static Bool BlockIsValid(Block block, ValidationType validParam)
|
|||
typedef struct SpanStruct
|
||||
{
|
||||
struct SpanStruct *next;
|
||||
Addr seg; /* segment underlying the span */
|
||||
BlockStruct base; /* sentinel at base of span */
|
||||
BlockStruct limit; /* sentinel at limit of span */
|
||||
Block blocks; /* allocated blocks */
|
||||
Addr space; /* total free space in segment */
|
||||
unsigned blockCount; /* number of blocks on chain */
|
||||
Addr seg; /* segment underlying the span */
|
||||
BlockStruct base; /* sentinel at base of span */
|
||||
BlockStruct limit; /* sentinel at limit of span */
|
||||
Block blocks; /* allocated blocks */
|
||||
Addr space; /* total free space in segment */
|
||||
unsigned blockCount; /* number of blocks on chain */
|
||||
} SpanStruct, *Span;
|
||||
|
||||
|
||||
|
|
@ -360,14 +361,14 @@ static Bool SpanAlloc(Addr *addrReturn, Span span, Addr size,
|
|||
|
||||
if(gap == size && block->next != &span->limit)
|
||||
{
|
||||
Block old = block->next;
|
||||
block->limit = old->limit;
|
||||
block->next = old->next;
|
||||
PoolFree(blockPool, (Addr)old, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
Block old = block->next;
|
||||
block->limit = old->limit;
|
||||
block->next = old->next;
|
||||
PoolFree(blockPool, (Addr)old, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
}
|
||||
else
|
||||
block->limit += size;
|
||||
block->limit += size;
|
||||
|
||||
span->space -= size;
|
||||
*addrReturn = new;
|
||||
|
|
@ -415,48 +416,48 @@ static Error SpanFree(Span span, Addr base, Addr limit, Pool blockPool)
|
|||
{
|
||||
if(!isSentinel && block->base == base && limit == block->limit)
|
||||
{
|
||||
AVER(block->next != NULL); /* should at least be a sentinel */
|
||||
*prev = block->next;
|
||||
PoolFree(blockPool, (Addr)block, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
AVER(block->next != NULL); /* should at least be a sentinel */
|
||||
*prev = block->next;
|
||||
PoolFree(blockPool, (Addr)block, sizeof(BlockStruct));
|
||||
--span->blockCount;
|
||||
}
|
||||
else if(!isBase && block->base == base)
|
||||
block->base = limit;
|
||||
block->base = limit;
|
||||
else if(!isLimit && limit == block->limit)
|
||||
block->limit = base;
|
||||
block->limit = base;
|
||||
else
|
||||
{
|
||||
Error e;
|
||||
Block new;
|
||||
Error e;
|
||||
Block new;
|
||||
|
||||
/* The freed area is buried in the middle of the block, so the */
|
||||
/* block must be split into two parts. */
|
||||
/* The freed area is buried in the middle of the block, so the */
|
||||
/* block must be split into two parts. */
|
||||
|
||||
e = PoolAlloc((Addr *)&new, blockPool, sizeof(BlockStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
e = PoolAlloc((Addr *)&new, blockPool, sizeof(BlockStruct));
|
||||
if(e != ErrSUCCESS) return(e);
|
||||
|
||||
/* If the freed area is in the base sentinel then insert the new */
|
||||
/* descriptor after it, otherwise insert before. */
|
||||
if(isBase)
|
||||
{
|
||||
new->base = limit;
|
||||
new->limit = block->limit;
|
||||
block->limit = base;
|
||||
new->next = block->next;
|
||||
AVER(new->next != NULL); /* should at least be a sentinel */
|
||||
block->next = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->base = block->base;
|
||||
new->limit = base;
|
||||
block->base = limit;
|
||||
new->next = block;
|
||||
*prev = new;
|
||||
}
|
||||
/* If the freed area is in the base sentinel then insert the new */
|
||||
/* descriptor after it, otherwise insert before. */
|
||||
if(isBase)
|
||||
{
|
||||
new->base = limit;
|
||||
new->limit = block->limit;
|
||||
block->limit = base;
|
||||
new->next = block->next;
|
||||
AVER(new->next != NULL); /* should at least be a sentinel */
|
||||
block->next = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
new->base = block->base;
|
||||
new->limit = base;
|
||||
block->base = limit;
|
||||
new->next = block;
|
||||
*prev = new;
|
||||
}
|
||||
|
||||
AVER(ISVALID(Block, new));
|
||||
++span->blockCount;
|
||||
AVER(ISVALID(Block, new));
|
||||
++span->blockCount;
|
||||
}
|
||||
|
||||
AVER(ISVALID(Block, block));
|
||||
|
|
@ -507,15 +508,15 @@ static Error alloc(Addr *pReturn, Pool pool, Size size)
|
|||
{
|
||||
if(size <= span->space)
|
||||
{
|
||||
Addr new;
|
||||
Addr new;
|
||||
|
||||
if(SpanAlloc(&new, span, size, BLOCKPOOL(poolMV)))
|
||||
{
|
||||
poolMV->space -= size;
|
||||
AVER(IsAligned(pool->alignment, new));
|
||||
*pReturn = new;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
if(SpanAlloc(&new, span, size, BLOCKPOOL(poolMV)))
|
||||
{
|
||||
poolMV->space -= size;
|
||||
AVER(IsAligned(pool->alignment, new));
|
||||
*pReturn = new;
|
||||
return ErrSUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
span = span->next;
|
||||
|
|
@ -674,24 +675,24 @@ static Error describe(Pool pool, LibStream stream)
|
|||
|
||||
for(j=i; j<i+length && j<span->limit.limit; j+=step)
|
||||
{
|
||||
if(j == block->base) {
|
||||
if(j+step == block->limit)
|
||||
LibPutChar(stream, '@');
|
||||
else
|
||||
LibPutChar(stream, '[');
|
||||
}
|
||||
else if(j+step == block->limit)
|
||||
LibPutChar(stream, ']');
|
||||
else if(j > block->base && j < block->limit)
|
||||
LibPutChar(stream, '=');
|
||||
else
|
||||
LibPutChar(stream, '.');
|
||||
if(j == block->base) {
|
||||
if(j+step == block->limit)
|
||||
LibPutChar(stream, '@');
|
||||
else
|
||||
LibPutChar(stream, '[');
|
||||
}
|
||||
else if(j+step == block->limit)
|
||||
LibPutChar(stream, ']');
|
||||
else if(j > block->base && j < block->limit)
|
||||
LibPutChar(stream, '=');
|
||||
else
|
||||
LibPutChar(stream, '.');
|
||||
|
||||
if(j >= block->limit)
|
||||
{
|
||||
block = block->next;
|
||||
AVER(block != NULL); /* shouldn't pass limit sentinel */
|
||||
}
|
||||
if(j >= block->limit)
|
||||
{
|
||||
block = block->next;
|
||||
AVER(block != NULL); /* shouldn't pass limit sentinel */
|
||||
}
|
||||
}
|
||||
LibPutChar(stream, '\n');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* NULL POOL
|
||||
*
|
||||
* $HopeName$
|
||||
* $HopeName: MMsrc/!pooln.c(trunk.1)$
|
||||
*
|
||||
* Copyright(C) 1995 Harlequin Group, all rights reserved
|
||||
*
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
#include "ref.h"
|
||||
#include "space.h"
|
||||
#include "trace.h"
|
||||
#include "prot.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
|
@ -42,6 +43,7 @@ static Error scan(Pool pool, Trace trace, RefRank rank);
|
|||
static Error fix(Pool pool, Trace trace, RefRank rank,
|
||||
Arena arena, Ref *refIO);
|
||||
static void reclaim(Pool pool, Trace trace);
|
||||
static void access(Pool pool, Addr seg, ProtMode mode);
|
||||
|
||||
|
||||
/* Class Structure */
|
||||
|
|
@ -51,14 +53,15 @@ static PoolClassStruct PoolClassNStruct;
|
|||
PoolClass PoolClassN(void)
|
||||
{
|
||||
PoolClassInit(&PoolClassNStruct,
|
||||
"N",
|
||||
sizeof(PoolNStruct), offsetof(PoolNStruct, poolStruct),
|
||||
create, destroy,
|
||||
alloc, free_,
|
||||
bufferCreate, bufferDestroy,
|
||||
condemn, mark, scan,
|
||||
fix, reclaim,
|
||||
describe);
|
||||
"N",
|
||||
sizeof(PoolNStruct), offsetof(PoolNStruct, poolStruct),
|
||||
create, destroy,
|
||||
alloc, free_,
|
||||
bufferCreate, bufferDestroy,
|
||||
condemn, mark, scan,
|
||||
fix, reclaim,
|
||||
access,
|
||||
describe);
|
||||
return &PoolClassNStruct;
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +272,7 @@ static Error scan(Pool pool, Trace trace, RefRank rank)
|
|||
}
|
||||
|
||||
static Error fix(Pool pool, Trace trace, RefRank rank,
|
||||
Arena arena, Ref *refIO)
|
||||
Arena arena, Ref *refIO)
|
||||
{
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(pool->class == &PoolClassNStruct);
|
||||
|
|
@ -284,7 +287,7 @@ static Error fix(Pool pool, Trace trace, RefRank rank,
|
|||
UNUSED(refIO);
|
||||
#endif /* DEBUG_ASSERT */
|
||||
NOTREACHED; /* since we don't allocate any objects, should never
|
||||
* be called upon to fix a reference */
|
||||
* be called upon to fix a reference */
|
||||
return ErrFAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -299,3 +302,15 @@ static void reclaim(Pool pool, Trace trace)
|
|||
#endif
|
||||
/* all unmarked and condemned objects reclaimed */
|
||||
}
|
||||
|
||||
static void access(Pool pool, Addr seg, ProtMode mode)
|
||||
{
|
||||
AVER(ISVALID(Pool, pool));
|
||||
AVER(pool->class == &PoolClassNStruct);
|
||||
UNUSED(seg);
|
||||
UNUSED(mode);
|
||||
#ifndef DEBUG_ASSERT
|
||||
UNUSED(pool);
|
||||
#endif
|
||||
/* deal with access to segment */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue