コード例 #1
0
ファイル: gc_ctrl.c プロジェクト: crotsos/mirage-platform
void caml_init_gc (uintnat minor_size, uintnat major_size,
                   uintnat major_incr, uintnat percent_fr,
                   uintnat percent_m)
{
    uintnat major_heap_size = Bsize_wsize (norm_heapincr (major_size));

    if (caml_page_table_initialize(Bsize_wsize(minor_size) + major_heap_size)) {
        caml_fatal_error ("OCaml runtime error: cannot initialize page table\n");
    }
    caml_set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size)));
    caml_major_heap_increment = Bsize_wsize (norm_heapincr (major_incr));
    caml_percent_free = norm_pfree (percent_fr);
    caml_percent_max = norm_pmax (percent_m);
    caml_init_major_heap (major_heap_size);
    caml_gc_message (0x20, "Initial minor heap size: %luk bytes\n",
                     caml_minor_heap_size / 1024);
    caml_gc_message (0x20, "Initial major heap size: %luk bytes\n",
                     major_heap_size / 1024);
    caml_gc_message (0x20, "Initial space overhead: %lu%%\n", caml_percent_free);
    caml_gc_message (0x20, "Initial max overhead: %lu%%\n", caml_percent_max);
    caml_gc_message (0x20, "Initial heap increment: %luk bytes\n",
                     caml_major_heap_increment / 1024);
    caml_gc_message (0x20, "Initial allocation policy: %d\n",
                     caml_allocation_policy);
}
コード例 #2
0
ファイル: gc_ctrl.c プロジェクト: ocamllabs/ocaml-multicore
CAMLprim value caml_gc_set(value v)
{
  uintnat newpf;
  uintnat newminwsz;

#ifndef NATIVE_CODE
  caml_change_max_stack_size (Long_field (v, 5));
#endif

  newpf = norm_pfree (Long_field (v, 2));
  if (newpf != caml_percent_free){
    caml_percent_free = newpf;
    caml_gc_message (0x20, "New space overhead: %"
                     ARCH_INTNAT_PRINTF_FORMAT "u%%\n", caml_percent_free);
  }

  /* Minor heap size comes last because it will trigger a minor collection
     (thus invalidating [v]) and it can raise [Out_of_memory]. */
  newminwsz = caml_norm_minor_heap_size (Long_field (v, 0));
  if (newminwsz != Caml_state->minor_heap_wsz){
    caml_gc_message (0x20, "New minor heap size: %"
                     ARCH_SIZET_PRINTF_FORMAT "uk words\n", newminwsz / 1024);
    caml_set_minor_heap_size (newminwsz);
  }

  return Val_unit;
}
コード例 #3
0
ファイル: gc_ctrl.c プロジェクト: crotsos/mirage-platform
CAMLprim value caml_gc_set(value v)
{
    uintnat newpf, newpm;
    asize_t newheapincr;
    asize_t newminsize;
    uintnat oldpolicy;

    caml_verb_gc = Long_val (Field (v, 3));

#ifndef NATIVE_CODE
    caml_change_max_stack_size (Long_val (Field (v, 5)));
#endif

    newpf = norm_pfree (Long_val (Field (v, 2)));
    if (newpf != caml_percent_free) {
        caml_percent_free = newpf;
        caml_gc_message (0x20, "New space overhead: %d%%\n", caml_percent_free);
    }

    newpm = norm_pmax (Long_val (Field (v, 4)));
    if (newpm != caml_percent_max) {
        caml_percent_max = newpm;
        caml_gc_message (0x20, "New max overhead: %d%%\n", caml_percent_max);
    }

    newheapincr = Bsize_wsize (norm_heapincr (Long_val (Field (v, 1))));
    if (newheapincr != caml_major_heap_increment) {
        caml_major_heap_increment = newheapincr;
        caml_gc_message (0x20, "New heap increment size: %luk bytes\n",
                         caml_major_heap_increment/1024);
    }
    oldpolicy = caml_allocation_policy;
    caml_set_allocation_policy (Long_val (Field (v, 6)));
    if (oldpolicy != caml_allocation_policy) {
        caml_gc_message (0x20, "New allocation policy: %d\n",
                         caml_allocation_policy);
    }

    /* Minor heap size comes last because it will trigger a minor collection
       (thus invalidating [v]) and it can raise [Out_of_memory]. */
    newminsize = norm_minsize (Bsize_wsize (Long_val (Field (v, 0))));
    if (newminsize != caml_minor_heap_size) {
        caml_gc_message (0x20, "New minor heap size: %luk bytes\n",
                         newminsize/1024);
        caml_set_minor_heap_size (newminsize);
    }
    return Val_unit;
}
コード例 #4
0
ファイル: gc_ctrl.c プロジェクト: dhil/ocaml-multicore
void caml_init_gc ()
{
/*  uintnat major_heap_size =
      Bsize_wsize (caml_normalize_heap_increment (caml_params->heap_size_init)); */

  caml_max_stack_size = caml_params->init_max_stack_wsz;
  caml_fiber_wsz = caml_params->init_fiber_wsz;
  caml_percent_free = norm_pfree (caml_params->init_percent_free);
  caml_gc_log ("Initial stack limit: %luk bytes",
               caml_max_stack_size / 1024 * sizeof (value));
  caml_setup_eventlog();
  caml_gc_phase = Phase_sweep_and_mark_main;
  #ifdef NATIVE_CODE
  caml_init_frame_descriptors();
  #endif
  caml_init_domains(caml_params->init_minor_heap_wsz);
/*
  caml_major_heap_increment = major_incr;
  caml_percent_free = norm_pfree (percent_fr);
  caml_percent_max = norm_pmax (percent_m);
  caml_init_major_heap (major_heap_size);
  caml_gc_message (0x20, "Initial minor heap size: %luk bytes\n",
                   Caml_state->minor_heap_size / 1024);
  caml_gc_message (0x20, "Initial major heap size: %luk bytes\n",
                   major_heap_size / 1024);
  caml_gc_message (0x20, "Initial space overhead: %"
                   ARCH_INTNAT_PRINTF_FORMAT "u%%\n", caml_percent_free);
  caml_gc_message (0x20, "Initial max overhead: %"
                   ARCH_INTNAT_PRINTF_FORMAT "u%%\n", caml_percent_max);
  if (caml_major_heap_increment > 1000){
    caml_gc_message (0x20, "Initial heap increment: %"
                     ARCH_INTNAT_PRINTF_FORMAT "uk words\n",
                     caml_major_heap_increment / 1024);
  }else{
    caml_gc_message (0x20, "Initial heap increment: %"
                     ARCH_INTNAT_PRINTF_FORMAT "u%%\n",
                     caml_major_heap_increment);
  }
  caml_gc_message (0x20, "Initial allocation policy: %d\n",
                   caml_allocation_policy);
*/
}
コード例 #5
0
ファイル: gc_ctrl.c プロジェクト: avsm/ocaml-community
void caml_init_gc (uintnat minor_size, uintnat major_size,
                   uintnat major_incr, uintnat percent_fr,
                   uintnat percent_m)
{
  uintnat major_heap_size = Bsize_wsize (norm_heapincr (major_size));

  caml_set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size)));
  caml_major_heap_increment = Bsize_wsize (norm_heapincr (major_incr));
  caml_percent_free = norm_pfree (percent_fr);
  caml_percent_max = norm_pmax (percent_m);
  caml_init_major_heap (major_heap_size);
  caml_gc_message (0x20, "Initial minor heap size: %luk bytes\n",
                   caml_minor_heap_size / 1024);
  caml_gc_message (0x20, "Initial major heap size: %luk bytes\n",
                   major_heap_size / 1024);
  caml_gc_message (0x20, "Initial space overhead: %lu%%\n", caml_percent_free);
  caml_gc_message (0x20, "Initial max overhead: %lu%%\n", caml_percent_max);
  caml_gc_message (0x20, "Initial heap increment: %luk bytes\n",
                   caml_major_heap_increment / 1024);
}
コード例 #6
0
ファイル: gc_ctrl.c プロジェクト: vouillon/ocaml
/* [minor_size] and [major_size] are numbers of words
   [major_incr] is either a percentage or a number of words */
void caml_init_gc (uintnat minor_size, uintnat major_size,
                   uintnat major_incr, uintnat percent_fr,
                   uintnat percent_m, uintnat window)
{
  uintnat major_heap_size =
    Bsize_wsize (caml_normalize_heap_increment (major_size));

  CAML_INSTR_INIT ();
  if (caml_init_alloc_for_heap () != 0){
    caml_fatal_error ("cannot initialize heap: mmap failed\n");
  }
  if (caml_page_table_initialize(Bsize_wsize(minor_size) + major_heap_size)){
    caml_fatal_error ("OCaml runtime error: cannot initialize page table\n");
  }
  caml_set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size)));
  caml_major_heap_increment = major_incr;
  caml_percent_free = norm_pfree (percent_fr);
  caml_percent_max = norm_pmax (percent_m);
  caml_init_major_heap (major_heap_size);
  caml_major_window = norm_window (window);
  caml_gc_message (0x20, "Initial minor heap size: %luk words\n",
                   caml_minor_heap_wsz / 1024);
  caml_gc_message (0x20, "Initial major heap size: %luk bytes\n",
                   major_heap_size / 1024);
  caml_gc_message (0x20, "Initial space overhead: %lu%%\n", caml_percent_free);
  caml_gc_message (0x20, "Initial max overhead: %lu%%\n", caml_percent_max);
  if (caml_major_heap_increment > 1000){
    caml_gc_message (0x20, "Initial heap increment: %luk words\n",
                     caml_major_heap_increment / 1024);
  }else{
    caml_gc_message (0x20, "Initial heap increment: %lu%%\n",
                     caml_major_heap_increment);
  }
  caml_gc_message (0x20, "Initial allocation policy: %d\n",
                   caml_allocation_policy);
  caml_gc_message (0x20, "Initial smoothing window: %d\n",
                   caml_major_window);
}
コード例 #7
0
ファイル: gc_ctrl.c プロジェクト: rizo/snowflake-os
void caml_init_gc (uintnat minor_size, uintnat major_size,
                   uintnat major_incr, uintnat percent_fr,
                   uintnat percent_m)
{
    uintnat major_heap_size = Bsize_wsize (norm_heapincr (major_size));

#ifdef DEBUG
    caml_gc_message (-1, "### O'Caml runtime: debug mode ###\n", 0);
#endif

    caml_set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size)));
    caml_major_heap_increment = Bsize_wsize (norm_heapincr (major_incr));
    caml_percent_free = norm_pfree (percent_fr);
    caml_percent_max = norm_pmax (percent_m);
    caml_init_major_heap (major_heap_size);
    caml_gc_message (0x20, "Initial minor heap size: %luk bytes\n",
                     caml_minor_heap_size / 1024);
    caml_gc_message (0x20, "Initial major heap size: %luk bytes\n",
                     major_heap_size / 1024);
    caml_gc_message (0x20, "Initial space overhead: %lu%%\n", caml_percent_free);
    caml_gc_message (0x20, "Initial max overhead: %lu%%\n", caml_percent_max);
    caml_gc_message (0x20, "Initial heap increment: %luk bytes\n",
                     caml_major_heap_increment / 1024);
}
コード例 #8
0
ファイル: gc_ctrl.c プロジェクト: vouillon/ocaml
CAMLprim value caml_gc_set(value v)
{
  uintnat newpf, newpm;
  asize_t newheapincr;
  asize_t newminwsz;
  uintnat oldpolicy;
  CAML_INSTR_SETUP (tmr, "");

  caml_verb_gc = Long_val (Field (v, 3));

#ifndef NATIVE_CODE
  caml_change_max_stack_size (Long_val (Field (v, 5)));
#endif

  newpf = norm_pfree (Long_val (Field (v, 2)));
  if (newpf != caml_percent_free){
    caml_percent_free = newpf;
    caml_gc_message (0x20, "New space overhead: %d%%\n", caml_percent_free);
  }

  newpm = norm_pmax (Long_val (Field (v, 4)));
  if (newpm != caml_percent_max){
    caml_percent_max = newpm;
    caml_gc_message (0x20, "New max overhead: %d%%\n", caml_percent_max);
  }

  newheapincr = Long_val (Field (v, 1));
  if (newheapincr != caml_major_heap_increment){
    caml_major_heap_increment = newheapincr;
    if (newheapincr > 1000){
      caml_gc_message (0x20, "New heap increment size: %luk words\n",
                       caml_major_heap_increment/1024);
    }else{
      caml_gc_message (0x20, "New heap increment size: %lu%%\n",
                       caml_major_heap_increment);
    }
  }
  oldpolicy = caml_allocation_policy;
  caml_set_allocation_policy (Long_val (Field (v, 6)));
  if (oldpolicy != caml_allocation_policy){
    caml_gc_message (0x20, "New allocation policy: %d\n",
                     caml_allocation_policy);
  }

  /* This field was added in 4.03.0. */
  if (Wosize_val (v) >= 8){
    int old_window = caml_major_window;
    caml_set_major_window (norm_window (Long_val (Field (v, 7))));
    if (old_window != caml_major_window){
      caml_gc_message (0x20, "New smoothing window size: %d\n",
                       caml_major_window);
    }
  }

    /* Minor heap size comes last because it will trigger a minor collection
       (thus invalidating [v]) and it can raise [Out_of_memory]. */
  newminwsz = norm_minsize (Long_val (Field (v, 0)));
  if (newminwsz != caml_minor_heap_wsz){
    caml_gc_message (0x20, "New minor heap size: %luk words\n",
                     newminwsz / 1024);
    caml_set_minor_heap_size (Bsize_wsize (newminwsz));
  }
  CAML_INSTR_TIME (tmr, "explicit/gc_set");
  return Val_unit;
}