mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-17 16:41:17 -08:00
Make it stop, update to modern oncventions
Copied from Perforce Change: 19128 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
4eed443152
commit
b8fa30de4d
1 changed files with 63 additions and 52 deletions
115
mps/src/amsss.c
115
mps/src/amsss.c
|
|
@ -1,15 +1,12 @@
|
|||
/* impl.c.amsss: POOL CLASS AMS STRESS TEST
|
||||
*
|
||||
* $HopeName: MMsrc!amsss.c(trunk.3) $
|
||||
* $HopeName: MMsrc!amsss.c(trunk.4) $
|
||||
* Copyright (C) 1996, 1997 Harlequin Group, all rights reserved
|
||||
*
|
||||
* A direct copy of amcss.c, with trivial changes. nickb 1997-08-14
|
||||
* .design: Adapted from amcss.c, but not counting collections, just
|
||||
* total size of objects allocated.
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mps.h"
|
||||
#include "mpscams.h"
|
||||
#include "fmtdy.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
|
@ -19,21 +16,32 @@
|
|||
#ifdef MPS_OS_SU
|
||||
#include "ossu.h"
|
||||
#endif
|
||||
#include "testlib.h"
|
||||
#include "mps.h"
|
||||
#include "mpscams.h"
|
||||
#include "mpsavm.h"
|
||||
#include "fmtdy.h"
|
||||
|
||||
|
||||
#define exactRootsCOUNT 50
|
||||
#define ambigRootsCOUNT 50
|
||||
/* Even this much takes 20 min to run in variety CI on gaia. */
|
||||
#define totalSizeMAX 4 * 1024 * (size_t)1024
|
||||
#define totalSizeSTEP 1 * 1024 * (size_t)1024
|
||||
#define objNULL ((mps_addr_t)0xDECEA5ED)
|
||||
#define testArenaSIZE ((size_t)16<<20)
|
||||
|
||||
#define NR_EXACT_ROOTS 50
|
||||
#define NR_AMBIG_ROOTS 50
|
||||
#define FIELDS_MAX 2000
|
||||
#define COLLECTIONS 5
|
||||
#define OBJNULL ((mps_addr_t)0xDECEA5ED)
|
||||
|
||||
static mps_pool_t pool;
|
||||
static mps_ap_t ap;
|
||||
static mps_addr_t exact_roots[NR_EXACT_ROOTS];
|
||||
static mps_addr_t ambig_roots[NR_AMBIG_ROOTS];
|
||||
static mps_addr_t exactRoots[exactRootsCOUNT];
|
||||
static mps_addr_t ambigRoots[ambigRootsCOUNT];
|
||||
static size_t totalSize = 0;
|
||||
|
||||
|
||||
static mps_addr_t make(void)
|
||||
{
|
||||
size_t length = rnd() % 20, size = (length+2)*sizeof(mps_word_t);
|
||||
size_t length = rnd() % 20, size = (length+2) * sizeof(mps_word_t);
|
||||
mps_addr_t p;
|
||||
mps_res_t res;
|
||||
|
||||
|
|
@ -41,103 +49,106 @@ static mps_addr_t make(void)
|
|||
MPS_RESERVE_BLOCK(res, p, ap, size);
|
||||
if(res)
|
||||
die(res, "MPS_RESERVE_BLOCK");
|
||||
res = dylan_init(p, size, exact_roots, NR_EXACT_ROOTS);
|
||||
res = dylan_init(p, size, exactRoots, exactRootsCOUNT);
|
||||
if(res)
|
||||
die(res, "dylan_init");
|
||||
} while(!mps_commit(ap, p, size));
|
||||
|
||||
totalSize += size;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static void *test(void *arg, size_t s)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_arena_t arena;
|
||||
mps_fmt_t format;
|
||||
mps_root_t exact_root, ambig_root;
|
||||
mps_root_t exactRoot, ambigRoot;
|
||||
size_t lastStep = 0;
|
||||
unsigned long i;
|
||||
mps_word_t collections;
|
||||
|
||||
space = (mps_space_t)arg;
|
||||
arena = (mps_arena_t)arg;
|
||||
(void)s; /* unused */
|
||||
|
||||
die(mps_fmt_create_A(&format, space, dylan_fmt_A()), "fmt_create");
|
||||
die(mps_fmt_create_A(&format, arena, dylan_fmt_A()), "fmt_create");
|
||||
|
||||
die(mps_pool_create(&pool, space, mps_class_ams(), format),
|
||||
die(mps_pool_create(&pool, arena, mps_class_ams(), format),
|
||||
"pool_create(ams)");
|
||||
|
||||
die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "BufferCreate");
|
||||
|
||||
die(mps_root_create_table(&exact_root, space,
|
||||
die(mps_root_create_table(&exactRoot, arena,
|
||||
MPS_RANK_EXACT, (mps_rm_t)0,
|
||||
&exact_roots[0], NR_EXACT_ROOTS),
|
||||
&exactRoots[0], exactRootsCOUNT),
|
||||
"root_create_table(exact)");
|
||||
|
||||
die(mps_root_create_table(&ambig_root, space,
|
||||
die(mps_root_create_table(&ambigRoot, arena,
|
||||
MPS_RANK_AMBIG, (mps_rm_t)0,
|
||||
&ambig_roots[0], NR_AMBIG_ROOTS),
|
||||
&ambigRoots[0], ambigRootsCOUNT),
|
||||
"root_create_table(ambig)");
|
||||
|
||||
for(i=0; i<NR_EXACT_ROOTS; ++i)
|
||||
exact_roots[i] = OBJNULL;
|
||||
for(i = 0; i < exactRootsCOUNT; ++i)
|
||||
exactRoots[i] = objNULL;
|
||||
|
||||
for(i=0; i<NR_AMBIG_ROOTS; ++i)
|
||||
ambig_roots[i] = (mps_addr_t)rnd();
|
||||
for(i = 0; i < ambigRootsCOUNT; ++i)
|
||||
ambigRoots[i] = (mps_addr_t)rnd();
|
||||
|
||||
collections = 0;
|
||||
|
||||
i = 0;
|
||||
while(collections < COLLECTIONS) {
|
||||
unsigned c;
|
||||
while(totalSize < totalSizeMAX) {
|
||||
size_t r;
|
||||
|
||||
c = mps_collections(space);
|
||||
|
||||
if(collections != c) {
|
||||
collections = c;
|
||||
printf("\nCollection %u, %lu objects.\n",
|
||||
c, i);
|
||||
if(totalSize > lastStep + totalSizeSTEP) {
|
||||
lastStep = totalSize;
|
||||
printf("\nSize %lu bytes, %lu objects.\n",
|
||||
(unsigned long)totalSize, i);
|
||||
fflush(stdout);
|
||||
for(r = 0; r < NR_EXACT_ROOTS; ++r)
|
||||
assert(exact_roots[r] == OBJNULL ||
|
||||
dylan_check(exact_roots[r]));
|
||||
for(r = 0; r < exactRootsCOUNT; ++r)
|
||||
assert(exactRoots[r] == objNULL ||
|
||||
dylan_check(exactRoots[r]));
|
||||
}
|
||||
|
||||
if(rnd() & 1)
|
||||
exact_roots[rnd() % NR_EXACT_ROOTS] = make();
|
||||
exactRoots[rnd() % exactRootsCOUNT] = make();
|
||||
else
|
||||
ambig_roots[rnd() % NR_AMBIG_ROOTS] = make();
|
||||
ambigRoots[rnd() % ambigRootsCOUNT] = make();
|
||||
|
||||
r = rnd() % exactRootsCOUNT;
|
||||
if(exactRoots[r] != objNULL)
|
||||
assert(dylan_check(exactRoots[r]));
|
||||
|
||||
++i;
|
||||
if (i % 256 == 0) {
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
r = rnd() % NR_EXACT_ROOTS;
|
||||
if(exact_roots[r] != OBJNULL)
|
||||
assert(dylan_check(exact_roots[r]));
|
||||
}
|
||||
|
||||
mps_ap_destroy(ap);
|
||||
mps_root_destroy(exact_root);
|
||||
mps_root_destroy(ambig_root);
|
||||
mps_root_destroy(exactRoot);
|
||||
mps_root_destroy(ambigRoot);
|
||||
mps_pool_destroy(pool);
|
||||
mps_fmt_destroy(format);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_arena_t arena;
|
||||
mps_thr_t thread;
|
||||
void *r;
|
||||
|
||||
die(mps_space_create(&space), "space_create");
|
||||
die(mps_thread_reg(&thread, space), "thread_reg");
|
||||
mps_tramp(&r, test, space, 0);
|
||||
die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
|
||||
"arena_create");
|
||||
die(mps_thread_reg(&thread, arena), "thread_reg");
|
||||
mps_tramp(&r, test, arena, 0);
|
||||
mps_thread_dereg(thread);
|
||||
mps_space_destroy(space);
|
||||
mps_arena_destroy(arena);
|
||||
|
||||
fprintf(stderr, "\nConclusion: Failed to find any defects.\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue