@@ -72,13 +72,13 @@ module Generate (Target : Target_sig.S) = struct
7272
7373 let repr_type r =
7474 match r with
75- | Value -> Value . value
75+ | Value -> Type . value
7676 | Float -> F64
7777 | Int32 -> I32
7878 | Nativeint -> I32
7979 | Int64 -> I64
8080
81- let specialized_func_type (_ , params , result ) =
81+ let specialized_primitive_type (_ , params , result ) =
8282 { W. params = List. map ~f: repr_type params; result = [ repr_type result ] }
8383
8484 let box_value r e =
@@ -127,9 +127,6 @@ module Generate (Target : Target_sig.S) = struct
127127 ];
128128 h
129129
130- let func_type n =
131- { W. params = List. init ~len: n ~f: (fun _ -> Value. value); result = [ Value. value ] }
132-
133130 let float_bin_op' op f g =
134131 Memory. box_float (op (Memory. unbox_float f) (Memory. unbox_float g))
135132
@@ -711,7 +708,7 @@ module Generate (Target : Target_sig.S) = struct
711708 let ((_, arg_typ, res_typ) as typ ) =
712709 Hashtbl. find specialized_primitives name
713710 in
714- let * f = register_import ~name (Fun (specialized_func_type typ)) in
711+ let * f = register_import ~name (Fun (specialized_primitive_type typ)) in
715712 let rec loop acc arg_typ l =
716713 match arg_typ, l with
717714 | [] , [] -> box_value res_typ (return (W. Call (f, List. rev acc)))
@@ -722,7 +719,9 @@ module Generate (Target : Target_sig.S) = struct
722719 in
723720 loop [] arg_typ l
724721 with Not_found ->
725- let * f = register_import ~name (Fun (func_type (List. length l))) in
722+ let * f =
723+ register_import ~name (Fun (Type. primitive_type (List. length l)))
724+ in
726725 let rec loop acc l =
727726 match l with
728727 | [] -> return (W. Call (f, List. rev acc))
@@ -921,6 +920,8 @@ module Generate (Target : Target_sig.S) = struct
921920 | _ -> Structure. is_merge_node g pc'
922921 in
923922 let code ~context =
923+ let block = Addr.Map. find pc ctx.blocks in
924+ let * () = translate_instrs ctx context block.body in
924925 translate_node_within
925926 ~result_typ
926927 ~fall_through
@@ -965,7 +966,6 @@ module Generate (Target : Target_sig.S) = struct
965966 translate_tree result_typ fall_through pc' context
966967 | [] -> (
967968 let block = Addr.Map. find pc ctx.blocks in
968- let * () = translate_instrs ctx context block.body in
969969 let branch = block.branch in
970970 match branch with
971971 | Branch cont -> translate_branch result_typ fall_through pc cont context
@@ -997,7 +997,7 @@ module Generate (Target : Target_sig.S) = struct
997997 instr (Br_table (e, List. map ~f: dest l, dest a.(len - 1 )))
998998 | Raise (x , _ ) -> (
999999 let * e = load x in
1000- let * tag = register_import ~name: exception_name (Tag Value . value) in
1000+ let * tag = register_import ~name: exception_name (Tag Type . value) in
10011001 match fall_through with
10021002 | `Catch -> instr (Push e)
10031003 | `Block _ | `Return | `Skip -> (
@@ -1082,7 +1082,7 @@ module Generate (Target : Target_sig.S) = struct
10821082 wrap_with_handlers
10831083 p
10841084 pc
1085- ~result_typ: [ Value . value ]
1085+ ~result_typ: [ Type . value ]
10861086 ~fall_through: `Return
10871087 ~context: []
10881088 (fun ~result_typ ~fall_through ~context ->
@@ -1103,7 +1103,10 @@ module Generate (Target : Target_sig.S) = struct
11031103 | None -> Option. map ~f: (fun name -> name ^ " .init" ) unit_name
11041104 | Some _ -> None )
11051105 ; typ = None
1106- ; signature = func_type param_count
1106+ ; signature =
1107+ (match name_opt with
1108+ | None -> Type. primitive_type param_count
1109+ | Some _ -> Type. func_type (param_count - 1 ))
11071110 ; param_names
11081111 ; locals
11091112 ; body
@@ -1112,7 +1115,7 @@ module Generate (Target : Target_sig.S) = struct
11121115
11131116 let init_function ~context ~to_link =
11141117 let name = Code.Var. fresh_n " initialize" in
1115- let signature = { W. params = [] ; result = [ Value . value ] } in
1118+ let signature = { W. params = [] ; result = [ Type . value ] } in
11161119 let locals, body =
11171120 function_body
11181121 ~context
@@ -1288,7 +1291,7 @@ module G = Generate (Gc_target)
12881291
12891292let init = G. init
12901293
1291- let start () = make_context ~value_type: Gc_target.Value . value
1294+ let start () = make_context ~value_type: Gc_target.Type . value
12921295
12931296let f ~context ~unit_name p ~live_vars ~in_cps ~deadcode_sentinal =
12941297 let t = Timer. make () in
0 commit comments