diff --git a/mps/src/pool.c b/mps/src/pool.c index df6ee0247e7..3ca025c9d13 100644 --- a/mps/src/pool.c +++ b/mps/src/pool.c @@ -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 #include @@ -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) { diff --git a/mps/src/poolmfs.c b/mps/src/poolmfs.c index fb9af5d94e6..242cd1c38a5 100644 --- a/mps/src/poolmfs.c +++ b/mps/src/poolmfs.c @@ -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); } diff --git a/mps/src/poolmv.c b/mps/src/poolmv.c index 166bfd41f68..6cd7aa1c38a 100644 --- a/mps/src/poolmv.c +++ b/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 -#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; jlimit.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'); } diff --git a/mps/src/pooln.c b/mps/src/pooln.c index 56ef9b0ec7e..1ae5bb0a7e5 100644 --- a/mps/src/pooln.c +++ b/mps/src/pooln.c @@ -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 #include @@ -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 */ +}