Esempio n. 1
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_fmt_t format;
 mps_ap_t ap;

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

 cdie(mps_fmt_create_k(&format, arena, mps_args_none), "create format");

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

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

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

 mps_ap_destroy(ap);
 comment("Destroyed ap again.");

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

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

 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
/* v serves two purposes:
 * A pseudo stack base for the stack root.
 * Pointer to a guff structure, which packages some values needed
 * (arena and thr mostly) */
static void *setup(void *v, size_t s)
{
  struct guff_s *guff;
  mps_arena_t arena;
  mps_pool_t leafpool;
  mps_pool_t tablepool;
  mps_fmt_t dylanfmt;
  mps_fmt_t dylanweakfmt;
  mps_ap_t leafap, exactap, weakap, bogusap;
  mps_root_t stack;
  mps_thr_t thr;

  guff = (struct guff_s *)v;
  (void)s;
  arena = guff->arena;
  thr = guff->thr;

  die(mps_root_create_reg(&stack, arena, MPS_RANK_AMBIG, 0, thr,
                          mps_stack_scan_ambig, v, 0),
      "Root Create\n");
  die(mps_fmt_create_A(&dylanfmt, arena, dylan_fmt_A()),
      "Format Create\n");
  die(mps_fmt_create_A(&dylanweakfmt, arena, dylan_fmt_A_weak()),
      "Format Create (weak)\n");
  die(mps_pool_create(&leafpool, arena, mps_class_lo(), dylanfmt),
      "Leaf Pool Create\n");
  die(mps_pool_create(&tablepool, arena, mps_class_awl(), dylanweakfmt,
                      dylan_weak_dependent),
      "Table Pool Create\n");
  die(mps_ap_create(&leafap, leafpool, MPS_RANK_EXACT),
      "Leaf AP Create\n");
  die(mps_ap_create(&exactap, tablepool, MPS_RANK_EXACT),
      "Exact AP Create\n");
  die(mps_ap_create(&weakap, tablepool, MPS_RANK_WEAK),
      "Weak AP Create\n");
  die(mps_ap_create(&bogusap, tablepool, MPS_RANK_EXACT),
      "Bogus AP Create\n");

  test(leafap, exactap, weakap, bogusap);

  mps_ap_destroy(bogusap);
  mps_ap_destroy(weakap);
  mps_ap_destroy(exactap);
  mps_ap_destroy(leafap);
  mps_pool_destroy(tablepool);
  mps_pool_destroy(leafpool);
  mps_fmt_destroy(dylanweakfmt);
  mps_fmt_destroy(dylanfmt);
  mps_root_destroy(stack);

  return NULL;
}
static void test (void) {
 mps_thr_t thread;
 mps_pool_t pool;
 mps_ap_t ap;
 int i;

 cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*100)), "create arena");
 cdie(mps_thread_reg(&thread, arena), "register thread");
 die(
  mps_pool_create(&pool, arena, mps_class_mv2(),
                  OBJSIZE, OBJSIZE, OBJSIZE, DEPTH, FRAGLIMIT),
  "create MV2 pool");

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

 for (i = 0; i < OBJECTS; i++) {
  die(mv2_alloc(&objs[i], ap, OBJSIZE), "alloc");
 }
 report("size1", "%ld", mps_arena_committed(arena));

 for (i = 0; i < OBJECTS; i+=2) {
  mps_free(pool, objs[i], OBJSIZE);
  die(mv2_alloc(&objs[i], ap, OBJSIZE), "alloc");
 }
 report("size2", "%ld", mps_arena_committed(arena));
 
 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
}
Esempio n. 4
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t poolamc1;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t ap1;

 mycell *a, *b;

 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(&poolamc1, arena, mps_class_amc(), format, chain),
     "create pool(1)");

 cdie(
  mps_ap_create(&ap1, poolamc1, mps_rank_exact()),
  "create ap");

 for (j = 1; j < 100; j++) {
  comment("%i of 100.", j);

  for (i = 1; i < 10000; i++) {
   UC;
   a = allocone(ap1, 2, 1);
   b = allocone(ap1, 2, 1);
   setref(a, 0, b);
   setref(b, 0, a);
   UC;
  }
  DC;
  DMC;
 }

 mps_ap_destroy(ap1);
 mps_pool_destroy(poolamc1);
 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 poolamc;
 mps_thr_t thread;
 mps_root_t root0, root1;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t apamc;

 mycell *a;

 long int j;

 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_reg(&root0, 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,
                            (mps_addr_t *)&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");

 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");

 /* alloc lots in an AMC pool; it should be collected away */

 for(j=0; j<1000; j++) {
  a = allocdumb(apamc, 1024ul*1024, MPS_RANK_EXACT);
 }

 /* (total allocated is 1000 M) */

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

 mps_ap_destroy(apamc);
 mps_pool_destroy(poolamc);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");

 pass();
}
static void test(void)
{
 mps_space_t space;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_ap_t ap;
 mps_addr_t p;
 mps_addr_t q;

 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");

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

 do
 {
  cdie(mps_reserve(&p, ap, 0x100), "Reserve: ");
  q = (mps_addr_t) ((char *)p);
 }
 while (!mps_commit(ap, q, 0x110));
 comment("Committed.");

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

 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.");
}
Esempio n. 7
0
static void test(void)
{
 int i = 0;
 mps_ap_t sap;
 mps_arena_t arena;
 mps_fmt_t format;
 mps_pool_t spool;
 mps_thr_t thread;
 mps_frame_t frame;
 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, alloc 1MB object, and pop to first stack frame.
   This shouldn't use much more than 1MB of memory.
*/

 for (i=0; i < ITERATIONS; i++) {
  die(mps_ap_frame_push(&frame, sap), "push");
  p = allocdumb(sap, OBJSIZE, mps_rank_exact());
  die(mps_ap_frame_pop(sap, frame), "pop");
  comment("%i of %i", i, ITERATIONS);
 }

 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.");

}
Esempio n. 8
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;
 mps_ap_t ap;

 mps_addr_t p;

 int i;

 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");

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

 for(i=1; i<1000; i++)
 {
  do
  { die(mps_reserve(&p, ap, OBJSIZE), "Reserve: ");
  }
  while (!mps_commit(ap, p, OBJSIZE));
  comment("%i at %p", i, p);
  comment("%i objects of 10 megabytes each allocated", i);
 }

 mps_arena_park(arena);
 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_fmt_destroy(format);
 mps_chain_destroy(chain);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);

}
Esempio n. 9
0
int main(void)
{
  mps_arena_t arena;
  mps_pool_t pool;
  mps_fmt_t format;
  mps_ap_t ap;
  mps_addr_t p;
  mps_root_t root;

  locv_fmt.align = sizeof(void *);  /* .fmt.align.delayed */

  die(mps_arena_create(&arena, mps_arena_class_vm(), testArenaSIZE),
      "mps_arena_create");
  die(mps_root_create_table(&root, arena, mps_rank_exact(),
                            (mps_rm_t)0,
                            roots, (sizeof(roots)/sizeof(*roots))),
      "RootCreate");

  die(mps_fmt_create_A(&format, arena, &locv_fmt), "FormatCreate");

  die(mps_pool_create(&pool, arena, mps_class_lo(), format), "LOCreate");

  die(mps_ap_create(&ap, pool, mps_rank_exact()), "APCreate");

  die(mps_reserve(&p, ap, sizeof(void *)), "mps_reserve min");
  *(mps_word_t *)p = sizeof(void *);
  cdie(mps_commit(ap, p, sizeof(void *)), "commit min");
  
  die(mps_reserve(&roots[1], ap, 2*sizeof(void *)), "mps_reserve 2*min");
  p = roots[1];
  *(mps_word_t *)p = 2*sizeof(void *);
  cdie(mps_commit(ap, p, 2*sizeof(void *)), "commit 2*min");
  
  die(mps_reserve(&p, ap, (size_t)4096), "mps_reserve 4096");
  *(mps_word_t *)p = 4096;
  cdie(mps_commit(ap, p, (size_t)4096), "commit 4096");
  
  die(mps_reserve(&p, ap, sizeof(void *)), "mps_reserve last");
  *(mps_word_t *)p = sizeof(void *);
  cdie(mps_commit(ap, p, sizeof(void *)), "commit last");

  {
    size_t count = 0;
    mps_arena_formatted_objects_walk(arena, stepper, &count, 0);
    cdie(count == 4, "walk 4 objects");
  }
  
  mps_ap_destroy(ap);
  mps_pool_destroy(pool);
  mps_fmt_destroy(format);
  mps_root_destroy(root);
  mps_arena_destroy(arena);

  fflush(stdout); /* synchronize */
  fprintf(stderr, "\nConclusion:  Failed to find any defects.\n");
  return 0;
}
Esempio n. 10
0
File: 36.c Progetto: 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_chain_t chain;
 mps_fmt_t format;
 mps_ap_t ap;

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

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

 cdie(mps_root_create_thread(&root, arena, thread, stack_pointer), "thread 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");

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

{
 mps_addr_t p;

 cdie(mps_reserve(&p, ap, 0x100), "Reserve: ");
}

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

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

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

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

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

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

 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
static void ap_create_v_test(mps_pool_t pool, ...)
{
  mps_ap_t apt;
  va_list args;

  va_start(args, pool);
  die(mps_ap_create_v(&apt, pool, args), "ap_create_v");
  va_end(args);
  mps_ap_destroy(apt);
}
Esempio n. 12
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;

 locell *a,*b,*c,*z;
 int i;

 alloclocomments = 0;
 allowlocopies = 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");

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

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

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

 a = string_ch("Hello there");
 b = string_ch("Wibble wobble foo");
 c = string_ch("Ba ");

 for (i=0; i<10000; i++) {
  a = conc(string_ch("B"), a);
  c = conc(string_ch("Hello there"), string_ch(" folks!"));
  z = alloclo(ap, 0x4000);
 }

 mps_arena_park(arena);
 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.");
}
Esempio n. 13
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;

 int h;
 mycell *p, *q, *r;

 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");

 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");

 r = allocone(ap, 1000);

 for (h = 0; h < 10000; h++) {
  if (h % 10 == 0) {
   report("iter", "%i", h);
  }
  q = allocone(ap, 1000);
  p = allocone(ap, 1000);
  setref(p, 1, q);
  r = allocone(ap, 1000);
  setref(q, 50, r);
  setref(r, 1, p);

 }

 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.");
}
Esempio n. 14
0
File: 112.c Progetto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 mps_pool_t poollo;
 mps_thr_t thread;
 mps_root_t root0, root1;

 mps_fmt_t format;
 mps_chain_t chain;
 mps_ap_t aplo;

 long int j;

 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_thread(&root0, arena, thread, stack_pointer), "thread root"); 
 cdie(mps_root_create_table(&root1, arena, mps_rank_ambig(), 0,
                            (mps_addr_t*)&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");

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

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

 /* alloc lots in an LO pool; it should be collected away */

 for(j=0; j<1000; j++) {
  (void)allocdumb(aplo, 1024ul*1024, mps_rank_exact());
 }

 /* (total allocated is 1000 M) */

 mps_arena_park(arena);
 mps_root_destroy(root0);
 mps_root_destroy(root1);
 comment("Destroyed roots.");

 mps_ap_destroy(aplo);
 mps_pool_destroy(poollo);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");

 pass();
}
Esempio n. 15
0
File: 138.c Progetto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 int j;
 mps_ap_t ap;
 mps_arena_t arena;
 mps_fmt_t format;
 mps_chain_t chain;
 mps_pool_t pool;
 mps_root_t root1;
 mps_thr_t thread;

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

 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_root_create_table(&root1, arena, mps_rank_exact(), 0,
                            (mps_addr_t*)&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");

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

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

 /* allocate a 16 MB live object */

 allocdumb(ap, 16*MEG, mps_rank_exact());

 comment("collect world...");

 for (j=0; j<1000; j++) {
  mps_arena_collect(arena);
 }

 mps_arena_park(arena);
 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root1);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Esempio n. 16
0
File: airtest.c Progetto: bhanug/mps
static void test_main(void *marker, int interior, int stack)
{
  mps_res_t res;
  mps_chain_t obj_chain;
  mps_fmt_t obj_fmt;
  mps_thr_t thread;
  mps_root_t reg_root = NULL;

  res = mps_arena_create_k(&scheme_arena, mps_arena_class_vm(), mps_args_none);
  if (res != MPS_RES_OK)
    error("Couldn't create arena");

  res = mps_chain_create(&obj_chain, scheme_arena,
                         sizeof(obj_gen_params) / sizeof(*obj_gen_params),
                         obj_gen_params);
  if (res != MPS_RES_OK)
    error("Couldn't create obj chain");

  scheme_fmt(&obj_fmt);

  MPS_ARGS_BEGIN(args) {
    MPS_ARGS_ADD(args, MPS_KEY_CHAIN, obj_chain);
    MPS_ARGS_ADD(args, MPS_KEY_FORMAT, obj_fmt);
    MPS_ARGS_ADD(args, MPS_KEY_INTERIOR, interior);
    die(mps_pool_create_k(&obj_pool, scheme_arena, mps_class_amc(), args),
        "mps_pool_create_k");
  } MPS_ARGS_END(args);

  res = mps_ap_create_k(&obj_ap, obj_pool, mps_args_none);
  if (res != MPS_RES_OK)
    error("Couldn't create obj allocation point");

  res = mps_thread_reg(&thread, scheme_arena);
  if (res != MPS_RES_OK)
    error("Couldn't register thread");

  if (stack) {
    res = mps_root_create_thread(&reg_root, scheme_arena, thread, marker);
    if (res != MPS_RES_OK)
      error("Couldn't create root");
  }
  
  test_air(interior, stack);

  mps_arena_park(scheme_arena);
  if (stack)
    mps_root_destroy(reg_root);
  mps_thread_dereg(thread);
  mps_ap_destroy(obj_ap);
  mps_pool_destroy(obj_pool);
  mps_chain_destroy(obj_chain);
  mps_fmt_destroy(obj_fmt);
  mps_arena_destroy(scheme_arena);
}
static void test(void)
{
 mps_space_t space;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_fmt_t format;
 mps_ap_t ap;

 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");

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

 allocone(ap, 0, NULL, NULL, 0x100);

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

 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.");
}
Esempio n. 18
0
/* start -- start routine for each thread */
static void *start(void *p)
{
  gcthread_t thread = p;
  void *marker;
  RESMUST(mps_thread_reg(&thread->mps_thread, arena));
  RESMUST(mps_root_create_thread(&thread->reg_root, arena,
                                 thread->mps_thread, &marker));
  RESMUST(mps_ap_create_k(&thread->ap, pool, mps_args_none));
  thread->fn(thread);
  mps_ap_destroy(thread->ap);
  mps_root_destroy(thread->reg_root);
  mps_thread_dereg(thread->mps_thread);
  return NULL;
}
Esempio n. 19
0
/* start -- start routine for each thread */
static void *start(void *p) {
  gcthread_t thread = p;
  void *marker;
  RESMUST(mps_thread_reg(&thread->mps_thread, arena));
  RESMUST(mps_root_create_reg(&thread->reg_root, arena, 
                              mps_rank_ambig(), (mps_rm_t)0,
                              thread->mps_thread, &mps_stack_scan_ambig,
                              &marker, (size_t)0));
  RESMUST(mps_ap_create_k(&thread->ap, pool, mps_args_none));
  thread->fn(thread);
  mps_ap_destroy(thread->ap);
  mps_root_destroy(thread->reg_root);
  mps_thread_dereg(thread->mps_thread);
  return NULL;
}
Esempio n. 20
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;

 mps_fmt_t format;
 mps_fmt_A_s fmtA;
 mps_ap_t ap;

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

 fmtA.align = (mps_align_t) 1;
 fmtA.scan  = &zilch;
 fmtA.skip  = &myskip;
 fmtA.copy  = &zilch;
 fmtA.fwd   = &zilch;
 fmtA.isfwd = &zilch;
 fmtA.pad   = &zilch;

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

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

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

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

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

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

 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_chain_t chain;
 mps_ap_t ap;

 mycell *a;

 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(mmqa_pool_create_chain(&pool, arena, mps_class_amc(), format, chain),
      "create pool");

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

  a = allocdumb(ap, 1024*1024*80);

 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);
}
Esempio n. 22
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;

 mps_ap_t ap;
 mps_fmt_t format;
 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_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(mmqa_pool_create_chain(&pool, arena, mps_class_amc(), format, chain),
      "create pool");

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

 while (mps_collections(arena) == 0) {
  allocdumb(ap, 1024*256);
 }

 mps_ap_destroy(ap);

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

 mps_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
}
Esempio n. 23
0
File: 66.c Progetto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 void *marker = &marker;
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;
 mps_root_t root;
 mps_fmt_t format;
 mps_ap_t ap;
 mps_addr_t p, q, unaligned;

 cdie(mps_arena_create_k(&arena, mps_arena_class_vm(), mps_args_none), "create arena");
 mps_arena_park(arena);
 cdie(mps_thread_reg(&thread, arena), "register thread");
 cdie(mps_root_create_thread(&root, arena, thread, marker), "create root");
 cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format");
 MPS_ARGS_BEGIN(args) {
   MPS_ARGS_ADD(args, MPS_KEY_FORMAT, format);
   cdie(mps_pool_create_k(&pool, arena, mps_class_ams(), args), "pool");
 } MPS_ARGS_END(args);
 cdie(mps_ap_create(&ap, pool, mps_rank_exact()), "ap");

 /* p is in the AMS pool */
 p = allocone(ap, 0, NULL, NULL, sizeof(mycell));

 /* q is in the AMS pool with unaligned exact reference to p */
 unaligned = (void *)((char*)p + 1);
 q = allocone(ap, 1, p, unaligned, sizeof(mycell));

 mps_arena_start_collect(arena);
 mps_arena_park(arena);

 /* Keep q (and thus p) alive during the collection. */
 report("q", "%p", q);

 mps_ap_destroy(ap);
 mps_pool_destroy(pool);
 mps_fmt_destroy(format);
 mps_root_destroy(root);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
}
Esempio n. 24
0
static void test(void)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_fmt_t format;
 mps_ap_t ap;
 mps_addr_t p;

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

 cdie(mps_fmt_create_k(&format, arena, mps_args_none), "create format");

 MPS_ARGS_BEGIN(args) {
   MPS_ARGS_ADD(args, MPS_KEY_FORMAT, format);
   cdie(mps_pool_create_k(&pool, arena, mps_class_ams(), args),
        "create pool");
 } MPS_ARGS_END(args);

 MPS_ARGS_BEGIN(args) {
   MPS_ARGS_ADD(args, MPS_KEY_RANK, mps_rank_weak());
   cdie(mps_ap_create_k(&ap, pool, args), "create ap");
 } MPS_ARGS_END(args);

 do {
  cdie(mps_reserve(&p, ap, 0x100), "Reserve: ");
 } while (!mps_commit(ap, p, 0x100));
 comment("Committed.");

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

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

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

 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Esempio n. 25
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;
 mps_ap_t ap;

 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");

 formatcomments = 0;

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

 ddie(
  mps_pool_create(&pool, arena, mps_class_amc(), format, chain),
  "create pool");

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

 mps_ap_destroy(UNALIGNED);

}
Esempio n. 26
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.");
}
Esempio n. 27
0
static void test(void) {
 mps_pool_t poollo;
 mps_thr_t thread;
 mps_root_t root0, root1;

 mps_fmt_t format;
 mps_ap_t aplo;

 mycell *a;

 long int j;

 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_reg(&root0, 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,
                            (mps_addr_t *)&exfmt_root, 1),
      "create table root");

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

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

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

 /* alloc lots in an LO pool; it should be collected away */

 for(j=0; j<1000; j++) {
  a = allocdumb(aplo, 1024ul*1024, mps_rank_exact());
 }

 /* (total allocated is 1000 M) */

 mps_arena_park(arena);
 mps_root_destroy(root0);
 mps_root_destroy(root1);
 comment("Destroyed roots.");

 mps_ap_destroy(aplo);
 comment("Destroyed ap.");

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

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

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

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

 pass();
}
static void test(void)
{
 mps_pool_t poolamc, poolawl, poollo;
 mps_thr_t thread;
 mps_root_t root0, root1;

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

 mycell *a, *b, *c, *d;

 long int j;

 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_reg(&root0, 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,
                            (mps_addr_t*)&exfmt_root, 1),
      "create table root");

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

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

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

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

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

 mps_message_type_enable(arena, 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(arena, (mps_addr_t*)&a);
  mps_finalize(arena, (mps_addr_t*)&c);
  mps_finalize(arena, (mps_addr_t*)&d);
  mps_finalize(arena, (mps_addr_t*)&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(arena);

 while(mps_message_poll(arena) == 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(arena);
 }

 /* how many are left? (n.b. ideally this would be 0 but
    there's no guarantee)
    */

 /* 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_chain_destroy(chain);
 mps_fmt_destroy(format);
 mps_thread_dereg(thread);
 mps_arena_destroy(arena);
 comment("Destroyed arena.");
}
Esempio n. 29
0
static void test(void) {

    mycell *p, *q;
    int i;
    mps_res_t res;
    size_t lim0, avail0, lim1, avail1, commit1, lim2, avail2, commit2;
    size_t lim3, avail3, commit3, lim4, avail4, commit4;
    size_t lim5, avail5, commit5, lim6, avail6, commit6;

    cdie(mps_arena_create(&arena, mps_arena_class_vm(), ARENA_SIZE),
         "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 stack root");

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

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

    cdie(
        mps_ap_create(&apsnc, poolsnc, mps_rank_exact()),
        "create ap");

    report("lim0", "%d", lim0 = mps_reservoir_limit(arena));
    report("avail0",  "%d", avail0 = mps_reservoir_available(arena));
    mps_reservoir_limit_set(arena, (size_t) 0);

    mps_reservoir_limit_set(arena, (size_t) (5ul*1024*1024));
    report("lim1", "%d", lim1 = mps_reservoir_limit(arena));
    report("avail1",  "%d", avail1 = mps_reservoir_available(arena));
    report("commit1", "%d", commit1 = arena_committed_and_used(arena));
    report("defecit1", "%d", lim1-avail1);

    mps_reservoir_limit_set(arena, (size_t) (1045));
    report("lim2", "%d", lim2 = mps_reservoir_limit(arena));
    report("avail2",  "%d", avail2 = mps_reservoir_available(arena));
    report("commit2", "%d", commit2 = arena_committed_and_used(arena));
    report("defecit2", "%d", lim2-avail2);

    /* set commit limit to whatever is currently committed plus 1 MB
    */

    die(mps_arena_commit_limit_set(arena, arena_committed_and_used(arena)+1024*1024), "commit limit set");
    mps_reservoir_limit_set(arena, (size_t) (10ul*1024*1024));
    report("lim3", "%d", lim3 = mps_reservoir_limit(arena));
    report("avail3",  "%d", avail3 = mps_reservoir_available(arena));
    report("commit3", "%d", commit3 = arena_committed_and_used(arena));
    report("defecit3", "%d", lim3-avail3);
    report("spill3", "%d", commit3-mps_arena_commit_limit(arena));

    /* now raise it by 1/2 MB -- reservoir should grow
    */

    die(mps_arena_commit_limit_set(arena, arena_committed_and_used(arena)+512*1024), "commit limit set");
    report("lim4", "%d", lim4 = mps_reservoir_limit(arena));
    report("avail4",  "%d", avail4 = mps_reservoir_available(arena));
    report("commit4", "%d", commit4 = arena_committed_and_used(arena));
    report("grow4", "%d", avail4-avail3);
    report("spill4", "%d", commit4-mps_arena_commit_limit(arena));

    /* try some allocation -- more than a small amount should fail
    */

    i = -1;
    p = NULL;
    res = MPS_RES_OK;
    while (res == MPS_RES_OK) {
        res = allocrone(&q, apsnc, 10, mps_rank_exact());
        if (res == MPS_RES_OK) {
            setref(q, 0, p);
            p = q;
        }
        i++;
    }
    report("allocfail", "%d", i);
    report_res("failres", res);

    /* available shouldn't have changed since before allocation
    */

    report("lim5", "%d", lim5 = mps_reservoir_limit(arena));
    report("avail5",  "%d", avail5 = mps_reservoir_available(arena));
    report("commit5", "%d", commit5 = arena_committed_and_used(arena));
    report("grow5", "%d", avail5-avail4);
    report("spill5", "%d", commit5-mps_arena_commit_limit(arena));

    /* try some allocation from reservoir -- not much should fail
    */

    i = -1;
    res = MPS_RES_OK;
    while (res == MPS_RES_OK) {
        res = reservoir_allocrone(&q, apsnc, 10, mps_rank_exact());
        if (res == MPS_RES_OK) {
            setref(q, 0, p);
            p = q;
        }
        i++;
    }
    report("allocfail2", "%d", i);
    report_res("failres2", res);

    /* available should have changed now
    */

    report("lim6", "%d", lim6 = mps_reservoir_limit(arena));
    report("avail6",  "%d", avail6 = mps_reservoir_available(arena));
    report("commit6", "%d", commit6 = arena_committed_and_used(arena));
    report("spill6", "%d", commit6-mps_arena_commit_limit(arena));
    report("shrink6", "%d", avail5-avail6);

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

    mps_ap_destroy(apsnc);
    comment("Destroyed ap.");

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

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

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

    mps_arena_destroy(arena);
    comment("Destroyed arena.");
}
Esempio n. 30
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.");
}