Skip to content

Port upstream PRs 11542 and 12505 to runtime4 #3431

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions backend/cmm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1769,15 +1769,11 @@ let make_alloc_generic ~block_kind ~mode dbg tag wordsize args
fields and memory chunks"
in
let caml_alloc_func, caml_alloc_args =
match Config.runtime5, block_kind with
| true, Regular_block -> "caml_alloc_shr_check_gc", [wordsize; tag]
| false, Regular_block -> "caml_alloc", [wordsize; tag]
| true, Mixed_block { scannable_prefix } ->
match block_kind with
| Regular_block -> "caml_alloc_shr_check_gc", [wordsize; tag]
| Mixed_block { scannable_prefix } ->
Mixed_block_support.assert_mixed_block_support ();
"caml_alloc_mixed_shr_check_gc", [wordsize; tag; scannable_prefix]
| false, Mixed_block { scannable_prefix } ->
Mixed_block_support.assert_mixed_block_support ();
"caml_alloc_mixed", [wordsize; tag; scannable_prefix]
in
Clet
( VP.create id,
Expand Down
30 changes: 30 additions & 0 deletions runtime4/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,43 @@ CAMLexport value caml_alloc (mlsize_t wosize, tag_t tag) {
return caml_alloc_with_reserved (wosize, tag, 0);
}

/* This is used by the native compiler for large block allocations. */
CAMLexport value caml_alloc_shr_reserved_check_gc (mlsize_t wosize, tag_t tag,
reserved_t reserved)
{
CAMLassert (tag < Num_tags);
CAMLassert (tag != Infix_tag);
caml_check_urgent_gc (Val_unit);
value result = caml_alloc_shr_reserved (wosize, tag, reserved);
if (tag < No_scan_tag) {
mlsize_t scannable_wosize = Scannable_wosize_val(result);
for (mlsize_t i = 0; i < scannable_wosize; i++) {
Field (result, i) = Val_unit;
}
}
return result;
}

CAMLexport value caml_alloc_shr_check_gc (mlsize_t wosize, tag_t tag)
{
return caml_alloc_shr_reserved_check_gc(wosize, tag, 0);
}

#ifdef NATIVE_CODE
CAMLexport value caml_alloc_mixed (mlsize_t wosize, tag_t tag,
mlsize_t scannable_prefix) {
reserved_t reserved =
Reserved_mixed_block_scannable_wosize_native(scannable_prefix);
return caml_alloc_with_reserved (wosize, tag, reserved);
}

CAMLexport value caml_alloc_mixed_shr_check_gc (mlsize_t wosize, tag_t tag,
mlsize_t scannable_prefix_len)
{
reserved_t reserved =
Reserved_mixed_block_scannable_wosize_native(scannable_prefix_len);
return caml_alloc_shr_reserved_check_gc(wosize, tag, reserved);
}
#endif // NATIVE_CODE

CAMLexport value caml_alloc_small_with_reserved (mlsize_t wosize, tag_t tag,
Expand Down
3 changes: 3 additions & 0 deletions runtime4/caml/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ CAMLextern value caml_alloc_mixed (mlsize_t wosize, tag_t,
CAMLextern value caml_alloc_small (mlsize_t wosize, tag_t);
CAMLextern value caml_alloc_small_with_reserved (mlsize_t wosize, tag_t,
reserved_t);
CAMLextern value caml_alloc_shr_check_gc (mlsize_t, tag_t);
CAMLextern value caml_alloc_mixed_shr_check_gc (mlsize_t, tag_t,
mlsize_t scannable_wosize);
CAMLextern value caml_alloc_tuple (mlsize_t wosize);
CAMLextern value caml_alloc_float_array (mlsize_t len);
CAMLextern value caml_alloc_string (mlsize_t len); /* len in bytes (chars) */
Expand Down
Loading