Ejemplo n.º 1
0
static void test(void)
{
    mps_arena_t arena;
    mps_pool_t pool;
    mps_thr_t thread;

    size_t mysize;
    mps_addr_t a;

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

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

    mysize = 8;

    cdie(
        mps_pool_create(
            &pool, arena, mps_class_mfs(), (size_t) 8, mysize),
        "create pool");

    mps_alloc(&a, pool, mysize);
    mps_free(NULL, a, mysize);
    mps_pool_destroy(pool);

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

 size_t mysize;
 mps_addr_t a;

 cdie(mps_space_create(&space), "create space");

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

 mysize = 16;

 cdie(
  mps_pool_create(
     &pool, space, mps_class_mfs(), mysize, mysize),
  "create pool");

 cdie(mps_alloc(&a, pool, mysize), "alloc");
 mps_free(pool, (mps_addr_t) ((char *)a+8), mysize);
 error("free");
 mps_pool_destroy(pool);

}
Ejemplo n.º 3
0
Archivo: 152.c Proyecto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;

 size_t mysize;
 mps_addr_t a;

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

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

 mysize = 16;

 cdie(
  mps_pool_create(
     &pool, arena, mps_class_mfs(), mysize, mysize),
  "create pool");

 cdie(mps_alloc(&a, pool, mysize), "alloc");
 mps_free(pool, (mps_addr_t) ((char *)a+8), mysize);
 mps_pool_destroy(pool);

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

 size_t mysize;
 mps_addr_t a;

 cdie(mps_space_create(&space), "create space");

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

 mysize = 8;

 cdie(
  mps_pool_create(
     &pool, space, mps_class_mfs(), (size_t) 8, mysize),
  "create pool");

 mps_alloc(&a, pool, mysize);
 mps_free(pool, NULL, mysize);
 mps_pool_destroy(pool);

}
Ejemplo n.º 5
0
static void testInArena(mps_arena_class_t arena_class, mps_arg_s *arena_args,
                        mps_pool_debug_option_s *options)
{
  mps_arena_t arena;

  die(mps_arena_create_k(&arena, arena_class, arena_args),
      "mps_arena_create");

  MPS_ARGS_BEGIN(args) {
    mps_align_t align = sizeof(void *) << (rnd() % 4);
    MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_ARENA_HIGH, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_SLOT_HIGH, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_FIRST_FIT, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_SPARE, rnd_double());
    die(stress(arena, NULL, randomSize8, align, "MVFF",
               mps_class_mvff(), args), "stress MVFF");
  } MPS_ARGS_END(args);

  MPS_ARGS_BEGIN(args) {
    mps_align_t align = sizeof(void *) << (rnd() % 4);
    MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_ARENA_HIGH, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_SLOT_HIGH, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_MVFF_FIRST_FIT, TRUE);
    MPS_ARGS_ADD(args, MPS_KEY_SPARE, rnd_double());
    MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, options);
    die(stress(arena, options, randomSize8, align, "MVFF debug",
               mps_class_mvff_debug(), args), "stress MVFF debug");
  } MPS_ARGS_END(args);

  MPS_ARGS_BEGIN(args) {
    mps_align_t align = (mps_align_t)1 << (rnd() % 6);
    MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align);
    die(stress(arena, NULL, randomSize, align, "MV",
               mps_class_mv(), args), "stress MV");
  } MPS_ARGS_END(args);

  MPS_ARGS_BEGIN(args) {
    mps_align_t align = (mps_align_t)1 << (rnd() % 6);
    MPS_ARGS_ADD(args, MPS_KEY_ALIGN, align);
    MPS_ARGS_ADD(args, MPS_KEY_POOL_DEBUG_OPTIONS, options);
    die(stress(arena, options, randomSize, align, "MV debug",
               mps_class_mv_debug(), args), "stress MV debug");
  } MPS_ARGS_END(args);

  MPS_ARGS_BEGIN(args) {
    fixedSizeSize = 1 + rnd() % 64;
    MPS_ARGS_ADD(args, MPS_KEY_MFS_UNIT_SIZE, fixedSizeSize);
    MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, 100000);
    die(stress(arena, NULL, fixedSize, MPS_PF_ALIGN, "MFS",
               mps_class_mfs(), args), "stress MFS");
  } MPS_ARGS_END(args);

  /* Manual allocation should not cause any garbage collections. */
  Insist(mps_collections(arena) == 0);
  mps_arena_destroy(arena);
}
Ejemplo n.º 6
0
Archivo: 40.c Proyecto: Ravenbrook/mps
static void test(void *stack_pointer)
{
 mps_arena_t arena;
 mps_pool_t pool;
 mps_thr_t thread;

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

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

 cdie(
  mps_pool_create(
     &pool, arena, mps_class_mfs(), (size_t) 32, (size_t) 33), 
  "create pool");

 mps_pool_destroy(pool);

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

 cdie(mps_space_create(&space), "create space");

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

 cdie(
  mps_pool_create(
     &pool, space, mps_class_mfs(), (size_t) 128, (size_t) 0), 
  "create pool");

 mps_pool_destroy(pool);

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