1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-27 07:41:28 -08:00

Replacing mv with mvff as the arena control pool.

Copied from Perforce
 Change: 189459
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Brooksby 2016-03-01 01:38:28 +00:00
parent b84dd0d529
commit f0b5e7d44a
7 changed files with 147 additions and 69 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);
}
@ -469,8 +469,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;
@ -486,7 +486,7 @@ void ControlFinish(Arena arena)
AVERT(Arena, arena);
AVER(arena->poolReady);
arena->poolReady = FALSE;
PoolFinish(MVPool(&arena->controlPoolStruct));
PoolFinish(ArenaControlPool(arena));
}

View file

@ -507,10 +507,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

@ -141,30 +141,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/>.
@ -696,9 +672,40 @@ 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;
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 */
@ -709,7 +716,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.
@ -34,6 +31,30 @@
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 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)

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.
*
* FIXME: This header is no longer necessary since MV is no longer
* used internally.
*
* .purpose: This is the interface to the manual-variable pool class.
*
* .mv: Manual-variable pools manage variably-sized blocks of memory

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,6 +27,7 @@
#include "freelist.h"
#include "mpm.h"
#include "mpscmvff.h"
#include "poolmvff.h"
#include "mpscmfs.h"
#include "poolmfs.h"
@ -33,35 +37,10 @@ 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 +48,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 */
@ -777,8 +754,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));

72
mps/code/poolmvff.h Normal file
View file

@ -0,0 +1,72 @@
/* 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 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.
*
* .design: See <design/poolmvff/>
*/
#ifndef poolmvff_h
#define poolmvff_h
#include "mpmtypes.h"
#include "mpscmvff.h"
typedef struct MVFFStruct *MVFF;
extern PoolClass PoolClassMVFF(void);
extern Bool MVFFCheck(MVFF mvff);
#define MVFFPool(mvff) (&(mvff)->poolStruct)
#endif /* poolmvff_h */
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Redistributions in any form must be accompanied by information on how
* to obtain complete source code for this software and any accompanying
* software that uses this software. The source code must either be
* included in the distribution or be available for no more than the cost
* of distribution plus a nominal fee, and must be freely redistributable
* under reasonable conditions. For an executable file, complete source
* code means the source code for all modules it contains. It does not
* include source code for modules or files that typically accompany the
* major components of the operating system on which the executable file
* runs.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/