Skip to content

Commit

Permalink
flambda-backend: Small optimisation for caml_modify (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan authored Mar 21, 2023
1 parent b16493b commit 999d523
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion runtime/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,17 @@ CAMLexport CAMLweakdef void caml_modify (value *fp, value val)
if (Is_young(old)) return;
/* Here, [old] can be a pointer within the major heap.
Check for condition 2. */
if (caml_gc_phase == Phase_mark) caml_darken(old, NULL);
if (caml_gc_phase == Phase_mark) {
header_t hd = Hd_val(old);
if (Tag_hd (hd) == Infix_tag) {
/* Infix_tag is always Caml_white */
CAMLassert(Is_white_hd(hd));
}
/* Inline the white-header check, to save a pagetable lookup */
if (Is_white_hd(hd)) {
caml_darken(old, NULL);
}
}
}
/* Check for condition 1. */
if (Is_block(val) && Is_young(val)) {
Expand Down

0 comments on commit 999d523

Please sign in to comment.