1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Merging branch/2016-03-01/mvff-control into branch/2016-03-15/sunrise to remove dependency on tractp.

Copied from Perforce
 Change: 190095
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 2016-03-15 11:35:33 +00:00
commit 66e5d032a8
7 changed files with 92 additions and 99 deletions

View file

@ -6,7 +6,7 @@
* .sources: <design/arena/> is the main design document. */
#include "tract.h"
#include "poolmv.h"
#include "poolmvff.h"
#include "mpm.h"
#include "cbs.h"
#include "bt.h"
@ -17,7 +17,7 @@
SRCID(arena, "$Id$");
#define ArenaControlPool(arena) MVPool(&(arena)->controlPoolStruct)
#define ArenaControlPool(arena) MVFFPool(&(arena)->controlPoolStruct)
#define ArenaCBSBlockPool(arena) MFSPool(&(arena)->freeCBSBlockPoolStruct)
#define ArenaFreeLand(arena) CBSLand(&(arena)->freeLandStruct)
@ -137,7 +137,7 @@ Bool ArenaCheck(Arena arena)
CHECKL(BoolCheck(arena->poolReady));
if (arena->poolReady) { /* <design/arena/#pool.ready> */
CHECKD(MV, &arena->controlPoolStruct);
CHECKD(MVFF, &arena->controlPoolStruct);
CHECKD(Reservoir, &arena->reservoirStruct);
}
@ -478,8 +478,8 @@ Res ControlInit(Arena arena)
AVER(!arena->poolReady);
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, CONTROL_EXTEND_BY);
res = PoolInit(MVPool(&arena->controlPoolStruct), arena,
PoolClassMV(), args);
res = PoolInit(ArenaControlPool(arena), arena,
PoolClassMVFF(), args);
} MPS_ARGS_END(args);
if (res != ResOK)
return res;
@ -495,7 +495,7 @@ void ControlFinish(Arena arena)
AVERT(Arena, arena);
AVER(arena->poolReady);
arena->poolReady = FALSE;
PoolFinish(MVPool(&arena->controlPoolStruct));
PoolFinish(ArenaControlPool(arena));
}

View file

@ -15,7 +15,7 @@
*/
#include "mpm.h"
#include "poolmv.h"
#include "poolmvff.h"
#include "testlib.h"
#include "mpslib.h"
#include "mpsavm.h"
@ -415,7 +415,7 @@ static void testPageTable(ArenaClass class, Size size, Addr addr, Bool zoned)
die(ArenaCreate(&arena, class, args), "ArenaCreate");
} MPS_ARGS_END(args);
die(PoolCreate(&pool, arena, PoolClassMV(), argsNone), "PoolCreate");
die(PoolCreate(&pool, arena, PoolClassMVFF(), argsNone), "PoolCreate");
pageSize = ArenaGrainSize(arena);
tractsPerPage = pageSize / sizeof(TractStruct);

View file

@ -24,7 +24,6 @@
#include "bt.h"
#include "poolmrg.h"
#include "mps.h" /* finalization */
#include "poolmv.h"
#include "mpm.h"
SRCID(global, "$Id$");
@ -509,10 +508,9 @@ void GlobalsPrepareToDestroy(Globals arenaGlobals)
* 0. arena->freeCBSBlockPoolStruct
* 1. arena->reservoirStruct
* 2. arena->controlPoolStruct
* 3. arena->controlPoolStruct.blockPoolStruct
* 4. arena->controlPoolStruct.spanPoolStruct
* 3. arena->controlPoolStruct.cbsBlockPoolStruct
*/
AVER(RingLength(&arenaGlobals->poolRing) == 5);
AVER(RingLength(&arenaGlobals->poolRing) == 4);
}

View file

@ -143,30 +143,6 @@ typedef struct MFSStruct { /* MFS outer structure */
} MFSStruct;
/* MVStruct -- MV (Manual Variable) pool outer structure
*
* .mv: See <code/poolmv.c>, <design/poolmv/>.
*
* The MV pool outer structure is declared here because it is the
* control pool structure which is inlined in the arena. Normally,
* pool outer structures are declared with the pools. */
#define MVSig ((Sig)0x5193B999) /* SIGnature MV */
typedef struct MVStruct { /* MV pool outer structure */
PoolStruct poolStruct; /* generic structure */
MFSStruct blockPoolStruct; /* for managing block descriptors */
MFSStruct spanPoolStruct; /* for managing span descriptors */
Size extendBy; /* segment size to extend pool by */
Size avgSize; /* client estimate of allocation size */
Size maxSize; /* client estimate of maximum size */
Size free; /* free space in pool */
Size lost; /* <design/poolmv/#lost> */
RingStruct spans; /* span chain */
Sig sig; /* <design/sig/> */
} MVStruct;
/* ReservoirStruct -- Reservoir structure
*
* .reservoir: See <code/reserv.c>, <design/reservoir/>.
@ -710,9 +686,39 @@ typedef struct FreelistStruct {
} FreelistStruct;
/* MVFFStruct -- MVFF (Manual Variable First Fit) pool outer structure
*
* The signature is placed at the end, see
* <design/pool/#outer-structure.sig>
*
* The MVFF pool outer structure is declared here because it is the
* control pool structure which is inlined in the arena. Normally,
* pool outer structures are declared with the pools.
*/
#define MVFFSig ((Sig)0x5193FFF9) /* SIGnature MVFF */
typedef struct MVFFStruct { /* MVFF pool outer structure */
PoolStruct poolStruct; /* generic structure */
LocusPrefStruct locusPrefStruct; /* the preferences for allocation */
Size extendBy; /* size to extend pool by */
Size avgSize; /* client estimate of allocation size */
double spare; /* spare space fraction, see MVFFReduce */
MFSStruct cbsBlockPoolStruct; /* stores blocks for CBSs */
CBSStruct totalCBSStruct; /* all memory allocated from the arena */
CBSStruct freeCBSStruct; /* free memory (primary) */
FreelistStruct flStruct; /* free memory (secondary, for emergencies) */
FailoverStruct foStruct; /* free memory (fail-over mechanism) */
Bool firstFit; /* as opposed to last fit */
Bool slotHigh; /* prefers high part of large block */
Sig sig; /* <design/sig/> */
} MVFFStruct;
/* ArenaStruct -- generic arena
*
* See <code/arena.c>. */
* See <code/arena.c>.
*/
#define ArenaSig ((Sig)0x519A6E4A) /* SIGnature ARENA */
@ -723,7 +729,7 @@ typedef struct mps_arena_s {
ArenaClass class; /* arena class structure */
Bool poolReady; /* <design/arena/#pool.ready> */
MVStruct controlPoolStruct; /* <design/arena/#pool> */
MVFFStruct controlPoolStruct; /* <design/arena/#pool> */
ReservoirStruct reservoirStruct; /* <design/reservoir/> */

View file

@ -4,9 +4,6 @@
* Copyright (c) 2001-2015 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
* **** RESTRICTION: This pool may not allocate from the arena control
* pool, since it is used to implement that pool.
*
* An observation: Freeing memory introduces more information
* into the system than allocating it. This causes the problem
* described in note 2.
@ -27,17 +24,41 @@
#include "mpscmv.h"
#include "dbgpool.h"
#include "poolmv.h"
#include "poolmfs.h"
#include "mpm.h"
SRCID(poolmv, "$Id$");
/* MVStruct -- MV (Manual Variable) pool outer structure
*
* .mv: See <code/poolmv.c>, <design/poolmv/>.
*
* The signature is placed at the end, see
* <design/pool/#outer-structure.sig>
*/
#define MVSig ((Sig)0x5193B999) /* SIGnature MV */
typedef struct MVStruct *MV;
typedef struct MVStruct { /* MV pool outer structure */
PoolStruct poolStruct; /* generic structure */
MFSStruct blockPoolStruct; /* for managing block descriptors */
MFSStruct spanPoolStruct; /* for managing span descriptors */
Size extendBy; /* segment size to extend pool by */
Size avgSize; /* client estimate of allocation size */
Size maxSize; /* client estimate of maximum size */
Size free; /* free space in pool */
Size lost; /* <design/poolmv/#lost> */
RingStruct spans; /* span chain */
Sig sig; /* <design/sig/> */
} MVStruct;
#define mvBlockPool(mv) MFSPool(&(mv)->blockPoolStruct)
#define mvSpanPool(mv) MFSPool(&(mv)->spanPoolStruct)
#define MVPool(mv) (&(mv)->poolStruct)
#define PoolMV(pool) PARENT(MVStruct, poolStruct, pool)
@ -129,6 +150,9 @@ typedef struct MVSpanStruct {
AddrOffset((span)->base.limit, (span)->limit.base)
static Bool MVCheck(MV mv);
/* MVSpanCheck -- check the consistency of a span structure */
ATTRIBUTE_UNUSED
@ -863,12 +887,6 @@ DEFINE_POOL_CLASS(MVPoolClass, this)
}
MVPoolClass PoolClassMV(void)
{
return EnsureMVPoolClass();
}
/* Pool class MVDebug */
DEFINE_POOL_CLASS(MVDebugPoolClass, this)
@ -901,7 +919,7 @@ mps_pool_class_t mps_class_mv_debug(void)
/* MVCheck -- check the consistency of an MV structure */
Bool MVCheck(MV mv)
static Bool MVCheck(MV mv)
{
CHECKS(MV, mv);
CHECKD(Pool, MVPool(mv));

View file

@ -4,6 +4,9 @@
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
* **** RESTRICTION: This pool may not allocate from the arena control
* pool, since it is used to implement that pool.
*
* .purpose: This is a pool class for manually managed objects of
* variable size where address-ordered first fit is an appropriate
* policy. Provision is made to allocate in reverse.
@ -24,44 +27,17 @@
#include "freelist.h"
#include "mpm.h"
#include "mpscmvff.h"
#include "poolmvff.h"
#include "mpscmfs.h"
#include "poolmfs.h"
SRCID(poolmvff, "$Id$");
/* Would go in poolmvff.h if the class had any MPS-internal clients. */
extern PoolClass PoolClassMVFF(void);
/* MVFFStruct -- MVFF (Manual Variable First Fit) pool outer structure
*
* The signature is placed at the end, see
* <design/pool/#outer-structure.sig>
*/
#define MVFFSig ((Sig)0x5193FFF9) /* SIGnature MVFF */
typedef struct MVFFStruct *MVFF;
typedef struct MVFFStruct { /* MVFF pool outer structure */
PoolStruct poolStruct; /* generic structure */
LocusPrefStruct locusPrefStruct; /* the preferences for allocation */
Size extendBy; /* size to extend pool by */
Size avgSize; /* client estimate of allocation size */
double spare; /* spare space fraction, see MVFFReduce */
MFSStruct cbsBlockPoolStruct; /* stores blocks for CBSs */
CBSStruct totalCBSStruct; /* all memory allocated from the arena */
CBSStruct freeCBSStruct; /* free memory (primary) */
FreelistStruct flStruct; /* free memory (secondary, for emergencies) */
FailoverStruct foStruct; /* free memory (fail-over mechanism) */
Bool firstFit; /* as opposed to last fit */
Bool slotHigh; /* prefers high part of large block */
Sig sig; /* <design/sig/> */
} MVFFStruct;
/* Note: MVFFStruct is declared in mpmst.h rather than here because it
is the control pool and is inlined in the arena globals. */
#define PoolMVFF(pool) PARENT(MVFFStruct, poolStruct, pool)
#define MVFFPool(mvff) (&(mvff)->poolStruct)
#define MVFFTotalLand(mvff) CBSLand(&(mvff)->totalCBSStruct)
#define MVFFFreePrimary(mvff) CBSLand(&(mvff)->freeCBSStruct)
#define MVFFFreeSecondary(mvff) FreelistLand(&(mvff)->flStruct)
@ -69,8 +45,6 @@ typedef struct MVFFStruct { /* MVFF pool outer structure */
#define MVFFLocusPref(mvff) (&(mvff)->locusPrefStruct)
#define MVFFBlockPool(mvff) MFSPool(&(mvff)->cbsBlockPoolStruct)
static Bool MVFFCheck(MVFF mvff);
/* MVFFDebug -- MVFFDebug class */
@ -774,8 +748,7 @@ mps_pool_class_t mps_class_mvff_debug(void)
/* MVFFCheck -- check the consistency of an MVFF structure */
ATTRIBUTE_UNUSED
static Bool MVFFCheck(MVFF mvff)
Bool MVFFCheck(MVFF mvff)
{
CHECKS(MVFF, mvff);
CHECKD(Pool, MVFFPool(mvff));

View file

@ -1,35 +1,33 @@
/* poolmv.h: MANUAL VARIABLE POOL
/* poolmvff.h: First Fit Manual Variable Pool
*
* $Id$
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
* .purpose: This is the interface to the manual-variable pool class.
* .purpose: This is a pool class for manually managed objects of
* variable size where address-ordered first fit is an appropriate
* policy. Provision is made to allocate in reverse.
*
* .mv: Manual-variable pools manage variably-sized blocks of memory
* in a flexible manner. They have higher overheads than a fixed-size
* pool.
*
* .design: See <design/poolmv/>
* .design: See <design/poolmvff/>
*/
#ifndef poolmv_h
#define poolmv_h
#ifndef poolmvff_h
#define poolmvff_h
#include "mpmtypes.h"
#include "mpscmv.h"
#include "mpscmvff.h"
typedef struct MVStruct *MV;
typedef struct MVFFStruct *MVFF;
extern PoolClass PoolClassMV(void);
extern PoolClass PoolClassMVFF(void);
extern Bool MVCheck(MV mv);
extern Bool MVFFCheck(MVFF mvff);
#define MVPool(mv) (&(mv)->poolStruct)
#define MVFFPool(mvff) (&(mvff)->poolStruct)
#endif /* poolmv_h */
#endif /* poolmvff_h */
/* C. COPYRIGHT AND LICENSE