Skip to content

Commit

Permalink
runtime/array.c: blitting from flat to non-flat is not supported (#13102
Browse files Browse the repository at this point in the history
)


Reported-by: Olivier Nicole <olivier@chnik.fr>
Reviewed-by: Olivier Nicole <olivier@chnik.fr>
Reviewed-by: Xavier Leroy <xavier.leroy@college-de-france.fr>
  • Loading branch information
gasche committed May 13, 2024
1 parent 57255a0 commit d87e21f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions runtime/array.c
Expand Up @@ -371,6 +371,12 @@ static void wo_memmove (volatile value* const dst,
CAMLprim value caml_floatarray_blit(value a1, value ofs1, value a2, value ofs2,
value n)
{
if (Long_val(n) == 0) return Val_unit;
/* Note: size-0 floatarrays do not have Double_array_tag,
but only size-0 blits are possible on them, so they
do not reach this point. */
CAMLassert (Tag_val(a1) == Double_array_tag);
CAMLassert (Tag_val(a2) == Double_array_tag);
/* See memory model [MM] notes in memory.c */
atomic_thread_fence(memory_order_acquire);
memmove((double *)a2 + Long_val(ofs2),
Expand All @@ -389,6 +395,10 @@ CAMLprim value caml_array_blit(value a1, value ofs1, value a2, value ofs2,
if (Tag_val(a2) == Double_array_tag)
return caml_floatarray_blit(a1, ofs1, a2, ofs2, n);
#endif
if (Long_val(n) == 0)
/* See comment on size-0 floatarrays in [caml_floatarray_blit]. */
return Val_unit;
CAMLassert (Tag_val(a1) != Double_array_tag);
CAMLassert (Tag_val(a2) != Double_array_tag);
if (Is_young(a2)) {
/* Arrays of values, destination is in young generation.
Expand Down

0 comments on commit d87e21f

Please sign in to comment.