mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-26 00:01:47 -07:00
New unit
new test Copied from Perforce Change: 18871 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
1756f2b99e
commit
f57431a7d9
8 changed files with 1465 additions and 0 deletions
140
mps/qa/function/43.c
Normal file
140
mps/qa/function/43.c
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/* TEST_HEADER
|
||||
summary = regresion test for request.dylan.170461
|
||||
language = c
|
||||
link = testlib.o awlfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscamc.h"
|
||||
#include "awlfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_pool_t poolamc, poolawl;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc, apexact, apweak;
|
||||
|
||||
mycell *a, *b, *c, *d, *e, *f, *g;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
RC;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apexact, poolawl, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apweak, poolawl, MPS_RANK_WEAK),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
b = allocone(apamc, 1, 1);
|
||||
|
||||
for (j=1; j<10; j++)
|
||||
{
|
||||
comment("%i of 10.", j);
|
||||
UC;
|
||||
a = allocone(apexact, 5, 1);
|
||||
setref(a, 0, b);
|
||||
b = a;
|
||||
c = a;
|
||||
d = a;
|
||||
e = a;
|
||||
f = a;
|
||||
g = a;
|
||||
|
||||
for (i=1; i<1000; i++)
|
||||
{
|
||||
UC;
|
||||
c = allocone(apamc, 1000, 0);
|
||||
if (ranint(2) == 0) {
|
||||
c = allocone(apweak, 100, 1);
|
||||
} else {
|
||||
c = allocone(apexact, 100, 1);
|
||||
}
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
UC;
|
||||
setref(c, 0, b);
|
||||
UC;
|
||||
setref(c, 1, d);
|
||||
UC;
|
||||
setref(c, 2, e);
|
||||
UC;
|
||||
setref(c, 3, f);
|
||||
UC;
|
||||
setref(c, 4, g);
|
||||
UC;
|
||||
b = c;
|
||||
}
|
||||
DC;
|
||||
DMC;
|
||||
}
|
||||
|
||||
mps_ap_destroy(apweak);
|
||||
mps_ap_destroy(apexact);
|
||||
mps_ap_destroy(apamc);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
mps_pool_destroy(poolawl);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root);
|
||||
comment("Destroyed root.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
182
mps/qa/function/44.c
Normal file
182
mps/qa/function/44.c
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/* TEST_HEADER
|
||||
summary = clamp and space_collect tests
|
||||
language = c
|
||||
link = testlib.o exfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscamc.h"
|
||||
#include "exfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_pool_t poolamc, poolawl;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root, root1;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc, apawl;
|
||||
|
||||
size_t size0, size1;
|
||||
mycell *a, *b, *c, *d, *e, *f, *g;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
RC;
|
||||
|
||||
deathcomments = 0;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_root_create_table(&root1, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1),
|
||||
"create exfmt root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apawl, poolawl, MPS_RANK_WEAK),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
b = allocone(apamc, 1, 1);
|
||||
|
||||
for (j=1; j<10; j++) {
|
||||
comment("%i of 10.", j);
|
||||
a = allocone(apawl, 5, 1);
|
||||
setref(b, 0, a);
|
||||
b = a;
|
||||
c = a;
|
||||
d = a;
|
||||
e = a;
|
||||
f = a;
|
||||
g = a;
|
||||
for (i=1; i<1000; i++) {
|
||||
if (i%100 == 0) {
|
||||
comment(" %i", i);
|
||||
}
|
||||
if (ranint(2)) {
|
||||
c = allocone(apamc, 1000, 1);
|
||||
} else {
|
||||
c = allocone(apawl, 1000, 1);
|
||||
}
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
setref(b, 0, c);
|
||||
setref(c, 1, d);
|
||||
setref(c, 2, e);
|
||||
setref(c, 3, f);
|
||||
setref(c, 4, g);
|
||||
b = c;
|
||||
}
|
||||
if (j==3) {
|
||||
DC;
|
||||
comment("...collecting:");
|
||||
RC;
|
||||
size0 = mps_arena_committed(space);
|
||||
mps_arena_collect(space);
|
||||
size1 = mps_arena_committed(space);
|
||||
report("sizebefore0", "%lu", (unsigned long) size0);
|
||||
report("sizeafter0", "%lu", (unsigned long) size1);
|
||||
DC;
|
||||
mps_arena_release(space);
|
||||
comment("...released");
|
||||
}
|
||||
DC;
|
||||
comment("clamping...");
|
||||
mps_arena_park(space);
|
||||
RC;
|
||||
for (i=1; i<1000; i++) {
|
||||
if (i%100 == 0) {
|
||||
comment(" %i", i);
|
||||
}
|
||||
if (ranint(2)) {
|
||||
c = allocone(apamc, 1000, 1);
|
||||
} else {
|
||||
c = allocone(apawl, 1000, 1);
|
||||
}
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
setref(b, 0, c);
|
||||
setref(c, 1, d);
|
||||
setref(c, 2, e);
|
||||
setref(c, 3, f);
|
||||
setref(c, 4, g);
|
||||
b = c;
|
||||
}
|
||||
asserts(counters[COPY_COUNT]==0, "Eppur si muove!");
|
||||
DC;
|
||||
if (j==9) {
|
||||
comment("collecting...");
|
||||
size0 = mps_arena_committed(space);
|
||||
mps_arena_collect(space);
|
||||
size1 = mps_arena_committed(space);
|
||||
report("sizebefore1", "%lu", (unsigned long) size0);
|
||||
report("sizeafter1", "%lu", (unsigned long) size1);
|
||||
DC;
|
||||
}
|
||||
mps_arena_release(space);
|
||||
comment("released.");
|
||||
RC;
|
||||
}
|
||||
|
||||
mps_ap_destroy(apawl);
|
||||
mps_ap_destroy(apamc);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
mps_pool_destroy(poolawl);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root);
|
||||
mps_root_destroy(root1);
|
||||
comment("Destroyed roots.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
213
mps/qa/function/45.c
Normal file
213
mps/qa/function/45.c
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/* TEST_HEADER
|
||||
summary = arena_collect when lots of APs are in mid-cycle
|
||||
language = c
|
||||
link = testlib.o newfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
/*
|
||||
See MMQA_test_function!12.c, on which this test is closely based.
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscamc.h"
|
||||
#include "newfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
#define NCELLS 100
|
||||
#define NAPS 100
|
||||
#define PNULL (ranint(100)<25)
|
||||
#define NUMREFS (ranint(80))
|
||||
#define BLAH 0
|
||||
|
||||
mps_ap_t ap[NAPS];
|
||||
mycell *p[NAPS];
|
||||
size_t s[NAPS];
|
||||
int nrefs[NAPS];
|
||||
int ap_state[NAPS];
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_pool_t pool;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root;
|
||||
|
||||
mps_fmt_t format;
|
||||
mycell *cells;
|
||||
|
||||
int h,i,j,k,l;
|
||||
mycell *pobj;
|
||||
|
||||
size_t size0, size1;
|
||||
long mdiff = 0;
|
||||
size_t bytes;
|
||||
size_t alignment;
|
||||
mps_addr_t q;
|
||||
int nextid = 0x1000000;
|
||||
|
||||
/* turn on comments about copying and scanning */
|
||||
formatcomments = BLAH;
|
||||
fixcomments = BLAH;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&pool, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
for (i=0; i<NAPS; i++)
|
||||
{
|
||||
die(mps_ap_create(&ap[i], pool, MPS_RANK_EXACT), "create ap");
|
||||
ap_state[i] = 0;
|
||||
}
|
||||
|
||||
cells = allocone(ap[0], NCELLS);
|
||||
|
||||
/* ap_state can have the following values:
|
||||
0 before reserve
|
||||
1 after reverse
|
||||
2 after init
|
||||
3 after I=A
|
||||
0 after commit
|
||||
*/
|
||||
|
||||
for(h=0; h<100; h++)
|
||||
{
|
||||
comment("%i of 100", h);
|
||||
|
||||
for(j=0; j<1000; j++)
|
||||
{
|
||||
if (j==500) {
|
||||
size0 = mps_arena_committed(space);
|
||||
mps_arena_collect(space);
|
||||
size1 = mps_arena_committed(space);
|
||||
asserts(((long) size1)-((long) size0) < 1024*1024,
|
||||
"Collection made space bigger: %lu -> %lu",
|
||||
(unsigned long) size0, (unsigned long) size1);
|
||||
if (((long) size1)-((long) size0) > mdiff) {
|
||||
mdiff = ((long) size1) - ((long) size0);
|
||||
}
|
||||
}
|
||||
i = ranint(NAPS);
|
||||
|
||||
switch (ap_state[i])
|
||||
{
|
||||
case 0:
|
||||
nrefs[i] = NUMREFS;
|
||||
bytes = offsetof(struct data, ref)+nrefs[i]*sizeof(struct refitem);
|
||||
alignment = MPS_PF_ALIGN;
|
||||
bytes = (bytes+alignment-1)&~(alignment-1);
|
||||
s[i] = bytes;
|
||||
die(mps_reserve(&q, ap[i], s[i]), "reserve: ");
|
||||
p[i] = q;
|
||||
p[i]->data.tag = 0xD033E2A6;
|
||||
p[i]->data.id = nextid;
|
||||
ap_state[i] = 1;
|
||||
commentif(BLAH, "%i: reserve %li at %p", i, nextid, q);
|
||||
nextid +=1;
|
||||
break;
|
||||
case 1:
|
||||
commentif(BLAH, "%i: init %li", i, p[i]->data.id);
|
||||
p[i]->data.tag = MCdata;
|
||||
p[i]->data.numrefs = nrefs[i];
|
||||
p[i]->data.size = s[i];
|
||||
ap_state[i] = 2;
|
||||
for (k=0; k<nrefs[i]; k++)
|
||||
{
|
||||
if PNULL
|
||||
{ p[i]->data.ref[k].addr = NULL;
|
||||
p[i]->data.ref[k].id = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = ranint(NCELLS);
|
||||
pobj = getref(cells, l);
|
||||
p[i]->data.ref[k].addr = pobj;
|
||||
p[i]->data.ref[k].id = (pobj==NULL ? 0 : pobj->data.id);
|
||||
}
|
||||
commentif(BLAH, " ref %i -> %li", k, p[i]->data.ref[k].id);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
commentif(BLAH, "%i: begin commit %li", i, p[i]->data.id);
|
||||
ap[i]->init = ap[i]->alloc;
|
||||
ap_state[i] = 3;
|
||||
break;
|
||||
case 3:
|
||||
commentif(BLAH, "%i: end commit %li", i, p[i]->data.id);
|
||||
q=p[i];
|
||||
if (ap[i]->limit != 0 || mps_ap_trip(ap[i], p[i], s[i]))
|
||||
{
|
||||
l = ranint(NCELLS);
|
||||
setref(cells, l, q);
|
||||
commentif(BLAH, "%i -> %i", i, l);
|
||||
}
|
||||
ap_state[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
checkfrom(cells);
|
||||
}
|
||||
|
||||
comment("Maximum size increase:");
|
||||
report("mincr", "%ld", mdiff);
|
||||
|
||||
comment("Finished main loop");
|
||||
|
||||
for (i=0; i<NAPS; i++)
|
||||
{
|
||||
switch (ap_state[i])
|
||||
{
|
||||
case 1:
|
||||
commentif(BLAH, "%i init", i);
|
||||
p[i]->data.tag = MCdata;
|
||||
p[i]->data.numrefs = 0;
|
||||
p[i]->data.size = s[i];
|
||||
case 2:
|
||||
commentif(BLAH, "%i begin commit", i);
|
||||
ap[i]->init = ap[i]->alloc;
|
||||
case 3:
|
||||
commentif(BLAH, "% end commit", i);
|
||||
(void) (ap[i]->limit != 0 || mps_ap_trip(ap[i], p[i], s[i]));
|
||||
}
|
||||
mps_ap_destroy(ap[i]);
|
||||
}
|
||||
|
||||
mps_pool_destroy(pool);
|
||||
comment("Destroyed pool.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root);
|
||||
comment("Destroyed root.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
pass();
|
||||
return 0;
|
||||
}
|
||||
161
mps/qa/function/46.c
Normal file
161
mps/qa/function/46.c
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
/* TEST_HEADER
|
||||
summary = mps_park and mps_amc_apply
|
||||
language = c
|
||||
link = testlib.o exfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscamc.h"
|
||||
#include "exfmt.h"
|
||||
|
||||
#define MAGICSIZE ((size_t) 10342)
|
||||
|
||||
void *stackpointer;
|
||||
long int appcount;
|
||||
long int apppadcount;
|
||||
|
||||
static void test_apply(mps_addr_t addr, void *V, size_t S) {
|
||||
mycell *a;
|
||||
|
||||
asserts(S == MAGICSIZE, "Size didn't get passed!");
|
||||
a = addr;
|
||||
asserts(((a->tag) & 0x3) == MCdata || ((a->tag) & 0x3) == MCpad,
|
||||
"apply on non-data and non-pad object at %p", addr);
|
||||
if (((a->tag) & 0x3) == MCdata) {
|
||||
appcount += 1;
|
||||
} else {
|
||||
apppadcount +=1;
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_pool_t poolamc;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root, root1;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc;
|
||||
|
||||
size_t size0, size1;
|
||||
mycell *a, *b, *c, *d, *e, *f, *g;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
RC;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_root_create_table(&root1, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1),
|
||||
"create exfmt root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
b = allocone(apamc, 1, 1);
|
||||
|
||||
for (j=1; j<10; j++) {
|
||||
comment("%i of 10.", j);
|
||||
a = allocone(apamc, 5, 1);
|
||||
b = a;
|
||||
c = a;
|
||||
d = a;
|
||||
e = a;
|
||||
f = a;
|
||||
g = a;
|
||||
for (i=1; i<1000; i++) {
|
||||
c = allocone(apamc, 1000, 1);
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
setref(c, 0, b);
|
||||
setref(c, 1, d);
|
||||
setref(c, 2, e);
|
||||
setref(c, 3, f);
|
||||
setref(c, 4, g);
|
||||
b = c;
|
||||
}
|
||||
comment("parking...");
|
||||
mps_arena_park(space);
|
||||
for (i=1; i<1000; i++) {
|
||||
c = allocone(apamc, 1000, 1);
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
setref(c, 0, b);
|
||||
setref(c, 1, d);
|
||||
setref(c, 2, e);
|
||||
setref(c, 3, f);
|
||||
setref(c, 4, g);
|
||||
b = c;
|
||||
}
|
||||
a = c;
|
||||
b = c;
|
||||
d = c;
|
||||
e = c;
|
||||
f = c;
|
||||
g = c;
|
||||
mps_arena_collect(space);
|
||||
comment("calling amc_apply:");
|
||||
checkfrom(c);
|
||||
appcount = 0;
|
||||
apppadcount = 0;
|
||||
mps_amc_apply(poolamc, &test_apply, NULL, MAGICSIZE);
|
||||
comment("finished amc_apply.");
|
||||
report("appcount", "%ld", appcount);
|
||||
report("apppadcount", "%ld", apppadcount);
|
||||
mps_arena_release(space);
|
||||
comment("released.");
|
||||
RC;
|
||||
}
|
||||
|
||||
mps_ap_destroy(apamc);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root);
|
||||
mps_root_destroy(root1);
|
||||
comment("Destroyed roots.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
118
mps/qa/function/47.c
Normal file
118
mps/qa/function/47.c
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/* TEST_HEADER
|
||||
summary = LDs don't go stale when using only non-moving pools
|
||||
language = c
|
||||
link = testlib.o rankfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscmv.h"
|
||||
#include "mpscamc.h"
|
||||
#include "rankfmt.h"
|
||||
|
||||
#define MAXLDS 100
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
static void test(void) {
|
||||
mps_space_t space;
|
||||
mps_pool_t poolmv, poolawl;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root0, root1;
|
||||
|
||||
mps_addr_t p;
|
||||
mps_ld_t lds[MAXLDS];
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apawl;
|
||||
|
||||
mycell *a, *b;
|
||||
|
||||
int i;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_table(&root0, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1),
|
||||
"create exfmt root");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root1, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create register and stack root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create awl pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolmv, space, mps_class_mv(), 0x4000, 128, 0x4000),
|
||||
"create mv pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
b = allocone(apawl, 5, MPS_RANK_EXACT);
|
||||
|
||||
for (i=0; i < MAXLDS; i++) {
|
||||
comment("%d", i);
|
||||
mps_alloc(&p, poolmv, sizeof(mps_ld_s));
|
||||
a = allocone(apawl, 5, MPS_RANK_EXACT);
|
||||
setref(a, 0, b);
|
||||
b = a;
|
||||
a = allocdumb(apawl, 256*1024, MPS_RANK_EXACT);
|
||||
comment("alloc");
|
||||
lds[i] = p;
|
||||
mps_ld_reset(lds[i], space);
|
||||
comment("reset");
|
||||
if (i>0) {
|
||||
mps_ld_add(lds[i], space, (mps_addr_t) b);
|
||||
}
|
||||
comment("add");
|
||||
}
|
||||
|
||||
for (i=0; i < MAXLDS; i++) {
|
||||
comment("%d", i);
|
||||
asserts(mps_ld_isstale(lds[i], space, p) == 0,
|
||||
"%d stale but shouldn't be", i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
mps_ap_destroy(apawl);
|
||||
comment("Destroyed ap.");
|
||||
|
||||
mps_pool_destroy(poolmv);
|
||||
mps_pool_destroy(poolawl);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root0);
|
||||
mps_root_destroy(root1);
|
||||
comment("Destroyed roots.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
141
mps/qa/function/48.c
Normal file
141
mps/qa/function/48.c
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/* TEST_HEADER
|
||||
summary = test awl and amc pools, checking ranks work properly
|
||||
language = c
|
||||
link = testlib.o rankfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscamc.h"
|
||||
#include "rankfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
mps_space_t space;
|
||||
mps_pool_t poolamc, poolawl;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc, apawl, apweak;
|
||||
|
||||
mycell *a, *b, *c, *d, *e, *f, *g;
|
||||
|
||||
int i;
|
||||
int j;
|
||||
|
||||
RC;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apweak, poolawl, MPS_RANK_WEAK),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
b = allocone(apamc, 1, 1);
|
||||
|
||||
for (j=1; j<10; j++)
|
||||
{
|
||||
comment("%i of 10.", j);
|
||||
UC;
|
||||
a = allocone(apawl, 5, MPS_RANK_EXACT);
|
||||
setref(b, 0, a);
|
||||
b = a;
|
||||
c = a;
|
||||
d = a;
|
||||
e = a;
|
||||
f = a;
|
||||
g = a;
|
||||
|
||||
for (i=1; i<1000; i++)
|
||||
{
|
||||
UC;
|
||||
if (ranint(3) == 0) {
|
||||
c = allocone(apawl, 500, MPS_RANK_EXACT);
|
||||
} else if (ranint(2) == 0) {
|
||||
c = allocone(apweak, 500, MPS_RANK_WEAK);
|
||||
} else {
|
||||
c = allocone(apamc, 500, MPS_RANK_EXACT);
|
||||
}
|
||||
if (ranint(8) == 0) d = c;
|
||||
if (ranint(8) == 0) e = c;
|
||||
if (ranint(8) == 0) f = c;
|
||||
if (ranint(8) == 0) g = c;
|
||||
UC;
|
||||
setref(b, 0, c);
|
||||
UC;
|
||||
setref(c, 1, d);
|
||||
UC;
|
||||
setref(c, 2, e);
|
||||
UC;
|
||||
setref(c, 3, f);
|
||||
UC;
|
||||
setref(c, 4, g);
|
||||
UC;
|
||||
b = c;
|
||||
}
|
||||
DC;
|
||||
DMC;
|
||||
}
|
||||
|
||||
mps_ap_destroy(apawl);
|
||||
mps_ap_destroy(apamc);
|
||||
mps_ap_destroy(apweak);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
mps_pool_destroy(poolawl);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_root_destroy(root);
|
||||
comment("Destroyed root.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
282
mps/qa/function/50.c
Normal file
282
mps/qa/function/50.c
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
/* TEST_HEADER
|
||||
summary = finalization tests with AMC, AWL and LO
|
||||
language = c
|
||||
link = testlib.o rankfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscamc.h"
|
||||
#include "mpsclo.h"
|
||||
#include "rankfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
mps_space_t space;
|
||||
|
||||
int final_count = 0;
|
||||
|
||||
enum {
|
||||
FINAL_DISCARD,
|
||||
FINAL_REREGISTER,
|
||||
FINAL_STORE,
|
||||
FINAL_QUEUE
|
||||
};
|
||||
|
||||
mps_message_t mqueue[10000];
|
||||
|
||||
int qhd = 0;
|
||||
int qtl = 0;
|
||||
|
||||
static void nq(mps_message_t mess) {
|
||||
mqueue[qhd] = mess;
|
||||
qhd = (qhd+1) % 10000;
|
||||
asserts(qhd != qtl, "No space in message queue.");
|
||||
}
|
||||
|
||||
static int qmt(void) {
|
||||
if (qhd == qtl) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int dq(mps_message_t *mess) {
|
||||
if (qhd == qtl) {
|
||||
return 0;
|
||||
} else {
|
||||
*mess = mqueue[qtl];
|
||||
qtl = (qtl+1) % 10000;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void process_mess(mps_message_t message, int faction, mps_addr_t *ref) {
|
||||
mps_addr_t ffref;
|
||||
|
||||
switch (faction) {
|
||||
case FINAL_DISCARD:
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_REREGISTER:
|
||||
mps_message_finalization_ref(&ffref, space, message);
|
||||
mps_finalize(space, &ffref);
|
||||
final_count +=1;
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_STORE:
|
||||
mps_message_finalization_ref(ref, space, message);
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_QUEUE:
|
||||
nq(message);
|
||||
break;
|
||||
default:
|
||||
asserts(0, "Unknown finalization action.");
|
||||
}
|
||||
}
|
||||
|
||||
static void qpoll(mps_addr_t *ref, int faction) {
|
||||
mps_message_t message;
|
||||
|
||||
if (dq(&message)) {
|
||||
process_mess(message, faction, ref);
|
||||
}
|
||||
}
|
||||
|
||||
static void finalpoll(mps_addr_t *ref, int faction) {
|
||||
mps_message_t message;
|
||||
|
||||
if (mps_message_get(&message, space, MPS_MESSAGE_TYPE_FINALIZATION)) {
|
||||
final_count -=1;
|
||||
process_mess(message, faction, ref);
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void) {
|
||||
mps_pool_t poolamc, poolawl, poollo;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root0, root1;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc, apawl, aplo;
|
||||
|
||||
mycell *a, *b, *c, *d, *e, *z;
|
||||
|
||||
long int j;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root0, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_root_create_table(&root1, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1),
|
||||
"create table root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poollo, space, mps_class_lo(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apawl, poolawl, MPS_RANK_WEAK),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&aplo, poollo, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
mps_message_type_enable(space, mps_message_type_finalization());
|
||||
|
||||
/* register loads of objects for finalization (1000*4) */
|
||||
|
||||
a = allocone(apamc, 2, 1);
|
||||
b = a;
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
a = allocone(apamc, 2, MPS_RANK_EXACT);
|
||||
c = allocone(apawl, 2, MPS_RANK_WEAK);
|
||||
d = allocone(aplo, 2, MPS_RANK_EXACT); /* rank irrelevant here! */
|
||||
mps_finalize(space, &a);
|
||||
mps_finalize(space, &c);
|
||||
mps_finalize(space, &d);
|
||||
mps_finalize(space, &d);
|
||||
final_count += 4;
|
||||
setref(a, 0, b);
|
||||
setref(a, 1, c);
|
||||
setref(c, 1, d);
|
||||
b = a;
|
||||
}
|
||||
|
||||
/* throw them all away and collect everything */
|
||||
|
||||
a = NULL;
|
||||
b = NULL;
|
||||
c = NULL;
|
||||
d = NULL;
|
||||
|
||||
mps_arena_collect(space);
|
||||
|
||||
while (mps_message_poll(space)) {
|
||||
finalpoll(&z, FINAL_DISCARD);
|
||||
}
|
||||
|
||||
/* how many are left? (n.b. ideally this would be 0 but
|
||||
there's no guarantee)
|
||||
*/
|
||||
|
||||
report("count1", "%i", final_count);
|
||||
|
||||
/* now to test leaving messages open for a long time! */
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
comment("%d of 10", j);
|
||||
a = allocone(apamc, 10000, MPS_RANK_EXACT);
|
||||
mps_finalize(space, &a);
|
||||
final_count +=1;
|
||||
comment("finalize");
|
||||
finalpoll(&z, FINAL_QUEUE);
|
||||
}
|
||||
|
||||
comment("reregister");
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
comment("%d of 10", j);
|
||||
qpoll(&z, FINAL_REREGISTER);
|
||||
}
|
||||
|
||||
b = a;
|
||||
z = a;
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
comment("%d of 10", j);
|
||||
finalpoll(&z, FINAL_QUEUE);
|
||||
qpoll(&z, FINAL_STORE);
|
||||
a = allocone(apamc, 2, MPS_RANK_EXACT);
|
||||
setref(z, 0, b);
|
||||
setref(a, 1, z);
|
||||
b = a;
|
||||
}
|
||||
|
||||
|
||||
for (j=0; j<10; j++) {
|
||||
a = allocone(apamc, 2, MPS_RANK_EXACT);
|
||||
qpoll(&z, FINAL_DISCARD);
|
||||
finalpoll(&z, FINAL_DISCARD);
|
||||
setref(a, 0, b);
|
||||
b = a;
|
||||
}
|
||||
|
||||
/* Force old objects to be killed */
|
||||
|
||||
while (qmt() == 0) {
|
||||
qpoll(&z, FINAL_DISCARD);
|
||||
}
|
||||
|
||||
while (mps_message_poll(space)) {
|
||||
finalpoll(&z, FINAL_DISCARD);
|
||||
}
|
||||
|
||||
mps_root_destroy(root0);
|
||||
mps_root_destroy(root1);
|
||||
comment("Destroyed roots.");
|
||||
|
||||
mps_ap_destroy(apawl);
|
||||
mps_ap_destroy(apamc);
|
||||
mps_ap_destroy(aplo);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_arena_collect(space);
|
||||
comment("Collected space.");
|
||||
|
||||
while (mps_message_poll(space)) {
|
||||
finalpoll(&z, FINAL_DISCARD);
|
||||
}
|
||||
|
||||
report("count2", "%d", final_count);
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
mps_pool_destroy(poolawl);
|
||||
mps_pool_destroy(poollo);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
228
mps/qa/function/51.c
Normal file
228
mps/qa/function/51.c
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
/* TEST_HEADER
|
||||
summary = wait until all registered objects are finalized
|
||||
language = c
|
||||
link = testlib.o rankfmt.o
|
||||
END_HEADER
|
||||
*/
|
||||
|
||||
#include "testlib.h"
|
||||
#include "mpscawl.h"
|
||||
#include "mpscamc.h"
|
||||
#include "mpsclo.h"
|
||||
#include "rankfmt.h"
|
||||
|
||||
void *stackpointer;
|
||||
|
||||
mps_space_t space;
|
||||
|
||||
int final_count = 0;
|
||||
|
||||
enum {
|
||||
FINAL_DISCARD,
|
||||
FINAL_REREGISTER,
|
||||
FINAL_STORE,
|
||||
FINAL_QUEUE
|
||||
};
|
||||
|
||||
mps_message_t mqueue[10000];
|
||||
|
||||
int qhd = 0;
|
||||
int qtl = 0;
|
||||
|
||||
static void nq(mps_message_t mess) {
|
||||
mqueue[qhd] = mess;
|
||||
qhd = (qhd+1) % 10000;
|
||||
asserts(qhd != qtl, "No space in message queue.");
|
||||
}
|
||||
|
||||
static int qmt(void) {
|
||||
if (qhd == qtl) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int dq(mps_message_t *mess) {
|
||||
if (qhd == qtl) {
|
||||
return 0;
|
||||
} else {
|
||||
*mess = mqueue[qtl];
|
||||
qtl = (qtl+1) % 10000;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void process_mess(mps_message_t message, int faction, mps_addr_t *ref) {
|
||||
mps_addr_t ffref;
|
||||
|
||||
switch (faction) {
|
||||
case FINAL_DISCARD:
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_REREGISTER:
|
||||
mps_message_finalization_ref(&ffref, space, message);
|
||||
mps_finalize(space, &ffref);
|
||||
final_count +=1;
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_STORE:
|
||||
mps_message_finalization_ref(ref, space, message);
|
||||
mps_message_discard(space, message);
|
||||
break;
|
||||
case FINAL_QUEUE:
|
||||
nq(message);
|
||||
break;
|
||||
default:
|
||||
asserts(0, "Unknown finalization action.");
|
||||
}
|
||||
}
|
||||
|
||||
static void qpoll(mps_addr_t *ref, int faction) {
|
||||
mps_message_t message;
|
||||
|
||||
if (dq(&message)) {
|
||||
process_mess(message, faction, ref);
|
||||
}
|
||||
}
|
||||
|
||||
static void finalpoll(mps_addr_t *ref, int faction) {
|
||||
mps_message_t message;
|
||||
|
||||
if (mps_message_get(&message, space, MPS_MESSAGE_TYPE_FINALIZATION)) {
|
||||
final_count -=1;
|
||||
process_mess(message, faction, ref);
|
||||
}
|
||||
}
|
||||
|
||||
static void test(void) {
|
||||
mps_pool_t poolamc, poolawl, poollo;
|
||||
mps_thr_t thread;
|
||||
mps_root_t root0, root1;
|
||||
|
||||
mps_fmt_t format;
|
||||
mps_ap_t apamc, apawl, aplo;
|
||||
|
||||
mycell *a, *b, *c, *d, *e, *z;
|
||||
|
||||
long int j;
|
||||
|
||||
cdie(mps_space_create(&space), "create space");
|
||||
|
||||
cdie(mps_thread_reg(&thread, space), "register thread");
|
||||
|
||||
cdie(
|
||||
mps_root_create_reg(&root0, space, MPS_RANK_AMBIG, 0, thread,
|
||||
mps_stack_scan_ambig, stackpointer, 0),
|
||||
"create root");
|
||||
|
||||
cdie(
|
||||
mps_root_create_table(&root1, space, MPS_RANK_AMBIG, 0, &exfmt_root, 1),
|
||||
"create table root");
|
||||
|
||||
cdie(
|
||||
mps_fmt_create_A(&format, space, &fmtA),
|
||||
"create format");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolamc, space, mps_class_amc(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poolawl, space, mps_class_awl(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_pool_create(&poollo, space, mps_class_lo(), format),
|
||||
"create pool");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apawl, poolawl, MPS_RANK_WEAK),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
cdie(
|
||||
mps_ap_create(&aplo, poollo, MPS_RANK_EXACT),
|
||||
"create ap");
|
||||
|
||||
mps_message_type_enable(space, mps_message_type_finalization());
|
||||
|
||||
/* register loads of objects for finalization (1000*4) */
|
||||
|
||||
a = allocone(apamc, 2, 1);
|
||||
b = a;
|
||||
|
||||
for (j=0; j<1000; j++) {
|
||||
a = allocone(apamc, 2, MPS_RANK_EXACT);
|
||||
c = allocone(apawl, 2, MPS_RANK_WEAK);
|
||||
d = allocone(aplo, 2, MPS_RANK_EXACT); /* rank irrelevant here! */
|
||||
mps_finalize(space, &a);
|
||||
mps_finalize(space, &c);
|
||||
mps_finalize(space, &d);
|
||||
mps_finalize(space, &d);
|
||||
final_count += 4;
|
||||
}
|
||||
|
||||
/* throw them all away and collect everything */
|
||||
|
||||
a = NULL;
|
||||
b = NULL;
|
||||
c = NULL;
|
||||
d = NULL;
|
||||
|
||||
mps_root_destroy(root0);
|
||||
mps_root_destroy(root1);
|
||||
comment("Destroyed roots.");
|
||||
|
||||
mps_arena_collect(space);
|
||||
|
||||
while (final_count != 0) {
|
||||
finalpoll(&z, FINAL_DISCARD);
|
||||
if (mps_message_poll(space) == 0) {
|
||||
a = allocdumb(apawl, 1024, MPS_RANK_WEAK);
|
||||
a = allocdumb(apamc, 1024, MPS_RANK_EXACT);
|
||||
a = allocdumb(aplo, 1024, MPS_RANK_EXACT);
|
||||
mps_arena_collect(space);
|
||||
comment(" %i", final_count);
|
||||
}
|
||||
}
|
||||
|
||||
/* how many are left? (n.b. ideally this would be 0 but
|
||||
there's no guarantee)
|
||||
*/
|
||||
|
||||
report("count1", "%i", final_count);
|
||||
|
||||
/* now to test leaving messages open for a long time! */
|
||||
|
||||
mps_ap_destroy(apawl);
|
||||
mps_ap_destroy(apamc);
|
||||
mps_ap_destroy(aplo);
|
||||
comment("Destroyed aps.");
|
||||
|
||||
mps_pool_destroy(poolamc);
|
||||
mps_pool_destroy(poolawl);
|
||||
mps_pool_destroy(poollo);
|
||||
comment("Destroyed pools.");
|
||||
|
||||
mps_fmt_destroy(format);
|
||||
comment("Destroyed format.");
|
||||
|
||||
mps_thread_dereg(thread);
|
||||
comment("Deregistered thread.");
|
||||
|
||||
mps_space_destroy(space);
|
||||
comment("Destroyed space.");
|
||||
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
void *m;
|
||||
stackpointer=&m; /* hack to get stack pointer */
|
||||
|
||||
easy_tramp(test);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue