1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-23 23:36:27 -07:00

Mps br/auto_header: mpsicv: use auto_header format half the time (rnd() & 1);

also: drop tabs; update copyright date

Copied from Perforce
 Change: 164501
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Kistruck 2008-03-26 14:30:59 +00:00
parent a2e31d78c7
commit cd44df4e24

View file

@ -5,18 +5,12 @@
* Portions copyright (c) 2002 Global Graphics Software.
*/
#define AUTO_HEADER 1
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "mpscmv.h"
#if AUTO_HEADER
#include "fmthe.h"
#endif
#include "fmtdy.h"
#include "fmtdytst.h"
#include "mps.h"
#include "mpstd.h"
@ -44,10 +38,9 @@ static mps_gen_param_s testChain[genCOUNT] = {
static mps_pool_t amcpool;
static mps_ap_t ap;
static size_t ap_headerSIZE = 0;
/* For this ap.... */
#if AUTO_HEADER
/* Auto_header format
*
* [ auto_header ][===object===]
@ -57,24 +50,17 @@ static mps_ap_t ap;
*
* Note: pMps < pCli; sizeMps > sizeCli.
*/
#define PtrMps2Cli(n) ((char*)n + headerSIZE)
#define PtrCli2Mps(n) ((char*)n - headerSIZE)
#define SizeMps2Cli(n) (n - headerSIZE)
#define SizeCli2Mps(n) (n + headerSIZE)
#define PtrMps2Cli(n) ((char*)n + ap_headerSIZE)
#define PtrCli2Mps(n) ((char*)n - ap_headerSIZE)
#define SizeMps2Cli(n) (n - ap_headerSIZE)
#define SizeCli2Mps(n) (n + ap_headerSIZE)
#define HeaderInit(pMps) do { \
mps_addr_t pMpsTEMP = (pMps); /* macro hygiene */ \
((int*)pMpsTEMP)[0] = realHeader; \
((int*)pMpsTEMP)[1] = 0xED0ED; \
if(ap_headerSIZE != 0) { \
mps_addr_t pMps_MACROCOPY = (pMps); /* macro hygiene */ \
((int*)pMps_MACROCOPY)[0] = realHeader; \
((int*)pMps_MACROCOPY)[1] = 0xED0ED; \
} \
} while(0)
#else
#include "fmtdy.h"
#define PtrMps2Cli(n) (n)
#define PtrCli2Mps(n) (n)
#define SizeMps2Cli(n) (n)
#define SizeCli2Mps(n) (n)
#define HeaderInit(pMps) do { \
} while(0)
#endif
static mps_addr_t exactRoots[exactRootsCOUNT];
static mps_addr_t ambigRoots[ambigRootsCOUNT];
@ -141,17 +127,17 @@ static void alignmentTest(mps_arena_t arena)
static mps_addr_t make(void)
{
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
mps_res_t res;
do {
MPS_RESERVE_BLOCK(res, pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "MPS_RESERVE_BLOCK");
HeaderInit(pMps);
pCli = PtrMps2Cli(pMps);
HeaderInit(pMps);
pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init");
} while(!mps_commit(ap, pMps, sizeMps));
@ -164,17 +150,17 @@ static mps_addr_t make(void)
static mps_addr_t make_with_permit(void)
{
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
mps_res_t res;
do {
MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK(res, pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK");
HeaderInit(pMps);
pCli = PtrMps2Cli(pMps);
pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init");
} while(!mps_commit(ap, pMps, sizeMps));
@ -187,17 +173,17 @@ static mps_addr_t make_with_permit(void)
static mps_addr_t make_no_inline(void)
{
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
size_t length = rnd() % 20;
size_t sizeCli = (length+2)*sizeof(mps_word_t);
size_t sizeMps = SizeCli2Mps(sizeCli);
mps_addr_t pMps, pCli;
mps_res_t res;
do {
res = (mps_reserve)(&pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "(mps_reserve)");
HeaderInit(pMps);
pCli = PtrMps2Cli(pMps);
pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init");
} while(!(mps_commit)(ap, pMps, sizeMps));
@ -340,11 +326,15 @@ static void *test(void *arg, size_t s)
arena = (mps_arena_t)arg;
testlib_unused(s);
#if AUTO_HEADER
EnsureHeaderFormat(&format, arena);
#else
die(dylan_fmt(&format, arena), "fmt_create");
#endif
if (rnd() & 1) {
printf("Using auto_header format.\n");
EnsureHeaderFormat(&format, arena);
ap_headerSIZE = headerSIZE; /* from fmthe.h */
} else {
printf("Using normal format (no implicit object header: client pointers point at start of storage).\n");
die(dylan_fmt(&format, arena), "fmt_create");
ap_headerSIZE = 0;
}
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
@ -457,8 +447,8 @@ static void *test(void *arg, size_t s)
cdie(rampCount > 0 ? res == MPS_RES_OK : res == MPS_RES_FAIL,
"alloc_pattern_end");
if (rampCount > 0) {
--rampCount;
}
--rampCount;
}
break;
case 3:
die(mps_ap_alloc_pattern_reset(ap), "alloc_pattern_reset");
@ -538,7 +528,7 @@ int main(int argc, char **argv)
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2002, 2008 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*