Beispiel #1
0
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);
}
Beispiel #2
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;
}
Beispiel #3
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;
}
Beispiel #4
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.");
}