Skip to content

Commit

Permalink
flambda-backend: Fix caml_gc_compaction in the 5 runtime to run final…
Browse files Browse the repository at this point in the history
…izers (#2135)
  • Loading branch information
mshinwell authored Dec 13, 2023
1 parent 8ecff46 commit 0b9333c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions runtime/gc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ CAMLprim value caml_gc_major(value v)
return caml_raise_async_if_exception(gc_major_exn (0), "");
}

static value gc_full_major_exn(void)
static value gc_full_major_exn(int force_compaction)
{
int i;
value exn = Val_unit;
Expand All @@ -268,7 +268,7 @@ static value gc_full_major_exn(void)
currently-unreachable object to be collected. */
for (i = 0; i < 3; i++) {
caml_empty_minor_heaps_once();
caml_finish_major_cycle(0);
caml_finish_major_cycle(force_compaction && i == 2);
exn = caml_process_pending_actions_exn();
if (Is_exception_result(exn)) break;
}
Expand All @@ -281,7 +281,7 @@ CAMLprim value caml_gc_full_major(value v)
{
Caml_check_caml_state();
CAMLassert (v == Val_unit);
return caml_raise_async_if_exception(gc_full_major_exn (), "");
return caml_raise_async_if_exception(gc_full_major_exn (0), "");
}

CAMLprim value caml_gc_major_slice (value v)
Expand All @@ -299,8 +299,7 @@ CAMLprim value caml_gc_compaction(value v)
Caml_check_caml_state();
CAML_EV_BEGIN(EV_EXPLICIT_GC_COMPACT);
CAMLassert (v == Val_unit);
value exn = gc_major_exn(1);
++ Caml_state->stat_forced_major_collections;
value exn = gc_full_major_exn(1);
CAML_EV_END(EV_EXPLICIT_GC_COMPACT);
return caml_raise_async_if_exception(exn, "");
}
Expand All @@ -309,7 +308,7 @@ CAMLprim value caml_gc_stat(value v)
{
value res;
CAML_EV_BEGIN(EV_EXPLICIT_GC_STAT);
res = gc_full_major_exn();
res = gc_full_major_exn(0);
if (Is_exception_result(res)) goto out;
res = caml_gc_quick_stat(Val_unit);
out:
Expand Down

0 comments on commit 0b9333c

Please sign in to comment.