mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-19 01:10:57 -08:00
Convert to chains
Copied from Perforce Change: 21677 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
56a68abfa3
commit
de0f8d32f9
1 changed files with 54 additions and 36 deletions
|
|
@ -1,12 +1,11 @@
|
|||
/* impl.c.amcsshe: POOL CLASS AMC STRESS TEST WITH HEADER
|
||||
*
|
||||
* $HopeName: MMsrc!amcsshe.c(trunk.3) $
|
||||
* Copyright (C) 2000 Harlequin Limited. All rights reserved.
|
||||
* $HopeName: MMsrc!amcsshe.c(trunk.4) $
|
||||
* Copyright (C) 2001 Harlequin Limited. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "fmthe.h"
|
||||
#include "testlib.h"
|
||||
|
||||
#include "mpscamc.h"
|
||||
#include "mpsavm.h"
|
||||
#include "mpstd.h"
|
||||
|
|
@ -14,20 +13,27 @@
|
|||
#include "mpsw3.h"
|
||||
#endif
|
||||
#include "mps.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define testArenaSIZE ((size_t)64<<13)
|
||||
/* These values have been tuned to cause one top-generation collection. */
|
||||
#define testArenaSIZE ((size_t)1000*1024)
|
||||
#define avLEN 3
|
||||
#define exactRootsCOUNT 300
|
||||
#define exactRootsCOUNT 200
|
||||
#define ambigRootsCOUNT 50
|
||||
#define bogusRootsCOUNT 4096
|
||||
#define collectionsCOUNT 18
|
||||
#define rampSIZE 5
|
||||
#define collectionsCOUNT 37
|
||||
#define rampSIZE 9
|
||||
#define initTestFREQ 6000
|
||||
#define genCOUNT 2
|
||||
|
||||
/* testChain -- generation parameters for the test */
|
||||
|
||||
static mps_gen_param_s testChain[genCOUNT] = {
|
||||
{ 150, 0.85 }, { 170, 0.45 } };
|
||||
|
||||
|
||||
/* objNULL needs to be odd so that it's ignored in exactRoots. */
|
||||
#define objNULL ((mps_addr_t)0xDECEA5ED)
|
||||
|
||||
|
|
@ -62,11 +68,11 @@ static mps_res_t init(mps_addr_t addr, size_t size,
|
|||
/* Make sure the size is aligned. */
|
||||
if ((size & (ALIGN-1)) != 0) return MPS_RES_PARAM;
|
||||
|
||||
if(ww == NULL) {
|
||||
if (ww == NULL) {
|
||||
ww = malloc(sizeof(mps_word_t) * (BASIC_WRAPPER_SIZE + 1));
|
||||
if(ww == NULL) return MPS_RES_MEMORY;
|
||||
if (ww == NULL) return MPS_RES_MEMORY;
|
||||
tvw = malloc(sizeof(mps_word_t) * BASIC_WRAPPER_SIZE);
|
||||
if(tvw == NULL) {
|
||||
if (tvw == NULL) {
|
||||
free(ww);
|
||||
return MPS_RES_MEMORY;
|
||||
}
|
||||
|
|
@ -92,7 +98,7 @@ static mps_res_t init(mps_addr_t addr, size_t size,
|
|||
/* If there is enough room, make a vector, otherwise just */
|
||||
/* make a padding object. */
|
||||
|
||||
if(size >= sizeof(mps_word_t) * 2) {
|
||||
if (size >= sizeof(mps_word_t) * 2) {
|
||||
mps_word_t *p = (mps_word_t *)addr;
|
||||
mps_word_t i, t = (size / sizeof(mps_word_t)) - 2;
|
||||
|
||||
|
|
@ -101,7 +107,7 @@ static mps_res_t init(mps_addr_t addr, size_t size,
|
|||
for(i = 0; i < t; ++i) {
|
||||
mps_word_t r = rnd();
|
||||
|
||||
if(r & 1)
|
||||
if (r & 1)
|
||||
p[2+i] = ((r & ~(mps_word_t)3) | 1); /* random int */
|
||||
else
|
||||
p[2+i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */
|
||||
|
|
@ -120,11 +126,11 @@ static void dylan_write(mps_addr_t addr, mps_addr_t *refs, size_t nr_refs)
|
|||
mps_word_t t = p[1] >> 2;
|
||||
|
||||
/* If the object is a vector, update a random entry. */
|
||||
if(p[0] == (mps_word_t)tvw && t > 0) {
|
||||
if (p[0] == (mps_word_t)tvw && t > 0) {
|
||||
mps_word_t r = rnd();
|
||||
size_t i = 2 + (rnd() % t);
|
||||
|
||||
if(r & 1)
|
||||
if (r & 1)
|
||||
p[i] = ((r & ~(mps_word_t)3) | 1); /* random int */
|
||||
else
|
||||
p[i] = (mps_word_t)refs[(r >> 1) % nr_refs]; /* random ptr */
|
||||
|
|
@ -141,11 +147,11 @@ static mps_addr_t make(void)
|
|||
|
||||
do {
|
||||
MPS_RESERVE_BLOCK(res, p, ap, size + headerSIZE);
|
||||
if(res)
|
||||
if (res)
|
||||
die(res, "MPS_RESERVE_BLOCK");
|
||||
userP = (mps_addr_t)((char*)p + headerSIZE);
|
||||
res = init(userP, size, exactRoots, exactRootsCOUNT);
|
||||
if(res)
|
||||
if (res)
|
||||
die(res, "dylan_init");
|
||||
((int*)p)[0] = realTYPE;
|
||||
((int*)p)[1] = 0xED0ED;
|
||||
|
|
@ -155,10 +161,13 @@ static mps_addr_t make(void)
|
|||
}
|
||||
|
||||
|
||||
/* test -- the body of the test */
|
||||
|
||||
static void *test(void *arg, size_t s)
|
||||
{
|
||||
mps_arena_t arena;
|
||||
mps_fmt_t format;
|
||||
mps_chain_t chain;
|
||||
mps_root_t exactRoot, ambigRoot, bogusRoot;
|
||||
unsigned long objs; size_t i;
|
||||
mps_word_t collections, rampSwitch;
|
||||
|
|
@ -171,16 +180,17 @@ static void *test(void *arg, size_t s)
|
|||
(void)s; /* unused */
|
||||
|
||||
die(EnsureHeaderFormat(&format, arena), "fmt_create");
|
||||
die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
|
||||
|
||||
die(mps_pool_create(&pool, arena, mps_class_amc(), format),
|
||||
die(mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
|
||||
"pool_create(amc)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
die(mps_ap_create(&busy_ap, pool, MPS_RANK_EXACT), "BufferCreate 2");
|
||||
|
||||
for(i=0; i<exactRootsCOUNT; ++i)
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
for(i=0; i<ambigRootsCOUNT; ++i)
|
||||
for(i = 0; i < ambigRootsCOUNT; ++i)
|
||||
ambigRoots[i] = (mps_addr_t)rnd();
|
||||
|
||||
die(mps_root_create_table_masked(&exactRoot, arena,
|
||||
|
|
@ -212,22 +222,29 @@ static void *test(void *arg, size_t s)
|
|||
|
||||
c = mps_collections(arena);
|
||||
|
||||
if(collections != c) {
|
||||
if (collections != c) {
|
||||
collections = c;
|
||||
printf("\nCollection %lu, %lu objects.\n", c, objs);
|
||||
for(r = 0; r < exactRootsCOUNT; ++r) {
|
||||
if (exactRoots[r] != objNULL)
|
||||
die(HeaderFormatCheck(exactRoots[r]), "wrapper check");
|
||||
}
|
||||
if(collections == rampSwitch) {
|
||||
if (collections == rampSwitch) {
|
||||
rampSwitch += rampSIZE;
|
||||
if(ramping) {
|
||||
if (ramping) {
|
||||
mps_ap_alloc_pattern_end(ap, ramp);
|
||||
mps_ap_alloc_pattern_end(busy_ap, ramp);
|
||||
/* kill half of the roots */
|
||||
for(i = 0; i < exactRootsCOUNT; i += 2) {
|
||||
if (exactRoots[i] != objNULL) {
|
||||
die(HeaderFormatCheck(exactRoots[i]), "ramp kill check");
|
||||
exactRoots[i] = objNULL;
|
||||
}
|
||||
}
|
||||
/* Every other time, switch back immediately. */
|
||||
if(collections & 1) ramping = 0;
|
||||
if (collections & 1) ramping = 0;
|
||||
}
|
||||
if(!ramping) {
|
||||
if (!ramping) {
|
||||
mps_ap_alloc_pattern_begin(ap, ramp);
|
||||
mps_ap_alloc_pattern_begin(busy_ap, ramp);
|
||||
ramping = 1;
|
||||
|
|
@ -235,7 +252,7 @@ static void *test(void *arg, size_t s)
|
|||
}
|
||||
/* fill bogusRoots with variations of a real pointer */
|
||||
r = rnd() % exactRootsCOUNT;
|
||||
if(exactRoots[i] != objNULL) {
|
||||
if (exactRoots[i] != objNULL) {
|
||||
char *p = (char*)exactRoots[i];
|
||||
|
||||
for(i = 0; i < bogusRootsCOUNT; ++i, ++p)
|
||||
|
|
@ -243,13 +260,13 @@ static void *test(void *arg, size_t s)
|
|||
}
|
||||
}
|
||||
|
||||
r = rnd();
|
||||
if(r & 1) {
|
||||
r = (size_t)rnd();
|
||||
if (r & 1) {
|
||||
i = (r >> 1) % exactRootsCOUNT;
|
||||
if(exactRoots[i] != objNULL)
|
||||
if (exactRoots[i] != objNULL)
|
||||
die(HeaderFormatCheck(exactRoots[i]), "wrapper check");
|
||||
exactRoots[i] = make();
|
||||
if(exactRoots[(exactRootsCOUNT-1) - i] != objNULL)
|
||||
if (exactRoots[(exactRootsCOUNT-1) - i] != objNULL)
|
||||
dylan_write(exactRoots[(exactRootsCOUNT-1) - i],
|
||||
exactRoots, exactRootsCOUNT);
|
||||
} else {
|
||||
|
|
@ -259,10 +276,10 @@ static void *test(void *arg, size_t s)
|
|||
ambigRoots[i] = (mps_addr_t)((char *)(ambigRoots[i/2]) + 1);
|
||||
}
|
||||
|
||||
if(r % initTestFREQ == 0)
|
||||
if (r % initTestFREQ == 0)
|
||||
*(int*)busy_init = -1; /* check that the buffer is still there */
|
||||
|
||||
if(objs % 1024 == 0) {
|
||||
if (objs % 1024 == 0) {
|
||||
putchar('.');
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
@ -277,6 +294,7 @@ static void *test(void *arg, size_t s)
|
|||
mps_root_destroy(ambigRoot);
|
||||
mps_root_destroy(bogusRoot);
|
||||
mps_pool_destroy(pool);
|
||||
mps_chain_destroy(chain);
|
||||
mps_fmt_destroy(format);
|
||||
|
||||
return NULL;
|
||||
|
|
@ -291,9 +309,9 @@ int main(int argc, char **argv)
|
|||
|
||||
randomize(argc, argv);
|
||||
|
||||
die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
|
||||
die(mps_arena_create(&arena, mps_arena_class_vm(), 3*testArenaSIZE),
|
||||
"arena_create\n");
|
||||
adjust_collection_freq(0.2);
|
||||
die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit");
|
||||
die(mps_thread_reg(&thread, arena), "thread_reg");
|
||||
mps_tramp(&r, test, arena, 0);
|
||||
mps_thread_dereg(thread);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue