Skip to content

Commit 0b9333c

Browse files
authored
flambda-backend: Fix caml_gc_compaction in the 5 runtime to run finalizers (#2135)
1 parent 8ecff46 commit 0b9333c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

runtime/gc_ctrl.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ CAMLprim value caml_gc_major(value v)
258258
return caml_raise_async_if_exception(gc_major_exn (0), "");
259259
}
260260

261-
static value gc_full_major_exn(void)
261+
static value gc_full_major_exn(int force_compaction)
262262
{
263263
int i;
264264
value exn = Val_unit;
@@ -268,7 +268,7 @@ static value gc_full_major_exn(void)
268268
currently-unreachable object to be collected. */
269269
for (i = 0; i < 3; i++) {
270270
caml_empty_minor_heaps_once();
271-
caml_finish_major_cycle(0);
271+
caml_finish_major_cycle(force_compaction && i == 2);
272272
exn = caml_process_pending_actions_exn();
273273
if (Is_exception_result(exn)) break;
274274
}
@@ -281,7 +281,7 @@ CAMLprim value caml_gc_full_major(value v)
281281
{
282282
Caml_check_caml_state();
283283
CAMLassert (v == Val_unit);
284-
return caml_raise_async_if_exception(gc_full_major_exn (), "");
284+
return caml_raise_async_if_exception(gc_full_major_exn (0), "");
285285
}
286286

287287
CAMLprim value caml_gc_major_slice (value v)
@@ -299,8 +299,7 @@ CAMLprim value caml_gc_compaction(value v)
299299
Caml_check_caml_state();
300300
CAML_EV_BEGIN(EV_EXPLICIT_GC_COMPACT);
301301
CAMLassert (v == Val_unit);
302-
value exn = gc_major_exn(1);
303-
++ Caml_state->stat_forced_major_collections;
302+
value exn = gc_full_major_exn(1);
304303
CAML_EV_END(EV_EXPLICIT_GC_COMPACT);
305304
return caml_raise_async_if_exception(exn, "");
306305
}
@@ -309,7 +308,7 @@ CAMLprim value caml_gc_stat(value v)
309308
{
310309
value res;
311310
CAML_EV_BEGIN(EV_EXPLICIT_GC_STAT);
312-
res = gc_full_major_exn();
311+
res = gc_full_major_exn(0);
313312
if (Is_exception_result(res)) goto out;
314313
res = caml_gc_quick_stat(Val_unit);
315314
out:

0 commit comments

Comments
 (0)