From a911bc6657cceeddd679f75482dfd67debad10ef Mon Sep 17 00:00:00 2001 From: David Jones Date: Wed, 28 Jan 1998 16:38:52 +0000 Subject: [PATCH] Adding walker, in anticipation of change for request.dylan.170440 Copied from Perforce Change: 19282 ServerID: perforce.ravenbrook.com --- mps/src/mpm.h | 5 ++++- mps/src/mpmst.h | 7 ++++--- mps/src/mpmtypes.h | 15 +++++++++------ mps/src/pool.c | 20 ++++++++++++++++++-- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/mps/src/mpm.h b/mps/src/mpm.h index a7a4b1195c9..9d366dcb019 100644 --- a/mps/src/mpm.h +++ b/mps/src/mpm.h @@ -1,6 +1,6 @@ /* impl.h.mpm: MEMORY POOL MANAGER DEFINITIONS * - * $HopeName: MMsrc!mpm.h(trunk.68) $ + * $HopeName: MMsrc!mpm.h(trunk.69) $ * Copyright (C) 1997, 1998 The Harlequin Group Limited. All rights reserved. */ @@ -350,6 +350,9 @@ extern void MessageNoFinalizationRef(Ref *refReturn, Arena arena, Message message); extern Res PoolNoAct(Pool pool, Action action); +extern void PoolNoWalk(Pool pool, Seg seg, + void (*f)(Addr, void *, unsigned long), + void *, unsigned long); extern Res PoolCollectAct(Pool pool, Action action); diff --git a/mps/src/mpmst.h b/mps/src/mpmst.h index bc2596813c4..82a2cb7f22f 100644 --- a/mps/src/mpmst.h +++ b/mps/src/mpmst.h @@ -1,6 +1,6 @@ /* impl.h.mpmst: MEMORY POOL MANAGER DATA STRUCTURES * - * $HopeName: MMsrc!mpmst.h(trunk.47) $ + * $HopeName: MMsrc!mpmst.h(trunk.48) $ * Copyright (C) 1997 The Harlequin Group Limited. All rights reserved. * * .readership: MM developers. @@ -83,9 +83,9 @@ typedef struct PoolClassStruct { PoolFreeMethod free; /* free memory to pool */ PoolBufferInitMethod bufferInit; /* additional buffer init */ PoolBufferFillMethod bufferFill; /* out-of-line reserve */ - PoolBufferEmptyMethod bufferEmpty; /* out-of-line commit */ + PoolBufferEmptyMethod bufferEmpty; /* out-of-line commit */ PoolBufferFinishMethod bufferFinish; /* additional buffer finish */ - PoolTraceBeginMethod traceBegin; + PoolTraceBeginMethod traceBegin; /* no idea what this does @@@@ */ PoolWhitenMethod whiten; /* whiten objects in a segment */ PoolGreyMethod grey; /* grey non-white objects */ PoolBlackenMethod blacken; /* blacken grey objects without scanning */ @@ -94,6 +94,7 @@ typedef struct PoolClassStruct { PoolReclaimMethod reclaim; /* reclaim dead objects after tracing */ PoolBenefitMethod benefit; /* calculate benefit of action */ PoolActMethod act; /* do an action */ + PoolWalkMethod walk; /* walk over a segment */ PoolDescribeMethod describe; /* describe the contents of the pool */ Sig endSig; /* .class.end-sig */ } PoolClassStruct; diff --git a/mps/src/mpmtypes.h b/mps/src/mpmtypes.h index bd1be51dd7d..6eb12d1c0bb 100644 --- a/mps/src/mpmtypes.h +++ b/mps/src/mpmtypes.h @@ -1,6 +1,6 @@ /* impl.h.mpmtypes: MEMORY POOL MANAGER TYPES * - * $HopeName: MMsrc!mpmtypes.h(trunk.38) $ + * $HopeName: MMsrc!mpmtypes.h(trunk.39) $ * Copyright (C) 1997 The Harlequin Group Limited. All rights reserved. * * .readership: MM developers. @@ -102,17 +102,18 @@ typedef struct MessageClassStruct *MessageClass; /* design.mps.message */ /* Pool*Method -- see design.mps.class-interface */ +/* Order of types corresponds to PoolClassStruct in impl.h.mpmst */ + typedef Res (*PoolInitMethod)(Pool pool, va_list args); typedef void (*PoolFinishMethod)(Pool pool); typedef Res (*PoolAllocMethod)(Addr *pReturn, Pool pool, Size size); typedef void (*PoolFreeMethod)(Pool pool, Addr old, Size size); typedef Res (*PoolBufferInitMethod)(Pool pool, Buffer buf, va_list args); -typedef void (*PoolBufferFinishMethod)(Pool pool, Buffer buf); typedef Res (*PoolBufferFillMethod)(Seg *segReturn, Addr *baseReturn, Addr *limitReturn, Pool pool, Buffer buffer, Size size); typedef void (*PoolBufferEmptyMethod)(Pool pool, Buffer buffer); -typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream); +typedef void (*PoolBufferFinishMethod)(Pool pool, Buffer buf); typedef Res (*PoolTraceBeginMethod)(Pool pool, Trace trace); typedef Res (*PoolWhitenMethod)(Pool pool, Trace trace, Seg seg); typedef void (*PoolGreyMethod)(Pool pool, Trace trace, Seg seg); @@ -122,6 +123,11 @@ typedef Res (*PoolFixMethod)(Pool pool, ScanState ss, Seg seg, Ref *refIO); typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg); typedef double (*PoolBenefitMethod)(Pool pool, Action action); +typedef Res (*PoolActMethod)(Pool pool, Action action); +typedef void (*PoolWalkMethod)(Pool pool, Seg seg, + void (*f)(Addr, void *, unsigned long), + void *p, unsigned long s); +typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream); /* Message*Method -- design.mps.message */ @@ -136,9 +142,6 @@ typedef void (*MessageFinalizationRefMethod) typedef struct MessageFinalizationStruct *MessageFinalization; -typedef Res (*PoolActMethod)(Pool pool, Action action); - - /* Format*Method -- see design.mps.format-interface */ /* .fmt-methods: These methods must match those defined in the */ /* MPS C Interface. (See impl.h.mps.fmt-methods.) */ diff --git a/mps/src/pool.c b/mps/src/pool.c index ee098944ba6..26db87d1d73 100644 --- a/mps/src/pool.c +++ b/mps/src/pool.c @@ -1,6 +1,6 @@ /* impl.c.pool: POOL IMPLEMENTATION * - * $HopeName: MMsrc!pool.c(trunk.41) $ + * $HopeName: MMsrc!pool.c(trunk.42) $ * Copyright (C) 1997 The Harlequin Group Limited. All rights reserved. * * This is the implementation of the generic pool interface. The @@ -12,7 +12,7 @@ #include "mpm.h" -SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.41) $"); +SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.42) $"); Bool PoolClassCheck(PoolClass class) @@ -40,6 +40,7 @@ Bool PoolClassCheck(PoolClass class) CHECKL(FUNCHECK(class->reclaim)); CHECKL(FUNCHECK(class->benefit)); CHECKL(FUNCHECK(class->act)); + CHECKL(FUNCHECK(class->walk)); CHECKL(FUNCHECK(class->describe)); CHECKL(class->endSig == PoolClassSig); return TRUE; @@ -372,6 +373,7 @@ Res PoolAct(Pool pool, Action action) } + Res PoolDescribe(Pool pool, mps_lib_FILE *stream) { Res res; @@ -809,3 +811,17 @@ failBegin: failCreate: return res; } + +void PoolNoWalk(Pool pool, Seg seg, + void (*f)(Addr, void *, unsigned long), + void *p, unsigned long s) +{ + AVERT(Pool, pool); + AVERT(Seg, seg); + AVER(FunCheck((Fun)f)); + /* p and s are arbitrary closures, hence can't be checked */ + UNUSED(p); + UNUSED(s); + + NOTREACHED; +}