Beispiel #1
0
static void test_stepper(mps_addr_t object, mps_fmt_t fmt, mps_pool_t pool,
                         void *p, size_t s)
{
  testlib_unused(object); testlib_unused(fmt); testlib_unused(pool);
  testlib_unused(s);
  (*(unsigned long *)p)++;
}
Beispiel #2
0
static mps_res_t fmtScan(mps_ss_t ss, mps_addr_t base, mps_addr_t limit)
{
  testlib_unused(ss);
  testlib_unused(base);
  testlib_unused(limit);
  return MPS_RES_OK;
}
Beispiel #3
0
static mps_res_t scan(mps_ss_t ss, mps_addr_t base, mps_addr_t limit)
{
  testlib_unused(ss);
  testlib_unused(base);
  testlib_unused(limit);
  die(MPS_RES_FAIL, "Error in Test, scan called unexpectedly");
  return MPS_RES_FAIL;
}
Beispiel #4
0
static void fmtVisitor(mps_addr_t object, mps_fmt_t format,
                       mps_pool_t pool, void *p, size_t s)
{
  env_t env = p;
  obj_t obj = object;
  testlib_unused(format);
  testlib_unused(pool);
  testlib_unused(s);
  if (obj->pad)
    env->pad += obj->size;
  else
    env->obj += obj->size;
}
Beispiel #5
0
static mps_res_t MPS_CALL scan_saves(mps_ss_t ss, void *p, size_t s)
{
  size_t i;
  saveRecord *sr;

  testlib_unused(p); testlib_unused(s);
  MPS_SCAN_BEGIN(ss)
    for (i = 0; i < MAXSAVELEVELS; ++i)
      for (sr = saves[i]; sr != NULL; sr = sr->next) {
        MPS_RETAIN((mps_addr_t*)&sr->slot, TRUE);
        MPS_SCAN_CALL((void)ps_scan(ss, &sr->oldvalue, &sr->oldvalue + 1));
      }
  MPS_SCAN_END(ss);
  return MPS_RES_OK;
}
Beispiel #6
0
static size_t randomSize(unsigned long i)
{
  /* Distribution centered on mean.  Verify that allocations
     below min and above max are handled correctly */
  size_t s = (size_max - size_mean)/4;
  size_t m = size_mean;
  double r;
  double x;

  testlib_unused(i);

  /* per SGR */
  do {
    r = expdev();
    x = (double)s * sqrt(2 * r);
    x += (double)m;
  } while (x <= 1.0);

  return (size_t)x;

}
Beispiel #7
0
static size_t fixedSize(size_t i)
{
  testlib_unused(i);
  return fixedSizeSize;
}
Beispiel #8
0
static mps_addr_t isMoved(mps_addr_t object)
{
  testlib_unused(object);
  cdie(0, "isMoved");
  return (mps_addr_t)NULL;
}
Beispiel #9
0
static void move(mps_addr_t object, mps_addr_t to)
{
  testlib_unused(object);
  testlib_unused(to);
  cdie(0, "move");
}
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;
}
static mps_res_t root_single(mps_ss_t ss, void *p, size_t s)
{
  testlib_unused(s);
  return mps_fix(ss, (mps_addr_t *)p);
}
Beispiel #12
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;
}
Beispiel #13
0
static mps_addr_t test_awl_find_dependent(mps_addr_t addr)
{
    testlib_unused(addr);
    return NULL;
}