Ejemplo n.º 1
0
/* 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;
}
Ejemplo n.º 2
0
static void *test(void *arg, size_t s)
{
  mps_arena_t arena;
  mps_fmt_t format;
  mps_root_t exactRoot, ambigRoot;
  size_t lastStep = 0, i, r;
  unsigned long objs;
  mps_ap_t busy_ap;
  mps_addr_t busy_init;
  const char *indent = "    ";
  mps_chain_t chain;
  static mps_gen_param_s genParam = {1024, 0.2};

  arena = (mps_arena_t)arg;
  (void)s; /* unused */

  die(mps_fmt_create_A(&format, arena, dylan_fmt_A()), "fmt_create");
  die(mps_chain_create(&chain, arena, 1, &genParam), "chain_create");

  MPS_ARGS_BEGIN(args) {
    MPS_ARGS_ADD(args, MPS_KEY_FORMAT, format);
    MPS_ARGS_ADD(args, MPS_KEY_CHAIN, chain);
    MPS_ARGS_ADD(args, MPS_KEY_GEN, 0);
    die(mps_pool_create_k(&pool, arena, mps_class_amst(), args),
        "pool_create(amst)");
  } MPS_ARGS_END(args);

  die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
  die(mps_ap_create(&busy_ap, pool, mps_rank_exact()), "BufferCreate 2");

  for(i = 0; i < exactRootsCOUNT; ++i)
    exactRoots[i] = objNULL;
  for(i = 0; i < ambigRootsCOUNT; ++i)
    ambigRoots[i] = rnd_addr();

  die(mps_root_create_table_masked(&exactRoot, arena,
                                   mps_rank_exact(), (mps_rm_t)0,
                                   &exactRoots[0], exactRootsCOUNT,
                                   (mps_word_t)1),
      "root_create_table(exact)");
  die(mps_root_create_table(&ambigRoot, arena,
                            mps_rank_ambig(), (mps_rm_t)0,
                            &ambigRoots[0], ambigRootsCOUNT),
      "root_create_table(ambig)");

  puts(indent);

  /* create an ap, and leave it busy */
  die(mps_reserve(&busy_init, busy_ap, 64), "mps_reserve busy");

  objs = 0;
  while(totalSize < totalSizeMAX) {
    if (totalSize > lastStep + totalSizeSTEP) {
      lastStep = totalSize;
      printf("\nSize %"PRIuLONGEST" bytes, %"PRIuLONGEST" objects.\n",
             (ulongest_t)totalSize, (ulongest_t)objs);
      printf("%s", indent);
      (void)fflush(stdout);
      for(i = 0; i < exactRootsCOUNT; ++i)
        cdie(exactRoots[i] == objNULL || dylan_check(exactRoots[i]),
             "all roots check");
    }

    r = (size_t)rnd();
    if (r & 1) {
      i = (r >> 1) % exactRootsCOUNT;
      if (exactRoots[i] != objNULL)
        cdie(dylan_check(exactRoots[i]), "dying root check");
      exactRoots[i] = make();
      if (exactRoots[(exactRootsCOUNT-1) - i] != objNULL)
        dylan_write(exactRoots[(exactRootsCOUNT-1) - i],
                    exactRoots, exactRootsCOUNT);
    } else {
Ejemplo n.º 3
0
static void *test(void *arg, size_t s)
{
  unsigned i;                        /* index */
  mps_ap_t ap;
  mps_fmt_t fmt;
  mps_chain_t chain;
  mps_pool_t amc;
  mps_res_t e;
  mps_root_t mps_root[2];
  mps_addr_t nullref = NULL;
  int state[rootCOUNT];
  mps_arena_t arena;
  void *p = NULL;
  mps_message_t message;

  arena = (mps_arena_t)arg;
  (void)s;

  die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
  die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
  die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
      "pool_create amc\n");
  die(mps_root_create_table(&mps_root[0], arena, mps_rank_exact(), (mps_rm_t)0,
                            root, (size_t)rootCOUNT),
      "root_create\n");
  die(mps_root_create_table(&mps_root[1], arena, mps_rank_exact(), (mps_rm_t)0,
                            &p, (size_t)1),
      "root_create\n");
  die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n");

  /* Make registered-for-finalization objects. */
  /* <design/poolmrg/#test.promise.ut.alloc> */
  for(i = 0; i < rootCOUNT; ++i) {
    do {
      MPS_RESERVE_BLOCK(e, p, ap, vectorSIZE);
      die(e, "MPS_RES_OK");
      die(dylan_init(p, vectorSIZE, &nullref, 1), "dylan_init");
    } while (!mps_commit(ap, p, vectorSIZE));

    /* store index in vector's slot */
    ((mps_word_t *)p)[vectorSLOT] = dylan_int(i);

    die(mps_finalize(arena, &p), "finalize\n");
    root[i] = p; state[i] = rootSTATE;
  }
  p = NULL;

  mps_message_type_enable(arena, mps_message_type_finalization());

  /* <design/poolmrg/#test.promise.ut.churn> */
  while (mps_collections(arena) < collectionCOUNT) {
    
    /* Perhaps cause (minor) collection */
    churn(ap);
    
    /* Maybe make some objects ready-to-finalize */
    /* <design/poolmrg/#test.promise.ut.drop> */
    for (i = 0; i < rootCOUNT; ++i) {
      if (root[i] != NULL && state[i] == rootSTATE) {
        if (rnd() % finalizationRATE == 0) {
          /* for this object, either... */
          if (rnd() % 2 == 0) {
            /* ...definalize it, or */
            die(mps_definalize(arena, &root[i]), "definalize\n");
            state[i] = deadSTATE;
          } else {
            /* ...expect it to be finalized soon */
            state[i] = finalizableSTATE;
          }
          /* Drop the root reference to it; this makes it */
          /* non-E-reachable: so either dead, or ready-to-finalize. */
          root[i] = NULL;
        }
      }
    }

    /* Test any finalized objects, and perhaps resurrect some */
    while (mps_message_poll(arena)) {
      mps_word_t *obj;
      mps_word_t objind;
      mps_addr_t objaddr;

      /* <design/poolmrg/#test.promise.ut.message> */
      cdie(mps_message_get(&message, arena, mps_message_type_finalization()),
           "get");
      cdie(0 == mps_message_clock(arena, message),
           "message clock should be 0 (unset) for finalization messages");
      mps_message_finalization_ref(&objaddr, arena, message);
      obj = objaddr;
      objind = dylan_int_int(obj[vectorSLOT]);
      printf("Finalizing: object %lu at %p\n", objind, objaddr);
      /* <design/poolmrg/#test.promise.ut.final.check> */
      cdie(root[objind] == NULL, "finalized live");
      cdie(state[objind] == finalizableSTATE, "finalized dead");
      state[objind] = finalizedSTATE;
      /* sometimes resurrect */
      if (rnd() % 2 == 0)
        root[objind] = objaddr;
      mps_message_discard(arena, message);
    }
  }

  /* @@@@ <design/poolmrg/#test.promise.ut.nofinal.check> missing */

  mps_ap_destroy(ap);
  mps_root_destroy(mps_root[1]);
  mps_root_destroy(mps_root[0]);
  mps_pool_destroy(amc);
  mps_chain_destroy(chain);
  mps_fmt_destroy(fmt);

  return NULL;
}
Ejemplo n.º 4
0
static void *testscriptB(void *arg, size_t s)
{
  trampDataStruct trampData;
  mps_arena_t arena;
  mps_thr_t thr;
  const char *script;
  mps_fmt_t fmt;
  mps_chain_t chain;
  mps_pool_t amc;
  mps_root_t root_table;
  mps_ap_t ap;
  mps_root_t root_stackreg;
  size_t i;
  int N = myrootCOUNT - 1;
  void *stack_starts_here;  /* stack scanning starts here */

  Insist(s == sizeof(trampDataStruct));
  trampData = *(trampDataStruct*)arg;
  arena = trampData.arena;
  thr = trampData.thr;
  script = trampData.script;

  die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create");
  die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
  die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
      "pool_create amc");
  for(i = 0; i < myrootCOUNT; ++i) {
    myroot[i] = NULL;
  }
  die(mps_root_create_table(&root_table, arena, mps_rank_exact(), (mps_rm_t)0,
                            myroot, (size_t)myrootCOUNT),
      "root_create");
  die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create");
  
  /* root_stackreg: stack & registers are ambiguous roots = mutator's workspace */
  die(mps_root_create_reg(&root_stackreg, arena,
                          mps_rank_ambig(), (mps_rm_t)0, thr,
                          mps_stack_scan_ambig, &stack_starts_here, 0),
      "root_stackreg");

  /* Make myrootCOUNT registered-for-finalization objects. */
  /* Each is a dylan vector with 2 slots, inited to: (index, NULL) */
  for(i = 0; i < myrootCOUNT; ++i) {
    mps_word_t v;
    mps_addr_t v_ref;
    die(make_dylan_vector(&v, ap, 2), "make_dylan_vector");
    DYLAN_VECTOR_SLOT(v, 0) = DYLAN_INT(i);
    DYLAN_VECTOR_SLOT(v, 1) = (mps_word_t)NULL;
    v_ref = (mps_addr_t)v;
    die(mps_finalize(arena, &v_ref), "finalize");
    myroot[i] = (void*)v;
    state[i] = rootSTATE;
  }
  
  /* .keep-alive: Create some additional inter-object references.
   *
   * 1 and N-1 don't die until myroot refs to both have been nulled.
   *
   * 2 and 3 don't die until myroot refs to both have been nulled.
   *
   * We do this to check that reachability via non-root refs prevents 
   * finalization.
   */

  /* Leave 0 and N containing NULL refs */
  
  /* Make 1 and N-1 refer to each other */
  DYLAN_VECTOR_SLOT(myroot[1]  , 1) = (mps_word_t)myroot[N-1];
  DYLAN_VECTOR_SLOT(myroot[N-1], 1) = (mps_word_t)myroot[1];

  /* Make 2 and 3 refer to each other */
  DYLAN_VECTOR_SLOT(myroot[2], 1) = (mps_word_t)myroot[3];
  DYLAN_VECTOR_SLOT(myroot[3], 1) = (mps_word_t)myroot[2];

  /* Stop stack scanning, otherwise stack or register dross from */
  /* these setup functions can cause unwanted object retention, */
  /* which would mean we don't get the finalization messages we */
  /* expect. */
  mps_root_destroy(root_stackreg);

  mps_message_type_enable(arena, mps_message_type_gc_start());
  mps_message_type_enable(arena, mps_message_type_gc());
  mps_message_type_enable(arena, mps_message_type_finalization());

  testscriptC(arena, script);

  mps_ap_destroy(ap);
  mps_root_destroy(root_table);
  mps_pool_destroy(amc);
  mps_chain_destroy(chain);
  mps_fmt_destroy(fmt);

  return NULL;
}
static void *test(void *arg, size_t s)
{
  mps_arena_t arena;
  mps_fmt_t fmt;
  mps_chain_t chain;
  mps_pool_t amc;
  mps_root_t mps_root[2];
  mps_ap_t ap;
  mps_res_t e;
  int i;
  mps_addr_t nullref = NULL;
  void *p = NULL;
  int N = rootCOUNT - 1;

  arena = (mps_arena_t)arg;
  (void)s;

  die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
  die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
  die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
      "pool_create amc\n");
  die(mps_root_create_table(&mps_root[0], arena, MPS_RANK_EXACT, (mps_rm_t)0,
                            root, (size_t)rootCOUNT),
      "root_create\n");
  die(mps_root_create_table(&mps_root[1], arena, MPS_RANK_EXACT, (mps_rm_t)0,
                            &p, (size_t)1),
      "root_create\n");
  die(mps_ap_create(&ap, amc, MPS_RANK_EXACT), "ap_create\n");

  /* Make registered-for-finalization objects. */
  /* <design/poolmrg/#test.promise.ut.alloc> */
  for(i = 0; i < rootCOUNT; ++i) {
    do {
      MPS_RESERVE_BLOCK(e, p, ap, vectorSIZE(2));
      die(e, "MPS_RES_OK");
      die(dylan_init(p, vectorSIZE(2), &nullref, 1), "dylan_init");
    } while (!mps_commit(ap, p, vectorSIZE(2)));

    /* set vector's slots */
    ((mps_word_t *)p)[vectorSLOT(0)] = dylan_int(i);
    ((mps_word_t *)p)[vectorSLOT(1)] = (mps_word_t)NULL;

    die(mps_finalize(arena, &p), "finalize\n");
    root[i] = p; state[i] = rootSTATE;
  }
  p = NULL;

  mps_message_type_enable(arena, mps_message_type_finalization());

  mps_arena_collect(arena);
  report(arena, 0);

  /* make 0 and N finalizable */
  root[0] = NULL;
  state[0] = finalizableSTATE;
  root[N] = NULL;
  state[N] = finalizableSTATE;
  mps_arena_collect(arena);
  report(arena, 2);

  /* make 1 and N-1 refer to each other and finalizable */
  ((mps_word_t *)root[1])[vectorSLOT(1)] = (mps_word_t)root[N-1];
  ((mps_word_t *)root[N-1])[vectorSLOT(1)] = (mps_word_t)root[1];
  root[1] = NULL;
  state[1] = finalizableSTATE;
  root[N-1] = NULL;
  state[N-1] = finalizableSTATE;
  mps_arena_collect(arena);
  report(arena, 2);

  mps_arena_collect(arena);
  report(arena, 0);

  /* @@@@ <design/poolmrg/#test.promise.ut.nofinal.check> missing */

  mps_ap_destroy(ap);
  mps_root_destroy(mps_root[1]);
  mps_root_destroy(mps_root[0]);
  mps_pool_destroy(amc);
  mps_chain_destroy(chain);
  mps_fmt_destroy(fmt);

  return NULL;
}
static void *test(void *arg, size_t s)
{
  mps_arena_t arena;
  mps_fmt_t format;
  mps_chain_t chain;
  mps_root_t exactRoot, ambigRoot, singleRoot, fmtRoot;
  unsigned long i;
  /* Leave arena clamped until we have allocated this many objects.
     is 0 when arena has not been clamped. */
  unsigned long clamp_until = 0;
  size_t j;
  mps_word_t collections;
  mps_pool_t mv;
  mps_addr_t alloced_obj;
  size_t asize = 32;  /* size of alloced obj */
  mps_addr_t obj;
  mps_ld_s ld;
  mps_alloc_pattern_t ramp = mps_alloc_pattern_ramp();
  size_t rampCount = 0;
  mps_res_t res;

  arena = (mps_arena_t)arg;
  testlib_unused(s);

  die(dylan_fmt(&format, arena), "fmt_create");
  die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");

  die(mps_pool_create(&mv, arena, mps_class_mv(), 0x10000, 32, 0x10000),
      "pool_create(mv)");

  pool_create_v_test(arena, format, chain); /* creates amc pool */

  ap_create_v_test(amcpool);

  die(mps_ap_create(&ap, amcpool), "ap_create");

  for(j = 0; j < exactRootsCOUNT; ++j) {
    exactRoots[j] = objNULL;
  }
  for(j = 0; j < ambigRootsCOUNT; ++j) {
    ambigRoots[j] = (mps_addr_t)rnd();
  }

  die(mps_root_create_table_masked(&exactRoot, arena,
                                   MPS_RANK_EXACT, (mps_rm_t)0,
                                   &exactRoots[0], exactRootsCOUNT,
                                   (mps_word_t)1),
      "root_create_table(exact)");
  die(mps_root_create_table(&ambigRoot, arena,
                            MPS_RANK_AMBIG, (mps_rm_t)0,
                            &ambigRoots[0], ambigRootsCOUNT),
      "root_create_table(ambig)");

  obj = objNULL;

  die(mps_root_create(&singleRoot, arena,
                      MPS_RANK_EXACT, (mps_rm_t)0,
                      &root_single, &obj, 0),
      "root_create(single)");

  /* test non-inlined reserve/commit */
  obj = make_no_inline();

  die(mps_alloc(&alloced_obj, mv, asize), "mps_alloc");
  die(dylan_init(alloced_obj, asize, exactRoots, exactRootsCOUNT),
      "dylan_init(alloced_obj)");

  die(mps_root_create_fmt(&fmtRoot, arena,
                          MPS_RANK_EXACT, (mps_rm_t)0,
                          dylan_fmt_A()->scan,
                          alloced_obj,
                          (mps_addr_t)(((char*)alloced_obj)+asize)),
      "root_create_fmt");

  mps_ld_reset(&ld, arena);
  mps_ld_add(&ld, arena, obj);

  if (mps_ld_isstale(&ld, arena, obj)) {
    mps_ld_reset(&ld, arena);
    mps_ld_add(&ld, arena, obj);
  }

  collections = mps_collections(arena);

  for(i = 0; i < OBJECTS; ++i) {
    unsigned c;
    size_t r;

    c = mps_collections(arena);

    if(collections != c) {
      collections = c;
      printf("\nCollection %u, %lu objects.\n", c, i);
      for(r = 0; r < exactRootsCOUNT; ++r) {
        cdie(exactRoots[r] == objNULL || dylan_check(exactRoots[r]),
             "all roots check");
      }
      if(collections == 1) {
        mps_arena_clamp(arena);
        clamp_until = i + 10000;
      }
      if(collections % 6 == 0) {
        mps_arena_expose(arena);
        mps_arena_release(arena);
      }
      if(collections % 6 == 3) {
        mps_arena_unsafe_expose_remember_protection(arena);
        mps_arena_unsafe_restore_protection(arena);
        mps_arena_release(arena);
      }
      if(collections % 6 == 4) {
        mps_arena_unsafe_expose_remember_protection(arena);
        mps_arena_release(arena);
      }
      if(collections % 3 == 2) {
        mps_arena_park(arena);
        mps_arena_release(arena);
      }
    }

    if(clamp_until && i >= clamp_until) {
      mps_arena_release(arena);
      clamp_until = 0;
    }

    if (rnd() % patternFREQ == 0) {
      switch(rnd() % 4) {
      case 0: case 1:
        die(mps_ap_alloc_pattern_begin(ap, ramp), "alloc_pattern_begin");
        ++rampCount;
        break;
      case 2:
        res = mps_ap_alloc_pattern_end(ap, ramp);
        cdie(rampCount > 0 ? res == MPS_RES_OK : res == MPS_RES_FAIL,
             "alloc_pattern_end");
        if (rampCount > 0) {
	  --rampCount;
	}
        break;
      case 3:
        die(mps_ap_alloc_pattern_reset(ap), "alloc_pattern_reset");
        rampCount = 0;
        break;
      }
    }

    if (rnd() & 1) {
      exactRoots[rnd() % exactRootsCOUNT] = make();
    } else {
      ambigRoots[rnd() % ambigRootsCOUNT] = make();
    }

    r = rnd() % exactRootsCOUNT;
    if (exactRoots[r] != objNULL)  {
      cdie(dylan_check(exactRoots[r]), "random root check");
    }
  }

  arena_commit_test(arena);
  reservoir_test(arena);
  alignmentTest(arena);

  die(mps_arena_collect(arena), "collect");

  mps_free(mv, alloced_obj, 32);
  alloc_v_test(mv);
  mps_pool_destroy(mv);
  mps_ap_destroy(ap);
  mps_root_destroy(fmtRoot);
  mps_root_destroy(singleRoot);
  mps_root_destroy(exactRoot);
  mps_root_destroy(ambigRoot);
  mps_pool_destroy(amcpool);
  mps_chain_destroy(chain);
  mps_fmt_destroy(format);

  return NULL;
}
Ejemplo n.º 7
0
static void *test(void *arg, size_t s)
{
  mps_ap_t ap;
  mps_fmt_t fmt;
  mps_chain_t chain;
  mps_word_t finals;
  mps_pool_t amc;
  mps_root_t mps_root;
  mps_arena_t arena;
  mps_message_t message;
  size_t i;

  arena = (mps_arena_t)arg;
  (void)s;

  die(mps_fmt_create_A(&fmt, arena, dylan_fmt_A()), "fmt_create\n");
  die(mps_chain_create(&chain, arena, genCOUNT, testChain), "chain_create");
  die(mps_pool_create(&amc, arena, mps_class_amc(), fmt, chain),
      "pool_create amc\n");
  die(mps_root_create_table(&mps_root, arena, mps_rank_exact(), (mps_rm_t)0,
                            root, (size_t)rootCOUNT),
      "root_create\n");
  die(mps_ap_create(&ap, amc, mps_rank_exact()), "ap_create\n");

  mps_message_type_enable(arena, mps_message_type_finalization());

  mps_arena_park(arena);

  object_count = 0;

  printf("Making some finalized trees of objects.\n");
  /* make some trees */
  for(i = 0; i < rootCOUNT; ++i) {
          root[i] = (void *)make_numbered_tree(maxtreeDEPTH, ap);
          register_numbered_tree((mps_word_t)root[i], arena);
  }

  mps_arena_unsafe_expose_remember_protection(arena);
  mps_arena_unsafe_restore_protection(arena);

  printf("Losing all pointers to the trees.\n");
  /* clean out the roots */
  for(i = 0; i < rootCOUNT; ++i) {
          root[i] = 0;
  }

  finals = 0;

  while ((finals < object_count) &&
         (mps_collections(arena) < collectionCOUNT)) {
          mps_word_t final_this_time = 0;
          printf("Collecting...");
          (void)fflush(stdout);
          die(mps_arena_collect(arena), "collect");
          printf(" Done.\n");
          while (mps_message_poll(arena)) {
                  mps_word_t obj;
                  mps_addr_t objaddr;
                  cdie(mps_message_get(&message, arena,
                                       mps_message_type_finalization()),
                       "get");
                  mps_message_finalization_ref(&objaddr, arena, message);
                  obj = (mps_word_t)objaddr;
                  mps_message_discard(arena, message);
                  ++ final_this_time;
                  testlib_unused(obj);
          }
          finals += final_this_time;
          printf("%"PRIuLONGEST" objects finalized: total %"PRIuLONGEST
                 " of %"PRIuLONGEST"\n",
                 (ulongest_t)final_this_time, (ulongest_t)finals,
                 (ulongest_t)object_count);
  }

  object_count = 0;

  printf("Making some indirectly finalized trees of objects.\n");
  /* make some trees */
  for(i = 0; i < rootCOUNT; ++i) {
          root[i] = (void *)make_indirect_tree(maxtreeDEPTH, ap);
          register_indirect_tree((mps_word_t)root[i], arena);
  }

  printf("Losing all pointers to the trees.\n");
  /* clean out the roots */
  for(i = 0; i < rootCOUNT; ++i) {
          root[i] = 0;
  }

  finals = 0;

  while ((finals < object_count) &&
         (mps_collections(arena) < collectionCOUNT)) {
          mps_word_t final_this_time = 0;
          printf("Collecting...");
          (void)fflush(stdout);
          die(mps_arena_collect(arena), "collect");
          printf(" Done.\n");
          while (mps_message_poll(arena)) {
                  mps_word_t obj;
                  mps_addr_t objaddr;
                  cdie(mps_message_get(&message, arena,
                                       mps_message_type_finalization()),
                       "get");
                  mps_message_finalization_ref(&objaddr, arena, message);
                  obj = (mps_word_t)objaddr;
                  mps_message_discard(arena, message);
                  ++ final_this_time;
                  testlib_unused(obj);
          }
          finals += final_this_time;
          printf("%"PRIuLONGEST" objects finalized: total %"PRIuLONGEST
                 " of %"PRIuLONGEST"\n",
                 (ulongest_t)final_this_time, (ulongest_t)finals,
                 (ulongest_t)object_count);
  }

  mps_ap_destroy(ap);
  mps_root_destroy(mps_root);
  mps_pool_destroy(amc);
  mps_chain_destroy(chain);
  mps_fmt_destroy(fmt);

  return NULL;
}
Ejemplo n.º 8
0
mps_res_t EnsureHeaderWeakFormat(mps_fmt_t *mps_fmt_o, mps_arena_t arena)
{
    dylan_format = dylan_fmt_A();
    return mps_fmt_create_auto_header(mps_fmt_o, arena, &HeaderWeakFormat);
}