1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-23 14:32:12 -07:00

Merge branch/2016-03-01/mvff-control into the master sources.

Copied from Perforce
 Change: 194442
This commit is contained in:
Gareth Rees 2018-07-05 13:37:01 +01:00
commit a4bbb4ddc2
14 changed files with 208 additions and 201 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)
@ -179,7 +179,7 @@ Bool ArenaCheck(Arena arena)
CHECKL(BoolCheck(arena->poolReady));
if (arena->poolReady) { /* <design/arena/#pool.ready> */
CHECKD(MV, &arena->controlPoolStruct);
CHECKD(MVFF, &arena->controlPoolStruct);
}
/* .reserved.check: Would like to check that arena->committed <=
@ -502,8 +502,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;
@ -519,7 +519,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 klass, Size size, Addr addr, Bool zoned)
die(ArenaCreate(&arena, klass, 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$");
@ -538,10 +537,9 @@ void GlobalsPrepareToDestroy(Globals arenaGlobals)
/* At this point the following pools still exist:
* 0. arena->freeCBSBlockPoolStruct
* 1. arena->controlPoolStruct
* 2. arena->controlPoolStruct.blockPoolStruct
* 3. arena->controlPoolStruct.spanPoolStruct
* 2. arena->controlPoolStruct.cbsBlockPoolStruct
*/
AVER(RingLength(&arenaGlobals->poolRing) == 4); /* <design/check/#.common> */
AVER(RingLength(&arenaGlobals->poolRing) == 3); /* <design/check/#.common> */
}

View file

@ -127,30 +127,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;
/* MessageClassStruct -- Message Class structure
*
* See <design/message/#class.struct> (and <design/message/#message>,
@ -720,6 +696,35 @@ typedef struct HistoryStruct {
} HistoryStruct;
/* 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>.
@ -734,7 +739,7 @@ typedef struct mps_arena_s {
Serial serial;
Bool poolReady; /* <design/arena/#pool.ready> */
MVStruct controlPoolStruct; /* <design/arena/#pool> */
MVFFStruct controlPoolStruct; /* <design/arena/#pool> */
Size reserved; /* total reserved address space */
Size committed; /* total committed memory */

View file

@ -1693,7 +1693,7 @@
311F2F7717398B8E00C15B6A /* ss.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ss.h; sourceTree = "<group>"; };
311F2F7817398B8E00C15B6A /* th.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = th.h; sourceTree = "<group>"; };
311F2F7A17398B8E00C15B6A /* tract.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tract.h; sourceTree = "<group>"; };
311F2F7B17398E7600C15B6A /* poolmv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolmv.h; sourceTree = "<group>"; };
311F2F7B17398E7600C15B6A /* poolmvff.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = poolmvff.h; sourceTree = "<group>"; };
311F2F7C17398E9A00C15B6A /* mpscmv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mpscmv.h; sourceTree = "<group>"; };
3124CAB8156BE3EC00753214 /* awlut */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = awlut; sourceTree = BUILT_PRODUCTS_DIR; };
3124CAC2156BE40100753214 /* awlut.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = awlut.c; sourceTree = "<group>"; };
@ -2550,8 +2550,8 @@
22FACEDC18880933000FDBC1 /* poolmfs.h */,
31EEAC2E156AB2F200714D05 /* poolmrg.c */,
22FACEDD18880933000FDBC1 /* poolmrg.h */,
31EEAC2F156AB2F200714D05 /* poolmv.c */,
311F2F7B17398E7600C15B6A /* poolmv.h */,
31EEAC5F156AB44D00714D05 /* poolmvff.c */,
311F2F7B17398E7600C15B6A /* poolmvff.h */,
22FACEDE18880933000FDBC1 /* pooln.c */,
22FACEDF18880933000FDBC1 /* pooln.h */,
2213454C1DB0386600E14202 /* prmc.h */,
@ -2628,9 +2628,9 @@
31CD33BD173A9F1500524741 /* poolams.h */,
3124CACE156BE4CF00753214 /* poolawl.c */,
3124CACA156BE4A300753214 /* poollo.c */,
31EEAC2F156AB2F200714D05 /* poolmv.c */,
31D4D5FD1745058100BE84B5 /* poolmv2.c */,
2291A5A8175CAA51001D4920 /* poolmv2.h */,
31EEAC5F156AB44D00714D05 /* poolmvff.c */,
31EEAC5D156AB43F00714D05 /* poolsnc.c */,
);
name = "Extra pools";

View file

@ -4,9 +4,6 @@
* Copyright (c) 2001-2016 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,23 +24,45 @@
#include "mpscmv.h"
#include "dbgpool.h"
#include "poolmv.h"
#include "poolmfs.h"
#include "mpscmvff.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;
typedef MV MVPool;
#define MVPoolCheck MVCheck
DECLARE_CLASS(Pool, MVPool, AbstractBufferPool);
DECLARE_CLASS(Pool, MVDebugPool, MVPool);
#define mvBlockPool(mv) MFSPool(&(mv)->blockPoolStruct)
#define mvSpanPool(mv) MFSPool(&(mv)->spanPoolStruct)
#define MVPool(mv) RVALUE(&(mv)->poolStruct)
#define PoolMV(pool) PARENT(MVStruct, poolStruct, pool)
@ -135,6 +154,9 @@ typedef struct MVSpanStruct {
AddrOffset((span)->base.limit, (span)->limit.base)
Bool MVCheck(MV mv);
/* MVSpanCheck -- check the consistency of a span structure */
ATTRIBUTE_UNUSED
@ -881,12 +903,6 @@ DEFINE_CLASS(Pool, MVPool, klass)
}
PoolClass PoolClassMV(void)
{
return CLASS(MVPool);
}
/* Pool class MVDebug */
DEFINE_CLASS(Pool, MVDebugPool, klass)

View file

@ -4,9 +4,12 @@
* Copyright (c) 2001-2016 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.
* variable size where address-ordered first (or last) fit is an
* appropriate policy.
*
* .design: <design/poolmvff>
*
@ -21,41 +24,15 @@
#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. */
typedef MVFF MVFFPool;
#define MVFFPoolCheck MVFFCheck
@ -64,7 +41,6 @@ DECLARE_CLASS(Pool, MVFFDebugPool, MVFFPool);
#define PoolMVFF(pool) PARENT(MVFFStruct, poolStruct, pool)
#define MVFFPool(mvff) (&(mvff)->poolStruct)
#define MVFFTotalLand(mvff) (&(mvff)->totalCBSStruct.landStruct)
#define MVFFFreePrimary(mvff) (&(mvff)->freeCBSStruct.landStruct)
#define MVFFFreeSecondary(mvff) FreelistLand(&(mvff)->flStruct)
@ -72,8 +48,6 @@ DECLARE_CLASS(Pool, MVFFDebugPool, MVFFPool);
#define MVFFLocusPref(mvff) (&(mvff)->locusPrefStruct)
#define MVFFBlockPool(mvff) MFSPool(&(mvff)->cbsBlockPoolStruct)
static Bool MVFFCheck(MVFF mvff);
/* MVFFDebug -- MVFFDebug class */
@ -786,8 +760,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);
CHECKC(MVFFPool, mvff);

View file

@ -1,40 +1,38 @@
/* 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.
* Copyright (c) 2001-2018 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 (or last) fit is an
* appropriate policy.
*
* .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) RVALUE(&(mvff)->poolStruct)
#endif /* poolmv_h */
#endif /* poolmvff_h */
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2018 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*