mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -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 */
|
||||
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.
|
||||
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);
|
||||
Insist(res == MPS_RES_UNIMPL);
|
||||
|
||||
/* Final clean up */
|
||||
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 */
|
||||
Res ArenaAddrObject(Addr *pReturn, Arena arena, Addr addr)
|
||||
{
|
||||
Seg seg;
|
||||
Pool pool;
|
||||
Tract tract;
|
||||
|
||||
AVER(pReturn != NULL);
|
||||
AVERT(Arena, arena);
|
||||
|
||||
/* We currently assume that managed objects are inside Segments
|
||||
and that pools where this feature is needed have Segments */
|
||||
if (!SegOfAddr(&seg, arena, addr))
|
||||
if (!TractOfAddr(&tract, arena, addr)) {
|
||||
/* address does not belong to the arena */
|
||||
return ResFAIL;
|
||||
}
|
||||
|
||||
pool = SegPool(seg);
|
||||
return PoolAddrObject(pReturn, pool, seg, addr);
|
||||
return PoolAddrObject(pReturn, TractPool(tract), addr);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ extern Res PoolTraceBegin(Pool pool, Trace trace);
|
|||
extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
|
||||
extern Size PoolTotalSize(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 void PoolAbsFinish(Inst inst);
|
||||
|
|
@ -268,7 +268,7 @@ extern void PoolTrivFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
|
|||
extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
|
||||
extern BufferClass PoolNoBufferClass(void);
|
||||
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. */
|
||||
#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);
|
||||
typedef Res (*PoolFramePopMethod)(Pool pool, Buffer buf,
|
||||
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 BufferClass (*PoolBufferClassMethod)(void);
|
||||
typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);
|
||||
|
|
|
|||
|
|
@ -303,16 +303,20 @@ Size PoolFreeSize(Pool 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);
|
||||
AVERT(Pool, pool);
|
||||
AVERT(Seg, seg);
|
||||
AVER(pool == SegPool(seg));
|
||||
AVER(SegBase(seg) <= addr);
|
||||
AVER(addr < SegLimit(seg));
|
||||
return Method(Pool, pool, addrObject)(pReturn, pool, seg, addr);
|
||||
return Method(Pool, pool, addrObject)(pReturn, pool, addr);
|
||||
}
|
||||
|
||||
/* PoolDescribe -- describe a pool */
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ DEFINE_CLASS(Pool, AbstractPool, klass)
|
|||
klass->debugMixin = PoolNoDebugMixin;
|
||||
klass->totalSize = PoolNoSize;
|
||||
klass->freeSize = PoolNoSize;
|
||||
klass->addrObject = PoolTrivAddr;
|
||||
klass->addrObject = PoolTrivAddrObject;
|
||||
klass->sig = PoolClassSig;
|
||||
AVERT(PoolClass, klass);
|
||||
}
|
||||
|
|
@ -476,10 +476,10 @@ Size PoolNoSize(Pool pool)
|
|||
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(Seg, seg);
|
||||
AVER(pReturn != NULL);
|
||||
UNUSED(addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -1926,24 +1926,24 @@ static Res amcAddrObjectSearch(Addr *pReturn, Pool pool, Addr objBase,
|
|||
return ResFAIL;
|
||||
}
|
||||
|
||||
|
||||
/* 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;
|
||||
Arena arena;
|
||||
Addr base, limit;
|
||||
Buffer buffer;
|
||||
|
||||
Seg seg;
|
||||
|
||||
AVER(pReturn != NULL);
|
||||
AVERT(Pool, pool);
|
||||
AVERT(Seg, seg);
|
||||
AVER(SegPool(seg) == pool);
|
||||
AVER(SegBase(seg) <= addr);
|
||||
AVER(addr < SegLimit(seg));
|
||||
|
||||
arena = PoolArena(pool);
|
||||
if (!SegOfAddr(&seg, arena, addr) || SegPool(seg) != pool)
|
||||
return ResFAIL;
|
||||
|
||||
base = SegBase(seg);
|
||||
if (SegBuffer(&buffer, seg))
|
||||
limit = BufferGetInit(buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue