Skip to content

Commit 1f869a5

Browse files
committed
Fix to_cmm with complex arities (oxcaml#3982)
1 parent d8dbd01 commit 1f869a5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

backend/cmm_helpers.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,12 +2880,12 @@ let maybe_reset_current_region ~dbg ~body_tail ~body_nontail old_region =
28802880
Any )
28812881

28822882
let apply_or_call_caml_apply result arity mut clos args pos mode dbg =
2883-
match args with
2884-
| [arg] ->
2883+
match arity with
2884+
| [_] ->
28852885
bind "fun" clos (fun clos ->
28862886
Cop
28872887
( Capply (Extended_machtype.to_machtype result, pos),
2888-
[get_field_codepointer mut clos 0 dbg; arg; clos],
2888+
(get_field_codepointer mut clos 0 dbg :: args) @ [clos],
28892889
dbg ))
28902890
| _ -> call_caml_apply result arity mut clos args pos mode dbg
28912891

@@ -4250,10 +4250,12 @@ let indirect_call ~dbg ty pos alloc_mode f args_type args =
42504250
might_split_call_caml_apply ty args_type Asttypes.Mutable f args pos
42514251
alloc_mode dbg
42524252

4253-
let indirect_full_call ~dbg ty pos alloc_mode f args_type = function
4253+
let indirect_full_call ~dbg ty pos alloc_mode f args_type args =
4254+
match args_type with
42544255
(* the single-argument case is already optimized by indirect_call *)
4255-
| [_] as args -> indirect_call ~dbg ty pos alloc_mode f args_type args
4256-
| args ->
4256+
| [_] -> indirect_call ~dbg ty pos alloc_mode f args_type args
4257+
| [] -> Misc.fatal_error "indirect_full_call: args_type was empty"
4258+
| _ :: _ :: _ ->
42574259
(* Use a variable to avoid duplicating the cmm code of the closure [f]. *)
42584260
let v = Backend_var.create_local "*closure*" in
42594261
let v' = Backend_var.With_provenance.create v in

0 commit comments

Comments
 (0)