mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-23 06:00:41 -08:00
Generalising mps_addr_object, arenaaddrobject, pooladdrobject for pools that do not use segments.
This commit is contained in:
parent
7835ac66e9
commit
bef248f012
7 changed files with 29 additions and 29 deletions
|
|
@ -148,9 +148,7 @@ static void test_main(void)
|
||||||
/* Do the test */
|
/* Do the test */
|
||||||
res = mps_addr_object(&out, arena, in);
|
res = mps_addr_object(&out, arena, in);
|
||||||
|
|
||||||
/* We should insist MPS_RES_UNIMPL here but the Trivial Method for mps_addr_object is only reached for pools that contain objects in Segs.
|
Insist(res == MPS_RES_UNIMPL);
|
||||||
Since mvff does not, and the input address is not inside a Seg, the call is rejected by the Arena with MPS_RES_FAIL */
|
|
||||||
Insist(res == MPS_RES_FAIL);
|
|
||||||
|
|
||||||
/* Final clean up */
|
/* Final clean up */
|
||||||
mps_free(mvff_pool, in, sizeof(mps_word_t));
|
mps_free(mvff_pool, in, sizeof(mps_word_t));
|
||||||
|
|
|
||||||
|
|
@ -1367,19 +1367,17 @@ Bool ArenaHasAddr(Arena arena, Addr addr)
|
||||||
/* ArenaAddrObject -- return base pointer of managed object */
|
/* ArenaAddrObject -- return base pointer of managed object */
|
||||||
Res ArenaAddrObject(Addr *pReturn, Arena arena, Addr addr)
|
Res ArenaAddrObject(Addr *pReturn, Arena arena, Addr addr)
|
||||||
{
|
{
|
||||||
Seg seg;
|
Tract tract;
|
||||||
Pool pool;
|
|
||||||
|
|
||||||
AVER(pReturn != NULL);
|
AVER(pReturn != NULL);
|
||||||
AVERT(Arena, arena);
|
AVERT(Arena, arena);
|
||||||
|
|
||||||
/* We currently assume that managed objects are inside Segments
|
if (!TractOfAddr(&tract, arena, addr)) {
|
||||||
and that pools where this feature is needed have Segments */
|
/* address does not belong to the arena */
|
||||||
if (!SegOfAddr(&seg, arena, addr))
|
|
||||||
return ResFAIL;
|
return ResFAIL;
|
||||||
|
}
|
||||||
|
|
||||||
pool = SegPool(seg);
|
return PoolAddrObject(pReturn, TractPool(tract), addr);
|
||||||
return PoolAddrObject(pReturn, pool, seg, addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ extern Res PoolTraceBegin(Pool pool, Trace trace);
|
||||||
extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
|
extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
|
||||||
extern Size PoolTotalSize(Pool pool);
|
extern Size PoolTotalSize(Pool pool);
|
||||||
extern Size PoolFreeSize(Pool pool);
|
extern Size PoolFreeSize(Pool pool);
|
||||||
extern Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr);
|
extern Res PoolAddrObject(Addr *pReturn, Pool pool, Addr addr);
|
||||||
|
|
||||||
extern Res PoolAbsInit(Pool pool, Arena arena, PoolClass klass, ArgList arg);
|
extern Res PoolAbsInit(Pool pool, Arena arena, PoolClass klass, ArgList arg);
|
||||||
extern void PoolAbsFinish(Inst inst);
|
extern void PoolAbsFinish(Inst inst);
|
||||||
|
|
@ -268,7 +268,7 @@ extern void PoolTrivFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
|
||||||
extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
|
extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
|
||||||
extern BufferClass PoolNoBufferClass(void);
|
extern BufferClass PoolNoBufferClass(void);
|
||||||
extern Size PoolNoSize(Pool pool);
|
extern Size PoolNoSize(Pool pool);
|
||||||
extern Res PoolTrivAddr(Addr *pReturn, Pool pool, Seg seg, Addr addr);
|
extern Res PoolTrivAddrObject(Addr *pReturn, Pool pool, Addr addr);
|
||||||
|
|
||||||
/* See .critical.macros. */
|
/* See .critical.macros. */
|
||||||
#define PoolFreeMacro(pool, old, size) Method(Pool, pool, free)(pool, old, size)
|
#define PoolFreeMacro(pool, old, size) Method(Pool, pool, free)(pool, old, size)
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn,
|
||||||
Pool pool, Buffer buf);
|
Pool pool, Buffer buf);
|
||||||
typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf,
|
typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf,
|
||||||
AllocFrame frame);
|
AllocFrame frame);
|
||||||
typedef Res (*PoolAddrObjectMethod)(Addr *pReturn, Pool pool, Seg seg, Addr addr);
|
typedef Res (*PoolAddrObjectMethod)(Addr *pReturn, Pool pool, Addr addr);
|
||||||
typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockVisitor f, void *p);
|
typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockVisitor f, void *p);
|
||||||
typedef BufferClass (*PoolBufferClassMethod)(void);
|
typedef BufferClass (*PoolBufferClassMethod)(void);
|
||||||
typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);
|
typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);
|
||||||
|
|
|
||||||
|
|
@ -303,16 +303,20 @@ Size PoolFreeSize(Pool pool)
|
||||||
return Method(Pool, pool, freeSize)(pool);
|
return Method(Pool, pool, freeSize)(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PoolAddrObject -- return base pointer from interior pointer */
|
|
||||||
Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr)
|
/* PoolAddrObject -- return base pointer from interior pointer
|
||||||
|
*
|
||||||
|
* Note: addr is not necessarily inside the pool, even though
|
||||||
|
* mps_addr_object dispatches via the tract table. This allows this
|
||||||
|
* function to be used more generally internally. The pool should
|
||||||
|
* check (it has to anyway).
|
||||||
|
*/
|
||||||
|
|
||||||
|
Res PoolAddrObject(Addr *pReturn, Pool pool, Addr addr)
|
||||||
{
|
{
|
||||||
AVER(pReturn != NULL);
|
AVER(pReturn != NULL);
|
||||||
AVERT(Pool, pool);
|
AVERT(Pool, pool);
|
||||||
AVERT(Seg, seg);
|
return Method(Pool, pool, addrObject)(pReturn, pool, addr);
|
||||||
AVER(pool == SegPool(seg));
|
|
||||||
AVER(SegBase(seg) <= addr);
|
|
||||||
AVER(addr < SegLimit(seg));
|
|
||||||
return Method(Pool, pool, addrObject)(pReturn, pool, seg, addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PoolDescribe -- describe a pool */
|
/* PoolDescribe -- describe a pool */
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ DEFINE_CLASS(Pool, AbstractPool, klass)
|
||||||
klass->debugMixin = PoolNoDebugMixin;
|
klass->debugMixin = PoolNoDebugMixin;
|
||||||
klass->totalSize = PoolNoSize;
|
klass->totalSize = PoolNoSize;
|
||||||
klass->freeSize = PoolNoSize;
|
klass->freeSize = PoolNoSize;
|
||||||
klass->addrObject = PoolTrivAddr;
|
klass->addrObject = PoolTrivAddrObject;
|
||||||
klass->sig = PoolClassSig;
|
klass->sig = PoolClassSig;
|
||||||
AVERT(PoolClass, klass);
|
AVERT(PoolClass, klass);
|
||||||
}
|
}
|
||||||
|
|
@ -476,10 +476,10 @@ Size PoolNoSize(Pool pool)
|
||||||
return UNUSED_SIZE;
|
return UNUSED_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Res PoolTrivAddr(Addr *pReturn, Pool pool, Seg seg, Addr addr)
|
|
||||||
|
Res PoolTrivAddrObject(Addr *pReturn, Pool pool, Addr addr)
|
||||||
{
|
{
|
||||||
AVERT(Pool, pool);
|
AVERT(Pool, pool);
|
||||||
AVERT(Seg, seg);
|
|
||||||
AVER(pReturn != NULL);
|
AVER(pReturn != NULL);
|
||||||
UNUSED(addr);
|
UNUSED(addr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1926,24 +1926,24 @@ static Res amcAddrObjectSearch(Addr *pReturn, Pool pool, Addr objBase,
|
||||||
return ResFAIL;
|
return ResFAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* AMCAddrObject -- return base pointer from interior pointer */
|
/* AMCAddrObject -- return base pointer from interior pointer */
|
||||||
|
|
||||||
static Res AMCAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr)
|
static Res AMCAddrObject(Addr *pReturn, Pool pool, Addr addr)
|
||||||
{
|
{
|
||||||
Res res;
|
Res res;
|
||||||
Arena arena;
|
Arena arena;
|
||||||
Addr base, limit;
|
Addr base, limit;
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
|
Seg seg;
|
||||||
|
|
||||||
AVER(pReturn != NULL);
|
AVER(pReturn != NULL);
|
||||||
AVERT(Pool, pool);
|
AVERT(Pool, pool);
|
||||||
AVERT(Seg, seg);
|
|
||||||
AVER(SegPool(seg) == pool);
|
|
||||||
AVER(SegBase(seg) <= addr);
|
|
||||||
AVER(addr < SegLimit(seg));
|
|
||||||
|
|
||||||
arena = PoolArena(pool);
|
arena = PoolArena(pool);
|
||||||
|
if (!SegOfAddr(&seg, arena, addr) || SegPool(seg) != pool)
|
||||||
|
return ResFAIL;
|
||||||
|
|
||||||
base = SegBase(seg);
|
base = SegBase(seg);
|
||||||
if (SegBuffer(&buffer, seg))
|
if (SegBuffer(&buffer, seg))
|
||||||
limit = BufferGetInit(buffer);
|
limit = BufferGetInit(buffer);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue