static void dotest(int kind, size_t unitSize, size_t extendBy,
 int number, int iter)
{
 mps_pool_t pool;
 int i, hd;
 clock_t time0, time1;
 int secs;

 asserts(number <= MAXNUMBER, "number too big");
 asserts(unitSize >= sizeof(int), "unitSize too small");

 time0 = clock();
 asserts(time0 != -1, "processor time not available");

 die(
  mps_pool_create(&pool, space, mps_class_mfs(), extendBy, unitSize),
  "create pool");

 for(hd=0; hd<number; hd++)
 {
  if (ranint(2) && (kind & 2))
  {
   queue[hd]=NULL;
  }
  else
  {
   mps_alloc(&queue[hd], pool, unitSize);
   *((int *) queue[hd])=hd;
  }
 };

 hd=-1;

 for(i=0; i<iter; i++)
 {
   if (kind & 1) hd = ranint(number);
   else {ranint(number); hd=(hd+1)%number;} /* call raninit anyway
                                               to use same time */

   asserts(queue[hd]==NULL || *((int*) queue[hd])==hd,
    "corrupt object (%s: %x, %x, %i, %i)",
    tdesc[kind], unitSize, extendBy, number, iter);

   if (queue[hd] != NULL) mps_free(pool, queue[hd], unitSize);

   if (ranint(2) && (kind & 2))
   {
    queue[hd]=NULL;
   }
   else
   {
    mps_alloc(&queue[hd], pool, unitSize);
    *((int *) queue[hd])=hd;
   }
 }

 mps_pool_destroy(pool);

 time1=clock();
 secs=(int) 100*(time1-time0)/CLOCKS_PER_SEC;

 comment("%s test (%x, %x, %i, %i) in %i centisecs",
  tdesc[kind], (int) extendBy, (int) unitSize, number, iter, secs);
}
Ejemplo n.º 2
0
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_collection_stats());

 inramp = 0;

 for (i = 0; i < ITERATIONS; i++) {
  if (i % 10000 == 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_collection_stats())) {
    unsigned long live, condemned, notCondemned;
    live = mps_message_collection_stats_live_size(arena, message);
    condemned = mps_message_collection_stats_condemned_size(arena, message);
    notCondemned = 
      mps_message_collection_stats_not_condemned_size(arena, message);
    comment("Collection: live=%ld,  condemned=%ld,  not condemned = %ld",
      live, condemned, notCondemned);
    mps_message_discard(arena, message);
  }
 }

 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.");
}
Ejemplo n.º 3
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t apamc, apawl;

 mycell *a, *b, *c, *d, *e, *f, *g;

 int i;
 int j;

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");
 die(mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread,
                         mps_stack_scan_ambig, stackpointer, 0),
     "create root");

 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool(amc)");

 cdie(
  mps_ap_create(&apawl, poolamc, mps_rank_exact()),
  "create ap");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap(amc)");

 b = allocone(apamc, 1, 1);

 for (j = 1; j < 100; j++) {
  comment("%i of 100.", j);
  UC;
  a = allocone(apamc, 5, 1);
  b = a;
  c = a;
  d = a;
  e = a;
  f = a;
  g = a;

  for (i = 1; i < 5000; i++) {
   UC;
   c = allocone(apamc, 20, 1);
   d = allocone(apawl, 20, 1);
   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_pool_destroy(poolamc);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
static void test(void) {
 mps_pool_t poolmv, poolawl, poolamc;
 mps_thr_t thread;
 mps_root_t root0, root1, root2;

 mps_addr_t p;
 mps_fmt_t format;
 mps_ap_t apawl, apamc;

 mycell *a, *b;

 int i,j;

 RC;

 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_table(&root2, space, MPS_RANK_EXACT, 0,
                        (mps_addr_t *)obj_table, MAXLDS),
  "create table 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");

 cdie(
  mps_pool_create(&poolamc, space, mps_class_amc(), format),
  "create amc pool");

 cdie(
  mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
  "create ap");

 /* first we'll use only pool classes MV and AWL. So LDs shouldn't
    go stale at all.
 */

 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(apamc, 256*1024, MPS_RANK_EXACT);
  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);
 }

/* allocate MAXLDS objects, and make each LD depend on the corresponding
   object
*/

 for (i=0; i < MAXLDS; i++) {
  comment("%d", i);
  obj_table[i] = allocone(apamc, ranint(100), MPS_RANK_EXACT);
  mps_ld_add(lds[i], space, (mps_addr_t) obj_table[i]);
 }

 for (i=0; i < 1000; i++) {
  comment("%d of 1000", i);
  checklds();
  for (j=0; j < 4; j++) {
   a = allocdumb(apamc, 32*1024, MPS_RANK_EXACT);
  }
 }

 mps_ap_destroy(apawl);
 mps_ap_destroy(apamc);
 comment("Destroyed aps.");

 mps_pool_destroy(poolmv);
 mps_pool_destroy(poolamc);
 mps_pool_destroy(poolawl);
 comment("Destroyed pools.");

 mps_fmt_destroy(format);
 comment("Destroyed format.");

 mps_root_destroy(root0);
 mps_root_destroy(root1);
 mps_root_destroy(root2);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_space_destroy(space);
 comment("Destroyed space.");

}
Ejemplo n.º 5
0
static void test(void)
{
/* a is a table of exact roots
   b    a table of ambiguous roots
   f    a table of non-roots
*/

 mycell *a[4], *b[4], *f[4];
 mps_addr_t addr;
 int i, j, k;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create arena");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 addr = &a[0];
 cdie(
  mps_root_create_table(&root, arena, mps_rank_exact(), 0, addr, 4),
  "create a root table");

 addr = &b[0];
 cdie(
  mps_root_create_table(&root1, arena, mps_rank_ambig(), 0, addr, 4),
  "create b 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_pool_create(&poollo, arena, mps_class_lo(), format),
  "create pool");

 cdie(
  mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
  "create pool");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap");

 cdie(
  mps_ap_create(&aplo, poollo, mps_rank_exact()),
  "create ap");

 cdie(
  mps_ap_create(&apawl, poolawl, mps_rank_exact()),
  "create ap");

 newstamp = 0;

 for (i=0; i<4; i++) {
  addr = &a[i];
  die(allocrdumb(addr, aplo, 64, mps_rank_exact()), "alloc failed");
  addr = &b[i];
  die(allocrone(addr, apawl, 5, mps_rank_exact()), "alloc failed");
  b[i]->data.ref[0].addr = a[i];
  addr = &a[i];
  die(allocrone(addr, apamc, 5, mps_rank_exact()), "alloc failed");
  a[i]->data.ref[0].addr = b[i];
 }


 for (j=0; j<100; j++) {

  comment("%i of 100", j);

  for (i=0; i<10000; i++) {
   k = ranint(4);
   addr = &a[k];
   die(allocrdumb(addr, aplo, 64, mps_rank_exact()), "alloc failed");
   k = ranint(4);
   addr = &b[k];
   die(allocrone(addr, apawl, 5, mps_rank_exact()), "alloc failed");
   b[k]->data.ref[0].addr = a[ranint(4)];
   b[k]->data.ref[1].addr = b[ranint(4)];
   addr = &a[k];
   die(allocrone(addr, apamc, 5, mps_rank_exact()), "alloc failed");
   f[k] = a[k]->data.ref[2].addr;
   a[k]->data.ref[2].addr = b[ranint(4)];
  }

  comment("walking...");

  mps_arena_park(arena);
  mps_arena_collect(arena);

  oldstamp = newstamp;
  newstamp += 1;
  mps_arena_formatted_objects_walk(arena, stepper,
                                   (void *) MAGICPOINT, MAGICSIZE);
  mps_arena_release(arena);

  comment("tracing...");

  oldstamp = newstamp;
  newstamp += 1;
  tracegraph((mycell *) exfmt_root);
  tracegraph(a[0]);
  tracegraph(a[1]);
  tracegraph(a[2]);
  tracegraph(a[3]);
  tracegraph(b[0]);
  tracegraph(b[1]);
  tracegraph(b[2]);
  tracegraph(b[3]);

  comment("f[0] = %p", f[0]); /* avoid compiler warning about used f */
  comment("ok");
 }

 mps_arena_park(arena);
 mps_ap_destroy(apamc);
 mps_ap_destroy(aplo);
 mps_ap_destroy(apawl);
 comment("Destroyed aps.");

 mps_pool_destroy(poolamc);
 mps_pool_destroy(poollo);
 mps_pool_destroy(poolawl);
 comment("Destroyed pools.");

 mps_fmt_destroy(format);
 comment("Destroyed format.");

 mps_chain_destroy(chain);
 comment("Destroyed chain.");

 mps_root_destroy(root);
 mps_root_destroy(root1);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 6
0
static void test(void)
{
 int i = 0, f = 0;
 mps_ap_t sap;
 mps_arena_t arena;
 mps_fmt_t format;
 mps_pool_t spool;
 mps_thr_t thread;
 mps_frame_t frames[MAXFRAMES];
 int nobj[MAXFRAMES+1];
 mycell *p;

/* create an arena that can't grow beyond 30 M */

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)THIRTY_MEG),
  "create arena");
 cdie(mps_arena_commit_limit_set(arena, (size_t)THIRTY_MEG),
  "commit limit set");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 cdie(
  mps_fmt_create_A(&format, arena, &fmtA),
  "create format");

 cdie(
  mps_pool_create(&spool, arena, mps_class_snc(), format),
  "create SNC pool");

 cdie(
  mps_ap_create(&sap, spool, mps_rank_exact()),
  "create ap");

/* repeatedly push and pop stack frames, and allocate objects in them
   at random. Parameters ensure that max allocation can't get too high.
*/

 for (i=0; i < ITERATIONS; i++) {
  switch (ranint(12)) {
  case 1: case 2: case 3: case 4: case 5:
   if (f < MAXFRAMES) {
    die(mps_ap_frame_push(&frames[f], sap), "push");
    comment("push %i", f);
    f++;
    nobj[f] = 0;
   }
   break;
  case 6: case 7: case 8: case 9: case 10:
   if (nobj[f] < MAXLEVOBJS) {
    p = allocone(sap, 16, mps_rank_exact());
    setref(p, 0, NULL);
    nobj[f]++;
   }
   break;
  case 11:
   if (f>0) {
    f -= 1+ranint(1+ranint(f)); /* new f is in [0, old f) */
    die(mps_ap_frame_pop(sap, frames[f]), "pop");
    comment("pop %i", f);
   }
   break;
  }
 }

 mps_arena_park(arena);
 mps_ap_destroy(sap);
 comment("Destroyed ap.");

 mps_pool_destroy(spool);
 comment("Destroyed pool.");

 mps_fmt_destroy(format);
 comment("Destroyed format.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_arena_destroy(arena);
 comment("Destroyed arena.");

}
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc, poolawl;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t apamc, apawl, apran;

 mycell *a[100], *c;

 int i;
 int j;
 int k,z;

 alloccomments = 1;
 skipcomments = 1;
 formatcomments = 1;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");
 die(mps_root_create_reg(&root, arena, MPS_RANK_AMBIG, 0, thread,
                         mps_stack_scan_ambig, stackpointer, 0),
     "create root");

 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool");

 cdie(
  mps_pool_create(&poolawl, arena, mps_class_awl(), format),
  "create pool");

 cdie(
  mps_ap_create(&apawl, poolawl, MPS_RANK_EXACT),
  "create ap");

 cdie(
  mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
  "create ap");

 for(i=0; i<100; i++) {
  a[i] = allocone(apamc, 6, 1);
 }

 for(i=0; i<10000; i++) {
  j = ranint(100);
  k = 5 + ranint(500);
  if (ranint(2)==1) {
   apran = apawl;
  } else {
   apran = apamc;
  }
  c = a[j];
  a[j] = allocone(apran, k, 1);
  k = ranint(100);
  z = ranint(2);
  setref(a[k], 0, c);
  setref(a[j], z, a[k]);
 }

 mps_ap_destroy(apawl);
 mps_ap_destroy(apamc);
 mps_pool_destroy(poolamc);
 mps_pool_destroy(poolawl);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 8
0
static void dt(int kind,
   size_t extendBy, size_t avgSize, size_t maxSize,
   size_t mins, size_t maxs, int number, int iter)
{
 mps_pool_t pool;
 int i, hd;
 clock_t time0, time1;
 size_t size;
 int secs;

 asserts(number <= MAXNUMBER, "number too big");

 time0 = clock();
 asserts(time0 != -1, "processor time not available");

 die(
  mps_pool_create(&pool, arena, mps_class_mv(),
                  extendBy, avgSize, maxSize),
  "create MV pool");

 for(hd=0; hd<number; hd++)
 {
  size = ranrange(mins, maxs);
  if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
  {
   queue[hd].addr=NULL;
  }
  else
  {
   die(mps_alloc(&queue[hd].addr, pool, size), "alloc");
   setobj(queue[hd].addr, size, (unsigned char) (hd%256));
   queue[hd].size = size;
  }
 };

 hd=-1;

 for(i=0; i<iter; i++)
 {
   if (kind & 1) hd = ranint(number);
   else {ranint(number); hd=(hd+1)%number;} /* call raninit anyway
                                               to use same time */

   if (queue[hd].addr != NULL)
   {
    asserts(chkobj(queue[hd].addr, queue[hd].size, (unsigned char) (hd%256)),
      "corrupt at %x (%s: %x, %x, %x, %x, %x, %i, %i)",
      queue[hd].addr,
      tdesc[kind], (int) extendBy, (int) avgSize, (int) maxSize,
      (int) mins, (int) maxs, number, iter);
    mps_free(pool, queue[hd].addr, queue[hd].size);
   }
   size = ranrange(mins, maxs);

   if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
   {
    queue[hd].addr=NULL;
   }
   else
   {
    die(mps_alloc(&queue[hd].addr, pool, size),"alloc");
    setobj(queue[hd].addr, size, (unsigned char) (hd%256));
    queue[hd].size = size;
   }
 }

 mps_pool_destroy(pool);

 time1=clock();
 secs=(int) 100*(time1-time0)/CLOCKS_PER_SEC;

 comment("%s test (%x, %x, %x, %x, %x, %i, %i) in %i centisecs",
  tdesc[kind], (int) extendBy, (int) avgSize, (int) maxSize,
  (int) mins, (int) maxs, number, iter, secs);
}
Ejemplo n.º 9
0
Archivo: 200.c Proyecto: Ravenbrook/mps
static void dt(int kind,
   size_t extendBy, size_t avgSize,
   unsigned long mins, unsigned long maxs, int number, int iter)
{
 mps_pool_t pool;
 int i, hd;
 clock_t time0, time1;
 size_t size;
 double secs;

 asserts(number <= MAXNUMBER, "number too big");

 time0 = clock();
 asserts(time0 != -1, "processor time not available");

 MPS_ARGS_BEGIN(args) {
   MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, extendBy);
   MPS_ARGS_ADD(args, MPS_KEY_MEAN_SIZE, avgSize);
   cdie(mps_pool_create_k(&pool, arena, mps_class_mvff(), args), "pool");
 } MPS_ARGS_END(args);

 for(hd=0; hd<number; hd++)
 {
  size = ranrange(mins, maxs);
  if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
  {
   queue[hd].addr=NULL;
  }
  else
  {
   die(mps_alloc(&queue[hd].addr, pool, size), "alloc");
   setobj(queue[hd].addr, size, (unsigned char) (hd%256));
   queue[hd].size = size;
  }
 };

 hd=-1;

 for(i=0; i<iter; i++)
 {
   if (kind & 1) hd = ranint(number);
   else {ranint(number); hd=(hd+1)%number;} /* call raninit anyway
                                               to use same time */

   if (queue[hd].addr != NULL)
   {
    asserts(chkobj(queue[hd].addr, queue[hd].size, (unsigned char) (hd%256)),
      "corrupt at %x (%s: %x, %x, %lx, %lx, %i, %i)",
      queue[hd].addr,
      tdesc[kind], (int) extendBy, (int) avgSize,
      mins, maxs, number, iter);
    mps_free(pool, queue[hd].addr, queue[hd].size);
   }
   size = ranrange(mins, maxs);

   if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
   {
    queue[hd].addr=NULL;
   }
   else
   {
    die(mps_alloc(&queue[hd].addr, pool, size),"alloc");
    setobj(queue[hd].addr, size, (unsigned char) (hd%256));
    queue[hd].size = size;
   }
 }

 mps_pool_destroy(pool);

 time1=clock();
 secs=(time1-time0)/(double)CLOCKS_PER_SEC;

 comment("%s test (%x, %x, %lx, %lx, %i, %i) in %.2f s",
  tdesc[kind], (int) extendBy, (int) avgSize,
  mins, maxs, number, iter, secs);
}
Ejemplo n.º 10
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t ap;

 mycell *z[10];

 mycell **a = &z[0];
 mycell **b = &z[1];
 mycell **c = &z[2];
 mycell **d = &z[3];
 mycell **e = &z[4];
 mycell **f = &z[5];
 mycell **g = &z[6];

 int i;
 int j;

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 cdie(
  mps_root_create_table(&root, arena, mps_rank_exact(), 0, (mps_addr_t*)&z[0], 10),
  "create table root");

 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 cdie(mmqa_pool_create_chain(&pool, arena, mps_class_amc(), format, chain),
      "create pool");

 cdie(
  mps_ap_create(&ap, pool, mps_rank_exact()),
  "create ap");

 for (j=1; j<100; j++)
 {
  comment("%i of 100.", j);
  UC;
  *a = allocone(ap, 5, 1);
  *b = *a;
  *c = *a;
  *d = *a;
  *e = *a;
  *f = *a;
  *g = *a;

  for (i=1; i<1000; i++)
  {
  UC;
   *c = allocone(ap, 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;
  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;
  }
 checkfrom(*a);
 }
 DC;
 DMC;

 checkfrom(*a);

 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 11
0
Archivo: 204.c Proyecto: Ravenbrook/mps
static void dt(int kind,
   size_t minSize, size_t avgSize, size_t maxSize,
   mps_word_t depth, mps_word_t fragLimit,
   unsigned long mins, unsigned long maxs, int number, int iter)
{
 mps_pool_t pool;
 mps_ap_t ap;
 int i, hd;
 clock_t time0, time1;
 size_t size;
 double secs;

 asserts(number <= MAXNUMBER, "number too big");

 time0 = clock();
 asserts(time0 != -1, "processor time not available");

 die(
  mps_pool_create(&pool, arena, mps_class_mvt(),
                  minSize, avgSize, maxSize, depth, fragLimit),
  "create MVT pool");

 die(mps_ap_create(&ap, pool, mps_rank_ambig()), "create ap");

 for(hd=0; hd<number; hd++)
 {
  size = ranrange(mins, maxs);
  if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
  {
   queue[hd].addr=NULL;
  }
  else
  {
   die(mvt_alloc(&queue[hd].addr, ap, size), "alloc");
   setobj(queue[hd].addr, size, (unsigned char) (hd%256));
   queue[hd].size = size;
  }
 };

 hd=-1;

 for(i=0; i<iter; i++)
 {
   if (kind & 1) hd = ranint(number);
   else {ranint(number); hd=(hd+1)%number;} /* call raninit anyway
                                               to use same time */

   if (queue[hd].addr != NULL)
   {
    asserts(chkobj(queue[hd].addr, queue[hd].size, (unsigned char) (hd%256)),
      "corrupt at %x (%s: %x, %x, %x, %i, %i, %lx, %lx, %i, %i)",
      queue[hd].addr,
      tdesc[kind], (int) minSize, (int) avgSize, (int) maxSize,
      (int) depth, (int) fragLimit,
      mins, maxs, number, iter);
    mps_free(pool, queue[hd].addr, queue[hd].size);
   }
   size = ranrange(mins, maxs);

   if ((ranint(2) && (kind & 2)) || (kind==DUMMY))
   {
    queue[hd].addr=NULL;
   }
   else
   {
    die(mvt_alloc(&queue[hd].addr, ap, size),"alloc");
    setobj(queue[hd].addr, size, (unsigned char) (hd%256));
    queue[hd].size = size;
   }
 }

 mps_ap_destroy(ap);
 mps_pool_destroy(pool);

 time1=clock();
 secs=(time1-time0)/(double)CLOCKS_PER_SEC;

 comment("%s test (%x, %x, %x, %i, %i, %lx, %lx, %i, %i) in %.2f s",
  tdesc[kind], (int) minSize, (int) avgSize, (int) maxSize,
  (int) depth, (int) fragLimit,
  mins, maxs, number, iter, secs);
}
Ejemplo n.º 12
0
Archivo: 45.c Proyecto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_chain_t chain;

 mycell *cells;

 int h,i,j,k,l;
 mycell *pobj;

 mycell *ambig[NAPS];

 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 = VERBOSE;
 fixcomments = VERBOSE;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");
 cdie(mps_root_create_thread(&root, arena, thread, stack_pointer), "thread root");
 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&pool, arena, mps_class_amc(), format, chain),
     "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<ITERATIONS; h++) {
   comment("%i of %i", h, ITERATIONS);

   for(j=0; j<1000; j++) {
     if (j == 500) {
       size0 = mps_arena_committed(arena) - mps_arena_spare_committed(arena);
       mps_arena_collect(arena);
       size1 = mps_arena_committed(arena) - mps_arena_spare_committed(arena);
       asserts(((long) size1)-((long) size0) < 1024*1024,
               "Collection made arena 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(VERBOSE, "%i: reserve %li at %p", i, nextid, q);
       nextid +=1;
       break;
     case 1:
       commentif(VERBOSE, "%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(VERBOSE, "    ref %i -> %li", k, p[i]->data.ref[k].id);
       }
       break;
     case 2:
       commentif(VERBOSE, "%i: begin commit %li", i, p[i]->data.id);
       ambig[i] = p[i];
       ap[i]->init = ap[i]->alloc;
       ap_state[i] = 3;
       break;
     case 3:
       commentif(VERBOSE, "%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(VERBOSE, "%i -> %i", i, l);
       }
       ap_state[i] = 0;
       ambig[i] = NULL;
       break;
     }
   }
   checkfrom(cells);
 }
Ejemplo n.º 13
0
static void test(void) {
 mps_pool_t poolmv, poolawl, poolamc;
 mps_thr_t thread;
 mps_root_t root0, root1, root2;
 mps_addr_t p;

 mps_chain_t chain;
 mps_fmt_t format;
 mps_ap_t apawl, apamc;

 mps_addr_t base;
 mps_addr_t *addr;

 int i,j,merge,stale,prevstale;

 mycell *held[AMBIGHOLD];

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), 100*1024*1024),
  "create arena");
 cdie(mps_thread_reg(&thread, arena), "register thread");
 base = &exfmt_root;
 addr = base;
 cdie(
  mps_root_create_table(&root0, arena, mps_rank_ambig(), 0, addr, 1),
  "create exfmt root");
 cdie(
  mps_root_create_table(&root2, arena, mps_rank_exact(), 0,
                        (mps_addr_t *)obj_table, MAXLDS),
  "create table root");
 cdie(
  mps_root_create_reg(&root1, arena, mps_rank_ambig(), 0, thread,
   mps_stack_scan_ambig, stackpointer, 0),
  "create register and stack root");
 cdie(
  mps_fmt_create_A(&format, arena, &fmtA),
  "create format");
 cdie(
  mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
  "create awl pool");

 cdie(
  mps_pool_create(&poolmv, arena, mps_class_mv(), 0x4000, 128, 0x4000),
  "create mv pool");

 cdie(
  mps_ap_create(&apawl, poolawl, mps_rank_exact()),
  "create ap");

 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 cdie(
  mps_pool_create(&poolamc, arena, mps_class_amc(), format, chain),
  "create amc pool");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap");

/* allocate MAXLDS objects, and make each LD depend on the corresponding
   object
*/

 for (i=0; i < MAXLDS; i++) {
  mps_alloc(&p, poolmv, sizeof(mps_ld_s));
  lds[i] = (mps_ld_t) p;
  mps_alloc(&p, poolmv, sizeof(mps_ld_s));
  ldm[i] = (mps_ld_t) p;
 }

 for (i=0; i < MAXLDS; i++) {
  obj_table[i] = allocone(apamc, ranint(1000), mps_rank_exact());
  mps_ld_reset(lds[i], arena);
  mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]);
  addr_table[i] = obj_table[i];
 }

 for (merge = 1; merge <= MAXMERGE; merge++) {
  comment("Merge %d", merge);

  for (i=0; i < MAXLDS; i++) {
   if (ranint(100) < BLATPERCENT) {
    obj_table[i] = allocone(apamc, ranint(1000), mps_rank_exact());
    mps_ld_reset(lds[i], arena);
    mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]);
    addr_table[i] = obj_table[i];
   }
  }

  mergelds(merge);

  stale = 0;
  prevstale = 0;
  i = 0;

  while (stale < MAXLDS) {
   for (j = 0; j < AMBIGHOLD; j++) {
    held[j] = obj_table[ranint(MAXLDS)];
   }
   i++;
   stale = checklds(merge);
   if (stale > prevstale) {
    prevstale = stale;
    comment("inc to %d at %d", stale, i);
   }
   for (j = 0; j < JUNK; j++) {
    (void)allocdumb(apamc, ranint(1000), mps_rank_exact());
   }
  }
 }

 comment("held[0] = %p", held[0]); /* avoid warning about unused variable */

 mps_arena_park(arena);
 mps_ap_destroy(apawl);
 mps_ap_destroy(apamc);
 comment("Destroyed aps.");

 mps_pool_destroy(poolmv);
 mps_pool_destroy(poolamc);
 mps_pool_destroy(poolawl);
 comment("Destroyed pools.");

 mps_fmt_destroy(format);
 comment("Destroyed format.");

 mps_chain_destroy(chain);
 comment("Destroyed chain.");

 mps_root_destroy(root0);
 mps_root_destroy(root1);
 mps_root_destroy(root2);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_arena_destroy(arena);
 comment("Destroyed arena.");

}
Ejemplo n.º 14
0
static void test(void)
{
 mycell *a[4], /* a is a table of exact roots */
        *b[4]; /* b is a table of ambiguous roots */
 int i, j, k;
 mps_chain_t chain;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 cdie(mps_root_create_table(&root, arena, mps_rank_exact(), 0,
                            (mps_addr_t *)&a[0], 4),
      "create a root table");

 cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0,
                            (mps_addr_t *)&b[0], 4),
      "create b root table");

 cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool(amc)");

 die(mmqa_pool_create_chain(&poollo, arena, mps_class_amcz(), format, chain),
     "create pool(amcz)");

 die(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
     "create pool(awl)");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap(amc)");

 cdie(
  mps_ap_create(&aplo, poollo, mps_rank_exact()),
  "create ap(amcz)");

 cdie(
  mps_ap_create(&apawl, poolawl, mps_rank_exact()),
  "create ap(awl)");

 newstamp = 0;

 for (i=0; i<4; i++) {
  die(allocrdumb(&a[i], aplo, 64, mps_rank_exact()), "alloc failed");
  a[i]->data.checkedflag = newstamp;
  die(allocrone(&b[i], apawl, 5, mps_rank_exact()), "alloc failed");
  b[i]->data.checkedflag = newstamp;
  b[i]->data.ref[0].addr = a[i];
  die(allocrone(&a[i], apamc, 5, mps_rank_exact()), "alloc failed");
  a[i]->data.checkedflag = newstamp;
  a[i]->data.ref[0].addr = b[i];
 }


 for (j=0; j<100; j++) {

  comment("%i of 100", j);

  for (i=0; i<10000; i++) {
   k = ranint(4);
   die(allocrdumb(&a[k], aplo, 64, mps_rank_exact()), "alloc failed");
   a[k]->data.checkedflag = newstamp;
   k = ranint(4);
   die(allocrone(&b[k], apawl, 5, mps_rank_exact()), "alloc failed");
   b[k]->data.checkedflag = newstamp;
   b[k]->data.ref[0].addr = a[ranint(4)];
   b[k]->data.ref[1].addr = b[ranint(4)];
   die(allocrone(&a[k], apamc, 5, mps_rank_exact()), "alloc failed");
   a[k]->data.checkedflag = newstamp;
   a[k]->data.ref[2].addr = b[ranint(4)];
  }

  comment("walking...");

  mps_arena_park(arena);
  mps_arena_collect(arena);

  oldstamp = newstamp;
  newstamp += 1;
  mps_arena_formatted_objects_walk(arena, stepper,
                                   (void *)MAGICPOINT, MAGICSIZE);
  mps_arena_release(arena);

  comment("tracing...");

  oldstamp = newstamp;
  newstamp += 1;
  tracegraph((mycell *) exfmt_root);
  tracegraph(a[0]);
  tracegraph(a[1]);
  tracegraph(a[2]);
  tracegraph(a[3]);
  tracegraph(b[0]);
  tracegraph(b[1]);
  tracegraph(b[2]);
  tracegraph(b[3]);
  
  comment("ok");
 }

 mps_ap_destroy(apamc);
 mps_ap_destroy(aplo);
 mps_ap_destroy(apawl);
 comment("Destroyed aps.");

 mps_pool_destroy(poolamc);
 mps_pool_destroy(poollo);
 mps_pool_destroy(poolawl);
 comment("Destroyed pools.");

 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_root_destroy(root1);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 15
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_chain_t chain;
 mps_fmt_t format;
 mycell *cells;

 int h,i,j,k,l;
 mycell *p[NAPS];
 mycell *pobj;
 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_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "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_fmt_create_A(&format, arena, &fmtA),
  "create format");

 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 cdie(
  mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
  "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);
 comment("%i collections", (int) mps_collections(arena));

 for(j=0; j<1000; j++)
 {
 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: case 4: case 5: case 6: case 7: case 8: case 9:
   ap_state[i]+=1;
   break; 
  case 10:
   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);
 }
Ejemplo n.º 16
0
Archivo: 113.c Proyecto: bhanug/mps
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc, poolawl;
 mps_thr_t thread;
 mps_root_t root, root1;

 mps_chain_t chain;
 mps_fmt_t format;
 mps_ap_t apamc, apawl;

 mycell *a, *b, *c, *d, *e, *f, *g;

 int i;
 int j;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "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_ambig(),0,&exfmt_root,1),
  "create table root");

 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_awl(), format, chain),
  "create pool");

 cdie(
  mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
  "create pool");

 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, mps_rank_exact());

 for (j=1; j<=ITERATIONS; j++)
 {
  comment("%i of %i.", j, ITERATIONS);
  a = allocone(apamc, 5, mps_rank_exact());
  b = a;
  c = a;
  d = a;
  e = a;
  f = a;
  g = a;

  for (i=1; i<=1000; i++)
  {
   c = allocone(apamc, 20, mps_rank_exact());
   d = allocone(apawl, 20, mps_rank_exact());
   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;
  }
 }

 mps_arena_park(arena);
 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_chain_destroy(chain);
 comment("Destroyed chain.");

 mps_root_destroy(root);
 mps_root_destroy(root1);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_arena_destroy(arena);
 comment("Destroyed arena.");

}
Ejemplo n.º 17
0
Archivo: 123.c Proyecto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 mps_arena_t arena;
 mps_pool_t poolamc, poolawl;
 mps_thr_t thread;
 mps_root_t root, rootb;

 mps_addr_t base;
 mps_addr_t *addr;
 mps_chain_t chain;
 mps_fmt_t format;
 mps_ap_t apamc, apawl;

 mps_word_t i, c;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (60ul*1024*1024)), "create arena");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 base = &b;
 addr = base;
 cdie(mps_root_create_table(&root, arena, mps_rank_ambig(), 0, addr, 1),
  "creat root");

 base = &exfmt_root;
 addr = base;
 cdie(mps_root_create_table(&rootb, arena, mps_rank_ambig(), 0, addr, 1),
  "create root b");

 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_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
  "create pool");

 cdie(
  mps_ap_create(&apawl, poolawl, mps_rank_weak()),
  "create ap");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap");

 formatcomments = 0;

 b = allocone(apamc, 1024, mps_rank_exact());

 c = mps_collections(arena);

 for (i=1; i<100; i++)
 {
  comment("%i of 100.", i);
  while (mps_collections(arena) == c) {
   a = allocone(apamc, 1024, mps_rank_exact());
   if (ranint(5)) {
    setref(a, 0, b);
   }
   b = a;
  }
  c = mps_collections(arena);
  a = allocone(apawl, 1, mps_rank_weak());
  a->data.id = 0;
  setref(a, 0, b);
 }

 mps_arena_park(arena);
 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_chain_destroy(chain);
 comment("Destroyed chain.");

 mps_root_destroy(root);
 mps_root_destroy(rootb);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 comment("Deregistered thread.");

 mps_arena_destroy(arena);
 comment("Destroyed arena.");

}
Ejemplo n.º 18
0
static void test(void)
{
 mps_pool_t poolmv, poolawl, poolamc;
 mps_thr_t thread;
 mps_root_t root0, root1, root2;

 mps_addr_t p;
 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t apawl, apamc;

 mycell *a, *b;

 int i,j;

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t)1024*1024*30),
      "create arena");

 cdie(mps_thread_reg(&thread, arena), "register thread");

 cdie(mps_root_create_table(&root0, arena, mps_rank_ambig(), 0,
                            (mps_addr_t*)&exfmt_root, 1),
      "create exfmt root");
 cdie(mps_root_create_table(&root2, arena, mps_rank_exact(), 0,
                            (mps_addr_t *)obj_table, MAXLDS),
      "create table root");

 cdie(mps_root_create_reg(&root1, arena, mps_rank_ambig(), 0, thread,
                          mps_stack_scan_ambig, stackpointer, 0),
      "create register and stack root");

 cdie(mps_fmt_create_A(&format, arena, &fmtA),
      "create format");

 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 cdie(mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
      "create awl pool");

 cdie(mps_pool_create(&poolmv, arena, mps_class_mv(), 0x4000, 128, 0x4000),
      "create mv pool");

 cdie(mps_ap_create(&apawl, poolawl, mps_rank_exact()),
      "create ap");

 /* First we'll use only pool classes MV and AWL. So LDs shouldn't */
 /* go stale at all. */

 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], arena);
  comment("reset");
  if (i>0) {
   mps_ld_add(lds[i], arena, (mps_addr_t) b);
  }
  comment("add");
 }

 for (i=0; i < MAXLDS; i++) {
  comment("%d", i);
  asserts(mps_ld_isstale(lds[i], arena, p) == 0,
          "%d stale but shouldn't be", i);
 }

 /* Then use AMC, so object do move and LDs go stale. */

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap");

 /* Allocate MAXLDS objects, and make each LD depend on the corresponding */
 /* object. */

 for (i=0; i < MAXLDS; i++) {
  comment("%d", i);
  obj_table[i] = allocone(apamc, ranint(100), mps_rank_exact());
  mps_ld_add(lds[i], arena, (mps_addr_t) obj_table[i]);
 }

 for (i=0; i < 1000; i++) {
  comment("%d of 1000", i);
  checklds();
  for (j=0; j < 8; j++) {
   a = allocdumb(apamc, 32*1024, mps_rank_exact());
  }
 }

 mps_ap_destroy(apawl);
 mps_ap_destroy(apamc);
 mps_pool_destroy(poolmv);
 mps_pool_destroy(poolamc);
 mps_pool_destroy(poolawl);
 comment("Destroyed pools.");

 mps_chain_destroy(chain);
 mps_fmt_destroy(format);

 mps_root_destroy(root0);
 mps_root_destroy(root1);
 mps_root_destroy(root2);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 19
0
static void test(void)
{
    mps_arena_t arena;
    mps_pool_t poolamc, poollo;
    mps_thr_t thread;
    mps_root_t root;

    mps_fmt_t format;
    mps_chain_t chain;
    mps_ap_t apamc, aplo;

    mycell *a[100];

    int i;
    int j;
    int k,z;

    alloccomments = 1;
    formatcomments = 1;

    cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
         "create arena");

    die(mps_thread_reg(&thread, arena), "register thread");
    die(mps_root_create_reg(&root, arena, mps_rank_ambig(), 0, thread,
                            mps_stack_scan_ambig, stackpointer, 0),
        "create root");

    die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
    cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

    die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
        "create pool(amc)");

    die(mps_pool_create(&poollo, arena, mps_class_lo(), format),
        "create pool(lo)");

    cdie(
        mps_ap_create(&aplo, poollo, mps_rank_exact()),
        "create ap");

    cdie(
        mps_ap_create(&apamc, poolamc, mps_rank_exact()),
        "create ap");

    for(i=0; i<100; i++) {
        a[i] = allocone(aplo, 6, 1);
    }

    for(i=0; i<10000; i++) {
        j = ranint(100);
        comment("New object %i", j);
        a[j] = allocone(aplo, 5+ranint(50), 1);
        k = ranint(50);
        z = ranint(5);
        comment("setting %i (%p) %i", k, a[k], z);
        setref(a[k], z, a[j]);
        (void)allocdumb(apamc, 0x400*64, 0);
    }

    mps_arena_park(arena);
    mps_ap_destroy(aplo);
    mps_ap_destroy(apamc);
    comment("Destroyed aps.");

    mps_pool_destroy(poolamc);
    mps_pool_destroy(poollo);
    comment("Destroyed pools.");

    mps_chain_destroy(chain);
    mps_fmt_destroy(format);

    mps_root_destroy(root);
    mps_thread_dereg(thread);

    mps_arena_destroy(arena);
    comment("Destroyed arena.");
}
Ejemplo n.º 20
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc;
 mps_thr_t thread;
 mps_root_t root, root2, root3, root4, root5, root6, root7, root1;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t apamc;

 typedef mycell * myroot;
 myroot a, b, c, d, e, f, g;

 int i;
 int j;

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");

 cdie(
  mps_root_create_table(&root1, arena, mps_rank_exact(), 0, (mps_addr_t*)&a, 1),
  "root");
 cdie(
  mps_root_create_table(&root2, arena, mps_rank_exact(), 0, (mps_addr_t*)&b, 1),
  "root");
 cdie(
  mps_root_create_table(&root3, arena, mps_rank_exact(), 0, (mps_addr_t*)&c, 1),
  "root");
 cdie(
  mps_root_create_table(&root4, arena, mps_rank_exact(), 0, (mps_addr_t*)&d, 1),
  "root");
 cdie(
  mps_root_create_table(&root5, arena, mps_rank_exact(), 0, (mps_addr_t*)&e, 1),
  "root");
 cdie(
  mps_root_create_table(&root6, arena, mps_rank_exact(), 0, (mps_addr_t*)&f, 1),
  "root");
 cdie(
  mps_root_create_table(&root7, arena, mps_rank_exact(), 0, (mps_addr_t*)&g, 1),
  "root");

 cdie(
  mps_root_create_table(&root, arena, mps_rank_exact(), 0, &exfmt_root, 1),
  "create exfmt root");

 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool");

 cdie(
  mps_ap_create(&apamc, poolamc, mps_rank_exact()),
  "create ap");

 comment("parking...");
 mps_arena_park(arena);
 
 b = allocone(apamc, 1, 1);

 for (j=1; j<10; j++) {
  comment("%i of 10.", j);
  a = allocone(apamc, 5, 1);
  cutoff_id = getid(a);
  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;
  }

  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;
  exfmt_root = c;
  mps_arena_collect(arena);
  comment(" reserved: %lu", (unsigned long) mps_arena_reserved(arena));
  comment("committed: %lu", (unsigned long) mps_arena_committed(arena));
  comment("calling amc_apply:");
  checkfrom(c);
  appcount = 0;
  apppadcount = 0;
  junk_size = 0;
  mps_amc_apply(poolamc, &test_apply, NULL, MAGICSIZE);
  comment("finished amc_apply");
  report("junksize", "%lu", (unsigned long) junk_size);
  report("appcount", "%ld", appcount);
  report("apppadcount", "%ld", apppadcount);
  RC;
 }

 mps_arena_release(arena);
 comment("released.");

 mps_arena_park(arena);
 mps_ap_destroy(apamc);
 mps_pool_destroy(poolamc);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);

 mps_root_destroy(root);
 mps_root_destroy(root1);
 mps_root_destroy(root2);
 mps_root_destroy(root3);
 mps_root_destroy(root4);
 mps_root_destroy(root5);
 mps_root_destroy(root6);
 mps_root_destroy(root7);
 comment("Destroyed roots.");

 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_ap_t ap;

 mycell *a, *b, *c, *d, *e, *f, *g;

 int i;
 int j;

 RC;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");
 die(mps_root_create_reg(&root, arena, MPS_RANK_AMBIG, 0, thread,
                         mps_stack_scan_ambig, stackpointer, 0),
     "create root");

 cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format");

 die(mps_pool_create(&pool, arena, mps_class_awl(), format),
     "create pool");

 cdie(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "create ap");

 for (j = 1; j < 100; j++) {
  comment("%i of 100.", j);
  UC;
  a = allocone(ap, 5, 1);
  b = a;
  c = a;
  d = a;
  e = a;
  f = a;
  g = a;

  for (i = 1; i < 100; i++) {
  UC;
   c = allocone(ap, 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;
   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;

 checkfrom(a);

 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 22
0
Archivo: 134.c Proyecto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 long int i;
 long int rsize = 0;

 int inramp;

 mycell *r = NULL, *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_thread(&root, arena, thread, stack_pointer), "thread 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");

 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());
#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());
#endif
    comment("ramp begin");
    r = allocone(apamc, 3, mps_rank_exact());
    inramp = 1;
    rsize = 0;
   }
  }
 }

 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.");
}
Ejemplo n.º 23
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc, poolawl;
 mps_thr_t thread;
 mps_root_t root, root1;

 mps_fmt_t format;
 mps_chain_t chain;
 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_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE),
      "create arena");

 die(mps_thread_reg(&thread, arena), "register thread");
 die(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_ambig(), 0, &exfmt_root, 1),
  "create exfmt root");

 die(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 cdie(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

 die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
     "create pool");

 cdie(
  mps_pool_create(&poolawl, arena, mps_class_awl(), format, getassociated),
  "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 = arena_committed_and_used(arena);
   mps_arena_collect(arena);
   size1 = arena_committed_and_used(arena);
   report("sizebefore0", "%lu", (unsigned long) size0);
   report("sizeafter0", "%lu", (unsigned long) size1);
   report("diff0", "%lu", (unsigned long) size0-size1);
   DC;
   mps_arena_release(arena);
   comment("...released");
  }
  DC;
  comment("clamping...");
  mps_arena_park(arena);
  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 = arena_committed_and_used(arena);
   mps_arena_collect(arena);
   size1 = arena_committed_and_used(arena);
   report("sizebefore1", "%lu", (unsigned long) size0);
   report("sizeafter1", "%lu", (unsigned long) size1);
   report("diff1", "%lu", (unsigned long) size0-size1);
   DC;
  }
  mps_arena_release(arena);
  comment("released.");
  RC;
 }

 mps_ap_destroy(apawl);
 mps_ap_destroy(apamc);
 mps_pool_destroy(poolamc);
 mps_pool_destroy(poolawl);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_root_destroy(root1);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Ejemplo n.º 24
0
static void test(void) {
 long int i;
 long int rsize;

 int inramp;

 mycell *r1, *r2, *s1, *s2;

 cdie(mps_arena_create(&arena1, mps_arena_class_vm(),
   (size_t) 1024*1024*ARENALIMIT), "create arena");
 cdie(mps_arena_create(&arena2, mps_arena_class_vm(),
   (size_t) 1024*1024*ARENALIMIT), "create arena");

 cdie(mps_thread_reg(&thread1, arena1), "register thread");
 cdie(mps_thread_reg(&thread2, arena2), "register thread");

 cdie(
  mps_root_create_reg(&root1, arena1, mps_rank_ambig(), 0, thread1,
   mps_stack_scan_ambig, stackpointer, 0),
  "create root");
 cdie(
  mps_root_create_reg(&root2, arena2, mps_rank_ambig(), 0, thread2,
   mps_stack_scan_ambig, stackpointer, 0),
  "create root");

 cdie(
  mps_root_create_table(&root1a, arena1, mps_rank_exact(), 0, &objtab1[0], TABSIZE),
  "create root table");
 cdie(
  mps_root_create_table(&root2a, arena2, mps_rank_exact(), 0, &objtab2[0], TABSIZE),
  "create root table");

 cdie(
  mps_fmt_create_A(&format1, arena1, &fmtA),
  "create format");
 cdie(
  mps_fmt_create_A(&format2, arena2, &fmtA),
  "create format");

 cdie(
  mps_pool_create(&poolamc1, arena1, mps_class_amc(), format1),
  "create pool");
 cdie(
  mps_pool_create(&poolamc2, arena2, mps_class_amc(), format2),
  "create pool");

 cdie(
  mps_ap_create(&apamc1, poolamc1, mps_rank_exact()),
  "create ap");
 cdie(
  mps_ap_create(&apamc2, poolamc2, mps_rank_exact()),
  "create ap");

 inramp = 0;

 for (i = 0; i < ITERATIONS; i++) {
  if (i % 10000 == 0) {
   comment("%ld of %ld", i, ITERATIONS);
  }
  alloc_back();
  if (inramp) {
   s1 = allocone(apamc1, 3, mps_rank_exact());
   s2 = allocone(apamc2, 3, mps_rank_exact());
   setref(r1, 0, s1);
   setref(r2, 0, s2);
   setref(s1, 1, r1);
   setref(s2, 1, r2);
   r1 = s1;
   r2 = s2;
   s1 = allocdumb(apamc1, RAMPSIZE, mps_rank_exact());
   s2 = allocdumb(apamc2, RAMPSIZE, mps_rank_exact());
   setref(r1, 2, s1);
   setref(r2, 2, s2);
   rsize ++;
   if (ranint(LEAVERAMP) == 0) {
    r1 = allocone(apamc1, 2, mps_rank_exact());
    r2 = allocone(apamc2, 2, mps_rank_exact());
    s1 = allocone(apamc1, 2, mps_rank_exact());
    s2 = allocone(apamc2, 2, mps_rank_exact());
#ifdef RAMP_INTERFACE
    mps_ap_alloc_pattern_end(apamc1, mps_alloc_pattern_ramp());
    mps_ap_alloc_pattern_end(apamc2, mps_alloc_pattern_ramp());
#endif
#ifdef COLLECT_WORLD
    mps_arena_collect(arena1);
    mps_arena_collect(arena2);
    mps_arena_release(arena1);
    mps_arena_release(arena2);
#endif
    comment("ramp end, %ld objects", rsize);
    inramp = 0;
   }
  } else {
   if (ranint(ENTERRAMP) == 0) {
#ifdef RAMP_INTERFACE
    mps_ap_alloc_pattern_begin(apamc1, mps_alloc_pattern_ramp());
    mps_ap_alloc_pattern_begin(apamc2, mps_alloc_pattern_ramp());
#endif
    comment("ramp begin");
    r1 = allocone(apamc1, 3, mps_rank_exact());
    r2 = allocone(apamc2, 3, mps_rank_exact());
    inramp = 1;
    rsize = 0;
   }
  }
 }

 mps_ap_destroy(apamc1);
 mps_ap_destroy(apamc2);
 comment("Destroyed ap.");

 mps_pool_destroy(poolamc1);
 mps_pool_destroy(poolamc2);
 comment("Destroyed pool.");

 mps_fmt_destroy(format1);
 mps_fmt_destroy(format2);
 comment("Destroyed format.");

 mps_root_destroy(root1);
 mps_root_destroy(root1a);
 mps_root_destroy(root2);
 mps_root_destroy(root2a);
 comment("Destroyed roots.");

 mps_thread_dereg(thread1);
 mps_thread_dereg(thread2);
 comment("Deregistered thread.");

 mps_arena_destroy(arena1);
 mps_arena_destroy(arena2);
 comment("Destroyed arena.");
}
Ejemplo n.º 25
0
static void test(void)
{
    mps_chain_t chain;
    long int i;
    long int rsize = 0;
    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");

    die(mmqa_pool_create_chain(&poolamc, arena, mps_class_amc(), format, chain),
        "create pool(amc)");

    cdie(
        mps_ap_create(&apamc, poolamc, mps_rank_exact()),
        "create ap");

    inramp = 0;
    r = NULL; /* r is always initialized, because inramp=0 at the start, but */
    /* the compiler doesn't know this. */

    for (i = 0; i < ITERATIONS; i++) {
        if (i % 10000 == 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());
#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());
#endif
                comment("ramp begin");
                r = allocone(apamc, 3, mps_rank_exact());
                inramp = 1;
                rsize = 0;
            }
        }
    }

    mps_arena_park(arena);
    mps_ap_destroy(apamc);
    mps_pool_destroy(poolamc);
    mps_chain_destroy(chain);
    mps_fmt_destroy(format);
    mps_root_destroy(root1);
    mps_root_destroy(root);
    mps_thread_dereg(thread);
    mps_arena_destroy(arena);
    comment("Destroyed arena.");
}