@@ -947,10 +947,11 @@ let unique_arity_identifier (arity : Cmm.machtype list) =
947
947
then Int. to_string (List. length arity)
948
948
else String. concat " _" (List. map machtype_identifier arity)
949
949
950
+ let result_layout_suffix result =
951
+ match result with [| Val |] -> " " | _ -> " _R" ^ machtype_identifier result
952
+
950
953
let send_function_name arity result (mode : Lambda.alloc_mode ) =
951
- let res =
952
- match result with [| Val |] -> " " | _ -> " _R" ^ machtype_identifier result
953
- in
954
+ let res = result_layout_suffix result in
954
955
let suff = match mode with Alloc_heap -> " " | Alloc_local -> " L" in
955
956
" caml_send" ^ unique_arity_identifier arity ^ res ^ suff
956
957
@@ -1018,9 +1019,7 @@ let make_checkbound dbg = function
1018
1019
(* Record application and currying functions *)
1019
1020
1020
1021
let apply_function_name arity result (mode : Lambda.alloc_mode ) =
1021
- let res =
1022
- match result with [| Val |] -> " " | _ -> " _R" ^ machtype_identifier result
1023
- in
1022
+ let res = result_layout_suffix result in
1024
1023
let suff = match mode with Alloc_heap -> " " | Alloc_local -> " L" in
1025
1024
" caml_apply" ^ unique_arity_identifier arity ^ res ^ suff
1026
1025
@@ -1031,25 +1030,23 @@ let apply_function_sym arity result mode =
1031
1030
Compilenv. need_apply_fun arity result mode;
1032
1031
apply_function_name arity result mode
1033
1032
1033
+ let tuplify_function_name arity result =
1034
+ " caml_tuplify" ^ Int. to_string arity ^ result_layout_suffix result
1035
+
1034
1036
let curry_function_sym function_kind arity result =
1035
1037
Compilenv. need_curry_fun function_kind arity result;
1036
1038
match function_kind with
1037
1039
| Lambda. Curried { nlocal } ->
1038
1040
" caml_curry"
1039
1041
^ unique_arity_identifier arity
1040
- ^ (match result with
1041
- | [| Val |] -> " "
1042
- | _ -> " _R" ^ machtype_identifier result)
1042
+ ^ result_layout_suffix result
1043
1043
^ if nlocal > 0 then " L" ^ Int. to_string nlocal else " "
1044
- | Lambda. Tupled -> (
1044
+ | Lambda. Tupled ->
1045
1045
if List. exists (function [| Val |] -> false | _ -> true ) arity
1046
1046
then
1047
1047
Misc. fatal_error
1048
1048
" tuplify_function is currently unsupported if arity contains non-values" ;
1049
- " caml_tuplify"
1050
- ^ Int. to_string (List. length arity)
1051
- ^
1052
- match result with [| Val |] -> " " | _ -> " _R" ^ machtype_identifier result)
1049
+ tuplify_function_name (List. length arity) result
1053
1050
1054
1051
(* Big arrays *)
1055
1052
@@ -2254,13 +2251,7 @@ let tuplify_function arity return =
2254
2251
else get_field_gen Asttypes. Mutable (Cvar arg) i (dbg () )
2255
2252
:: access_components(i+ 1 )
2256
2253
in
2257
- let fun_name =
2258
- " caml_tuplify" ^ Int. to_string arity
2259
- ^
2260
- match return with
2261
- | [| Val |] -> " "
2262
- | _ -> " _R" ^ machtype_identifier return
2263
- in
2254
+ let fun_name = tuplify_function_name arity return in
2264
2255
let fun_dbg = placeholder_fun_dbg ~human_name: fun_name in
2265
2256
Cfunction
2266
2257
{fun_name;
0 commit comments