@@ -72,13 +72,13 @@ module Generate (Target : Target_sig.S) = struct
72
72
73
73
let repr_type r =
74
74
match r with
75
- | Value -> Value . value
75
+ | Value -> Type . value
76
76
| Float -> F64
77
77
| Int32 -> I32
78
78
| Nativeint -> I32
79
79
| Int64 -> I64
80
80
81
- let specialized_func_type (_ , params , result ) =
81
+ let specialized_primitive_type (_ , params , result ) =
82
82
{ W. params = List. map ~f: repr_type params; result = [ repr_type result ] }
83
83
84
84
let box_value r e =
@@ -127,9 +127,6 @@ module Generate (Target : Target_sig.S) = struct
127
127
];
128
128
h
129
129
130
- let func_type n =
131
- { W. params = List. init ~len: n ~f: (fun _ -> Value. value); result = [ Value. value ] }
132
-
133
130
let float_bin_op' op f g =
134
131
Memory. box_float (op (Memory. unbox_float f) (Memory. unbox_float g))
135
132
@@ -711,7 +708,7 @@ module Generate (Target : Target_sig.S) = struct
711
708
let ((_, arg_typ, res_typ) as typ ) =
712
709
Hashtbl. find specialized_primitives name
713
710
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
715
712
let rec loop acc arg_typ l =
716
713
match arg_typ, l with
717
714
| [] , [] -> box_value res_typ (return (W. Call (f, List. rev acc)))
@@ -722,7 +719,9 @@ module Generate (Target : Target_sig.S) = struct
722
719
in
723
720
loop [] arg_typ l
724
721
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
726
725
let rec loop acc l =
727
726
match l with
728
727
| [] -> return (W. Call (f, List. rev acc))
@@ -921,6 +920,8 @@ module Generate (Target : Target_sig.S) = struct
921
920
| _ -> Structure. is_merge_node g pc'
922
921
in
923
922
let code ~context =
923
+ let block = Addr.Map. find pc ctx.blocks in
924
+ let * () = translate_instrs ctx context block.body in
924
925
translate_node_within
925
926
~result_typ
926
927
~fall_through
@@ -965,7 +966,6 @@ module Generate (Target : Target_sig.S) = struct
965
966
translate_tree result_typ fall_through pc' context
966
967
| [] -> (
967
968
let block = Addr.Map. find pc ctx.blocks in
968
- let * () = translate_instrs ctx context block.body in
969
969
let branch = block.branch in
970
970
match branch with
971
971
| Branch cont -> translate_branch result_typ fall_through pc cont context
@@ -997,7 +997,7 @@ module Generate (Target : Target_sig.S) = struct
997
997
instr (Br_table (e, List. map ~f: dest l, dest a.(len - 1 )))
998
998
| Raise (x , _ ) -> (
999
999
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
1001
1001
match fall_through with
1002
1002
| `Catch -> instr (Push e)
1003
1003
| `Block _ | `Return | `Skip -> (
@@ -1082,7 +1082,7 @@ module Generate (Target : Target_sig.S) = struct
1082
1082
wrap_with_handlers
1083
1083
p
1084
1084
pc
1085
- ~result_typ: [ Value . value ]
1085
+ ~result_typ: [ Type . value ]
1086
1086
~fall_through: `Return
1087
1087
~context: []
1088
1088
(fun ~result_typ ~fall_through ~context ->
@@ -1103,7 +1103,10 @@ module Generate (Target : Target_sig.S) = struct
1103
1103
| None -> Option. map ~f: (fun name -> name ^ " .init" ) unit_name
1104
1104
| Some _ -> None )
1105
1105
; 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 ))
1107
1110
; param_names
1108
1111
; locals
1109
1112
; body
@@ -1112,7 +1115,7 @@ module Generate (Target : Target_sig.S) = struct
1112
1115
1113
1116
let init_function ~context ~to_link =
1114
1117
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
1116
1119
let locals, body =
1117
1120
function_body
1118
1121
~context
@@ -1288,7 +1291,7 @@ module G = Generate (Gc_target)
1288
1291
1289
1292
let init = G. init
1290
1293
1291
- let start () = make_context ~value_type: Gc_target.Value . value
1294
+ let start () = make_context ~value_type: Gc_target.Type . value
1292
1295
1293
1296
let f ~context ~unit_name p ~live_vars ~in_cps ~deadcode_sentinal =
1294
1297
let t = Timer. make () in
0 commit comments