1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-05 03:20:39 -08:00
emacs/mps/test/function/223.c
Gareth Rees fd3136bb30 Fix mmqa function test cases so that they run on windows. in detail:
1. On w3i6mv, int and long are 32 bits, so these types can't be used to hold a size_t or an mps_word_t. See 26.c, 38.c, 47.c, 66.c, 123.c, 136.c, 164.c, 165.c, 200.c, 203.c, 204.c, 205.c, 206.c, 207.c, 215.c, 223.c.
2. The Windows command line doesn't cope with parentheses. See 170.c.
3. The natural platform alignment is 16 bytes on w3i6mv, so allocations into pools using the default alignment need to be rounded up. See 21.c, 22.c, 203.c, 204.c, 205.c.
4. Microsoft Visual C/C++ is fussy about signed/unsigned comparison. See 226.c.
5. windows.h defines a SIZE macro so you can't use it as a parameter. See 232.c.

Copied from Perforce
 Change: 191569
 ServerID: perforce.ravenbrook.com
2016-04-22 15:44:58 +01:00

183 lines
3.9 KiB
C

/*
TEST_HEADER
id = $Id$
summary = test of ramp allocation
language = c
link = testlib.o rankfmt.o
parameters = ITERATIONS=50000
OUTPUT_SPEC
result = pass
END_HEADER
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "rankfmt.h"
#define ARENALIMIT (200)
#define TABSIZE (ITERATIONS / 2)
#define ENTERRAMP (ITERATIONS / 10)
#define LEAVERAMP (ITERATIONS / 10)
#define BACKSIZE (128)
#define BACKITER (32)
#define RAMPSIZE (128)
#define RAMP_INTERFACE
/*
#define COLLECT_WORLD
*/
#define genCOUNT (3)
static mps_gen_param_s testChain[genCOUNT] = {
{ 6000, 0.90 }, { 8000, 0.65 }, { 16000, 0.50 } };
void *stackpointer;
mps_arena_t arena;
mps_pool_t poolamc;
mps_thr_t thread;
mps_root_t root, root1;
mps_chain_t chain;
mps_fmt_t format;
mps_ap_t apamc;
static mps_addr_t objtab[TABSIZE];
static void alloc_back(void) {
long int i, j;
for (j = 0; j < BACKITER; j++) {
i = ranint(ranint(ranint(ranint(TABSIZE)+1)+1)+1);
objtab[i] = allocdumb(apamc, BACKSIZE, mps_rank_exact());
}
}
static void test(void) {
long int i;
long int rsize;
mps_message_t message;
int inramp;
mycell *r, *s;
cdie(mps_arena_create(&arena, mps_arena_class_vm(),
(size_t) 1024*1024*ARENALIMIT),
"create arena");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(
mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread,
mps_stack_scan_ambig, stackpointer, 0),
"create root");
cdie(
mps_root_create_table(&root1, arena, mps_rank_exact(), 0, &objtab[0], TABSIZE),
"create root table");
cdie(
mps_fmt_create_A(&format, arena, &fmtA),
"create format");
cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
cdie(
mps_pool_create(&poolamc, arena, mps_class_amc(), format, chain),
"create pool");
cdie(
mps_ap_create(&apamc, poolamc, mps_rank_exact()),
"create ap");
mps_message_type_enable(arena, mps_message_type_gc());
inramp = 0;
for (i = 0; i < ITERATIONS; i++) {
if (i * 10 % ITERATIONS == 0) {
comment("%ld of %ld", i, ITERATIONS);
}
alloc_back();
if (inramp) {
s = allocone(apamc, 3, mps_rank_exact());
setref(r, 0, s);
setref(s, 1, r);
r = s;
s = allocdumb(apamc, RAMPSIZE, mps_rank_exact());
setref(r, 2, s);
rsize ++;
if (ranint(LEAVERAMP) == 0) {
r = allocone(apamc, 2, mps_rank_exact());
s = allocone(apamc, 2, mps_rank_exact());
#ifdef RAMP_INTERFACE
mps_ap_alloc_pattern_end(apamc, mps_alloc_pattern_ramp_collect_all());
#endif
#ifdef COLLECT_WORLD
mps_arena_collect(arena);
mps_arena_release(arena);
#endif
comment("ramp end, %ld objects", rsize);
inramp = 0;
}
} else {
if (ranint(ENTERRAMP) == 0) {
#ifdef RAMP_INTERFACE
mps_ap_alloc_pattern_begin(apamc, mps_alloc_pattern_ramp_collect_all());
#endif
comment("ramp begin");
r = allocone(apamc, 3, mps_rank_exact());
inramp = 1;
rsize = 0;
}
}
if(mps_message_get(&message, arena, mps_message_type_gc())) {
size_t live, condemned, notCondemned;
live = mps_message_gc_live_size(arena, message);
condemned = mps_message_gc_condemned_size(arena, message);
notCondemned = mps_message_gc_not_condemned_size(arena, message);
comment("Collection: live=%ld, condemned=%ld, not condemned = %ld",
live, condemned, notCondemned);
mps_message_discard(arena, message);
}
}
mps_arena_park(arena);
mps_ap_destroy(apamc);
comment("Destroyed ap.");
mps_pool_destroy(poolamc);
comment("Destroyed pool.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_chain_destroy(chain);
comment("Destroyed chain.");
mps_root_destroy(root1);
mps_root_destroy(root);
comment("Destroyed roots.");
mps_thread_dereg(thread);
comment("Deregistered thread.");
mps_arena_destroy(arena);
comment("Destroyed arena.");
}
int main(void)
{
void *m;
stackpointer=&m; /* hack to get stack pointer */
easy_tramp(test);
report("result", "pass");
return 0;
}