Skip to content

Commit edcd921

Browse files
committed
dce lambda
1 parent 23cbd99 commit edcd921

18 files changed

+22
-192
lines changed

compiler/core/js_of_lam_block.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let make_block mutable_flag (tag_info : Lam_tag_info.t) tag args =
3333

3434
let field (field_info : Lam_compat.field_dbg_info) e (i : int32) =
3535
match field_info with
36-
| Fld_tuple | Fld_array ->
36+
| Fld_tuple ->
3737
E.array_index_by_int ?comment:(Lam_compat.str_of_field_info field_info) e i
3838
| Fld_poly_var_content -> E.poly_var_value_access e
3939
| Fld_poly_var_tag -> E.poly_var_tag_access e

compiler/core/lam_analysis.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
9797
(* TODO *)
9898
| Praw_js_code _
9999
(* byte swap *)
100-
| Parraysets | Parraysetu | Poffsetref _ | Praise | Plazyforce | Psetfield _
101-
->
100+
| Parraysets | Parraysetu | Poffsetref _ | Praise | Psetfield _ ->
102101
false)
103102
| Llet (_, _, arg, body) -> no_side_effects arg && no_side_effects body
104103
| Lswitch (_, _) -> false

compiler/core/lam_compat.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ type field_dbg_info = Lambda.field_dbg_info =
7373
| Fld_extension
7474
| Fld_variant
7575
| Fld_cons
76-
| Fld_array
7776

7877
let str_of_field_info (x : field_dbg_info) : string option =
7978
match x with
80-
| Fld_array | Fld_extension | Fld_variant | Fld_cons | Fld_poly_var_tag
79+
| Fld_extension | Fld_variant | Fld_cons | Fld_poly_var_tag
8180
| Fld_poly_var_content | Fld_tuple ->
8281
None
8382
| Fld_record {name; _}

compiler/core/lam_compat.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type field_dbg_info = Lambda.field_dbg_info =
3737
| Fld_extension
3838
| Fld_variant
3939
| Fld_cons
40-
| Fld_array
4140

4241
val str_of_field_info : field_dbg_info -> string option
4342

compiler/core/lam_compile_primitive.ml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,3 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
605605
match args with
606606
| [e1] -> E.runtime_call Primitive_modules.hash "hash_final_mix" args
607607
| _ -> assert false)
608-
| Plazyforce
609-
(* FIXME: we don't inline lazy force or at least
610-
let buckle handle it
611-
*)
612-
(* let parm = Ident.create "prim" in
613-
Lfunction(Curried, [parm],
614-
Matching.inline_lazy_force (Lvar parm) Location.none)
615-
It is inlined, this should not appear here *)
616-
->
617-
assert false

compiler/core/lam_constant_convert.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ let rec convert_constant (const : Lambda.structured_constant) : Lam_constant.t =
6363
if Ext_string.is_valid_hash_number name then
6464
Const_int {i = Ext_string.hash_number_as_i32_exn name; comment = None}
6565
else Const_pointer name)
66-
| Const_float_array s -> assert false
6766
| Const_immstring s -> Const_string {s; unicode = false}
6867
| Const_block (t, xs) -> (
6968
let tag = Lambda.tag_of_tag_info t in

compiler/core/lam_convert.ml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
229229
| Pfield (id, info) -> prim ~primitive:(Pfield (id, info)) ~args loc
230230
| Psetfield (id, info) -> prim ~primitive:(Psetfield (id, info)) ~args loc
231231
| Pduprecord -> prim ~primitive:Pduprecord ~args loc
232-
| Plazyforce -> prim ~primitive:Plazyforce ~args loc
233232
| Praise _ -> prim ~primitive:Praise ~args loc
234233
| Pobjcomp x -> prim ~primitive:(Pobjcomp x) ~args loc
235234
| Pobjorder -> prim ~primitive:Pobjorder ~args loc
@@ -248,8 +247,8 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
248247
| Paddint -> prim ~primitive:Paddint ~args loc
249248
| Psubint -> prim ~primitive:Psubint ~args loc
250249
| Pmulint -> prim ~primitive:Pmulint ~args loc
251-
| Pdivint _is_safe (*FIXME*) -> prim ~primitive:Pdivint ~args loc
252-
| Pmodint _is_safe (*FIXME*) -> prim ~primitive:Pmodint ~args loc
250+
| Pdivint -> prim ~primitive:Pdivint ~args loc
251+
| Pmodint -> prim ~primitive:Pmodint ~args loc
253252
| Pandint -> prim ~primitive:Pandint ~args loc
254253
| Porint -> prim ~primitive:Porint ~args loc
255254
| Pxorint -> prim ~primitive:Pxorint ~args loc
@@ -334,11 +333,6 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
334333
| Pjs_fn_make arity -> prim ~primitive:(Pjs_fn_make arity) ~args loc
335334
| Pjs_fn_make_unit -> prim ~primitive:Pjs_fn_make_unit ~args loc
336335
| Pjs_fn_method -> prim ~primitive:Pjs_fn_method ~args loc
337-
| Pjs_unsafe_downgrade ->
338-
let primitive : Lam_primitive.t =
339-
Pjs_unsafe_downgrade {name = Ext_string.empty; setter = false}
340-
in
341-
prim ~primitive ~args loc
342336

343337
(* Does not exist since we compile array in js backend unlike native backend *)
344338

compiler/core/lam_primitive.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ type t =
4040
| Psetfield of int * Lam_compat.set_field_dbg_info
4141
(* could have field info at least for record *)
4242
| Pduprecord
43-
(* Force lazy values *)
44-
| Plazyforce
4543
(* External call *)
4644
| Pjs_call of {
4745
prim_name: string;
@@ -222,10 +220,10 @@ let eq_primitive_approx (lhs : t) (rhs : t) =
222220
| Pjs_apply | Pjs_runtime_apply | Pval_from_option | Pval_from_option_not_nest
223221
| Pundefined_to_opt | Pnull_to_opt | Pnull_undefined_to_opt | Pis_null
224222
| Pis_not_none | Psome | Psome_not_nest | Pis_undefined | Pis_null_undefined
225-
| Pimport | Ptypeof | Pfn_arity | Plazyforce | Pis_poly_var_block | Pdebugger
226-
| Pinit_mod | Pupdate_mod | Pduprecord | Pmakearray | Parraylength
227-
| Parrayrefu | Parraysetu | Parrayrefs | Parraysets | Pjs_fn_make_unit
228-
| Pjs_fn_method | Phash | Phash_mixstring | Phash_mixint | Phash_finalmix ->
223+
| Pimport | Ptypeof | Pfn_arity | Pis_poly_var_block | Pdebugger | Pinit_mod
224+
| Pupdate_mod | Pduprecord | Pmakearray | Parraylength | Parrayrefu
225+
| Parraysetu | Parrayrefs | Parraysets | Pjs_fn_make_unit | Pjs_fn_method
226+
| Phash | Phash_mixstring | Phash_mixint | Phash_finalmix ->
229227
rhs = lhs
230228
| Pcreate_extension a -> (
231229
match rhs with

compiler/core/lam_primitive.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type t =
3636
| Pfield of int * Lambda.field_dbg_info
3737
| Psetfield of int * Lambda.set_field_dbg_info
3838
| Pduprecord
39-
| Plazyforce
4039
| Pjs_call of {
4140
(* Location.t * [loc] is passed down *)
4241
prim_name: string;

compiler/core/lam_print.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ let primitive ppf (prim : Lam_primitive.t) =
8282
let instr = "setfield " in
8383
fprintf ppf "%s%i" instr n
8484
| Pduprecord -> fprintf ppf "duprecord"
85-
| Plazyforce -> fprintf ppf "force"
8685
| Pjs_call {prim_name} -> fprintf ppf "%s[js]" prim_name
8786
| Pjs_object_create _ -> fprintf ppf "[js.obj]"
8887
| Praise -> fprintf ppf "raise"

0 commit comments

Comments
 (0)