Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bigarray: do not change GC pace when creating subarrays or slices #12493

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -302,6 +302,9 @@ Working version
`Unix.create_process` (the one used when `posix_spawnp` is unavailable)
(Xavier Leroy, report by Chris Vine, review by Nicolás Ojeda Bär)

- #12491: allocating subarrays or slices of bigarrays increases
GC speed wrongly -- as if new memory was allocated
(Gabriel Scherer, report by Ido Yariv, review by ???)

OCaml 5.1.0 release branch
--------------------------
Expand Down
8 changes: 4 additions & 4 deletions runtime/bigarray.c
Expand Up @@ -225,7 +225,7 @@ CAMLexport value
caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim)
{
uintnat num_elts, asize, size;
int i, is_managed;
int i, must_alloc;
value res;
struct caml_ba_array * b;
intnat dimcopy[CAML_BA_MAX_NUM_DIMS];
Expand All @@ -242,14 +242,14 @@ caml_ba_alloc(int flags, int num_dims, void * data, intnat * dim)
caml_ba_element_size[flags & CAML_BA_KIND_MASK],
&size))
caml_raise_out_of_memory();
if (data == NULL) {
must_alloc = (data == NULL);
if (must_alloc) {
data = malloc(size);
if (data == NULL && size != 0) caml_raise_out_of_memory();
flags |= CAML_BA_MANAGED;
}
asize = SIZEOF_BA_ARRAY + num_dims * sizeof(intnat);
is_managed = ((flags & CAML_BA_MANAGED_MASK) == CAML_BA_MANAGED);
res = caml_alloc_custom_mem(&caml_ba_ops, asize, is_managed ? size : 0);
res = caml_alloc_custom_mem(&caml_ba_ops, asize, must_alloc ? size : 0);
b = Caml_ba_array_val(res);
b->data = data;
b->num_dims = num_dims;
Expand Down