Skip to content

Commit 9290e45

Browse files
committed
remove Lsend in lambda IR
1 parent cac9bdc commit 9290e45

28 files changed

+38
-441
lines changed

jscomp/core/lam.ml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module Types = struct
131131
| Lwhile of t * t
132132
| Lfor of ident * t * t * Asttypes.direction_flag * t
133133
| Lassign of ident * t
134-
| Lsend of Lam_compat.meth_kind * t * t * t list * Location.t
134+
(* | Lsend of Lam_compat.meth_kind * t * t * t list * Location.t *)
135135
end
136136

137137
module X = struct
@@ -187,7 +187,7 @@ module X = struct
187187
| Lwhile of t * t
188188
| Lfor of ident * t * t * Asttypes.direction_flag * t
189189
| Lassign of ident * t
190-
| Lsend of Lam_compat.meth_kind * t * t * t list * Location.t
190+
(* | Lsend of Lam_compat.meth_kind * t * t * t list * Location.t *)
191191
end
192192
include Types
193193

@@ -258,11 +258,11 @@ let inner_map
258258
| Lassign(id, e) ->
259259
let e = f e in
260260
Lassign(id,e)
261-
| Lsend (k, met, obj, args, loc) ->
261+
(* | Lsend (k, met, obj, args, loc) ->
262262
let met = f met in
263263
let obj = f obj in
264264
let args = Ext_list.map args f in
265-
Lsend(k,met,obj,args,loc)
265+
Lsend(k,met,obj,args,loc) *)
266266

267267

268268

@@ -415,7 +415,6 @@ let rec
415415
| Lstaticcatch _
416416
| Ltrywith _
417417
| Lfor (_,_,_,_,_)
418-
| Lsend _
419418
-> false
420419
and eq_option l1 l2 =
421420
match l1 with
@@ -487,8 +486,6 @@ let for_ v e1 e2 dir e3 : t =
487486
Lfor(v,e1,e2,dir,e3)
488487

489488
let assign v l : t = Lassign(v,l)
490-
let send u m o ll v : t =
491-
Lsend(u, m, o, ll, v)
492489
let staticcatch a b c : t = Lstaticcatch(a,b,c)
493490
let staticraise a b : t = Lstaticraise(a,b)
494491

jscomp/core/lam.mli

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ and t = private
9696
| Lwhile of t * t
9797
| Lfor of ident * t * t * Asttypes.direction_flag * t
9898
| Lassign of ident * t
99-
| Lsend of Lambda.meth_kind * t * t * t list * Location.t
99+
(* | Lsend of Lambda.meth_kind * t * t * t list * Location.t *)
100100
(* | Levent of t * Lambda.lambda_event
101101
[Levent] in the branch hurt pattern match,
102102
we should use record for trivial debugger info
@@ -165,10 +165,6 @@ val while_ : t -> t -> t
165165
val try_ : t -> ident -> t -> t
166166
val assign : ident -> t -> t
167167

168-
val send :
169-
Lambda.meth_kind ->
170-
t -> t -> t list ->
171-
Location.t -> t
172168

173169
(** constant folding *)
174170
val prim : primitive:Lam_primitive.t -> args:t list -> Location.t -> t

jscomp/core/lam_analysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
211211
| Lwhile _ -> false (* conservative here, non-terminating loop does have side effect *)
212212
| Lfor _ -> false
213213
| Lassign _ -> false (* actually it depends ... *)
214-
| Lsend _ -> false
214+
(* | Lsend _ -> false *)
215215
| Lapply {
216216
ap_func = Lprim {primitive = Pfield (_, Fld_module {name = "from_fun"})};
217217
ap_args = [arg]}
@@ -272,7 +272,7 @@ let rec size (lam : Lam.t) =
272272
| Lwhile _ -> really_big ()
273273
| Lfor _ -> really_big ()
274274
| Lassign (_,v) -> 1 + size v (* This is side effectful, be careful *)
275-
| Lsend _ -> really_big ()
275+
(* | Lsend _ -> really_big () *)
276276

277277
with Too_big_to_inline -> 1000
278278
and size_constant x =

jscomp/core/lam_arity_analysis.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ let rec get_arity (meta : Lam_stats.t) (lam : Lam.t) : Lam_arity.t =
131131
all_lambdas meta [l2;l3]
132132
| Lsequence(_, l2) -> get_arity meta l2
133133
| Lstaticraise _ (* since it will not be in tail position *)
134-
| Lsend _
135134
-> Lam_arity.na
136135
| Lwhile _
137136
| Lfor _

jscomp/core/lam_bounded_vars.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ let rewrite (map : _ Hash_ident.t)
159159
Lam.while_ l1 l2
160160
| Lassign(v, l)
161161
-> Lam.assign v (aux l)
162-
| Lsend(u, m, o, ll, v) ->
163-
let m = aux m in
164-
let o = aux o in
165-
let ll = Ext_list.map ll aux in
166-
Lam.send u m o ll v
167162
in
168163
aux lam
169164

jscomp/core/lam_check.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ let check file lam =
9999

100100
| Lassign(_id, e) ->
101101
check_staticfails e cxt
102-
| Lsend (_k, met, obj, args, _) ->
103-
check_list (met::obj::args) cxt
104102
in
105103
let rec
106104
iter_list xs = Ext_list.iter xs iter
@@ -160,10 +158,6 @@ let check file lam =
160158
| Lassign(id, e) ->
161159
use id ;
162160
iter e
163-
| Lsend (_k, met, obj, args, _) ->
164-
iter met; iter obj;
165-
iter_list args
166-
167161
in
168162
begin
169163
check_staticfails lam Set_int.empty;

jscomp/core/lam_closure.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ let free_variables
144144
| Lassign(id, e) ->
145145
used top id ;
146146
iter top e
147-
| Lsend (_k, met, obj, args, _) ->
148-
iter sink_pos met ;
149-
iter sink_pos obj;
150-
List.iter (iter sink_pos) args in
147+
in
151148
iter Lam_var_stats.fresh_env lam ;
152149
!fv
153150

jscomp/core/lam_compile.ml

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let rec apply_with_arity_aux (fn : J.expression)
7676
let apply_with_arity ~arity fn args =
7777
apply_with_arity_aux fn arity args (List.length args)
7878

79-
let method_cache_id = ref 1 (*TODO: move to js runtime for re-entrant *)
79+
8080

8181
let change_tail_type_in_try
8282
(x : Lam_compile_context.tail_type)
@@ -1145,71 +1145,6 @@ and compile_trywith lam id catch (lambda_cxt : Lam_compile_context.t) =
11451145
mutable initializers: (obj -> unit) list }
11461146
]}
11471147
*)
1148-
and compile_send (meth_kind : Lam_compat.meth_kind)
1149-
(met : Lam.t)
1150-
(obj : Lam.t) (args : Lam.t list)
1151-
(lambda_cxt : Lam_compile_context.t) =
1152-
let new_cxt = {lambda_cxt with continuation = NeedValue Not_tail} in
1153-
match Ext_list.split_map (met :: obj :: args) (fun x ->
1154-
match x with
1155-
| Lprim {primitive = Pccall {prim_name ; _}; args = []}
1156-
(* nullary external call*)
1157-
->
1158-
[], E.var (Ext_ident.create_js prim_name)
1159-
| _ ->
1160-
match compile_lambda new_cxt x with
1161-
| {value = None} -> assert false
1162-
| {block; value = Some b} -> block, b
1163-
) with
1164-
| _, ([] | [_]) -> assert false
1165-
| (args_code, label::nobj::args)
1166-
->
1167-
let cont3 nobj k =
1168-
match Js_ast_util.named_expression nobj with
1169-
| None ->
1170-
let cont =
1171-
Js_output.output_of_block_and_expression
1172-
lambda_cxt.continuation (List.concat args_code)
1173-
in
1174-
cont (k nobj)
1175-
| Some (obj_code, v) ->
1176-
let cont2 obj_code v =
1177-
Js_output.output_of_block_and_expression
1178-
lambda_cxt.continuation
1179-
( Ext_list.concat_append args_code [obj_code]) v in
1180-
let cobj = E.var v in
1181-
cont2 obj_code (k cobj) in
1182-
match meth_kind with
1183-
| Self ->
1184-
(* TODO: horrible hack -- fixed later -- CHECK*)
1185-
cont3 nobj (fun aobj -> E.call ~info:Js_call_info.dummy
1186-
(Js_of_lam_array.ref_array
1187-
(E.array_index_by_int aobj 0l) label )
1188-
(aobj :: args))
1189-
(* [E.small_int 1] is because we use array,
1190-
when we change the runtime represenation, it needs to be adapted
1191-
*)
1192-
1193-
| Cached | Public None
1194-
(* TODO: check -- 1. js object propagate 2. js object create *)
1195-
->
1196-
let get = E.runtime_ref Js_runtime_modules.oo "caml_get_public_method" in
1197-
let cache = !method_cache_id in
1198-
let () = incr method_cache_id in
1199-
cont3 nobj (fun obj' ->
1200-
E.call ~info:Js_call_info.dummy
1201-
(E.call ~info:Js_call_info.dummy get
1202-
[obj'; label; E.small_int cache]) (obj'::args)
1203-
) (* avoid duplicated compuattion *)
1204-
1205-
1206-
| Public (Some name) ->
1207-
let cache = !method_cache_id in
1208-
incr method_cache_id ;
1209-
cont3 nobj
1210-
(fun aobj -> E.public_method_call name aobj label
1211-
(Int32.of_int cache) args )
1212-
12131148

12141149
and compile_ifthenelse
12151150
(predicate : Lam.t)
@@ -1661,5 +1596,3 @@ and compile_lambda
16611596
compile_assign id lambda lambda_cxt
16621597
| Ltrywith(lam,id, catch) -> (* generate documentation *)
16631598
compile_trywith lam id catch lambda_cxt
1664-
| Lsend(meth_kind,met, obj, args,_loc) ->
1665-
compile_send meth_kind met obj args lambda_cxt

jscomp/core/lam_convert.ml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ let exception_id_destructed (l : Lam.t) (fv : Ident.t): bool =
131131
hit e1 || hit e2
132132
| Lwhile(e1, e2) ->
133133
hit e1 || hit e2
134-
| Lsend (_k, met, obj, args, _) ->
135-
hit met || hit obj || hit_list args
136134
in hit l
137135

138136

@@ -818,7 +816,7 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
818816
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
819817
| Lassign (id, body) ->
820818
Lam.assign id (convert_aux body)
821-
| Lsend (kind, a,b,ls, loc) ->
819+
| Lsend (kind, _,b,ls, _loc) ->
822820
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
823821
(match convert_aux b with
824822
| Lprim {primitive = Pjs_unsafe_downgrade {loc}; args}
@@ -836,8 +834,8 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
836834
~args loc
837835
| _ -> assert false
838836
end
839-
| b ->
840-
Lam.send kind (convert_aux a) b (Ext_list.map ls convert_aux) loc)
837+
| _ ->
838+
assert false)
841839

842840
| Levent _ ->
843841
(* disabled by upstream*)

jscomp/core/lam_exit_count.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ let count_helper (lam : Lam.t) : collection =
8585
| Lwhile(l1, l2) -> count l1; count l2
8686
| Lfor(_, l1, l2, _dir, l3) -> count l1; count l2; count l3
8787
| Lassign(_, l) -> count l
88-
| Lsend(_, m, o, ll, _) -> count m; count o; List.iter count ll
8988
and count_default sw =
9089
match sw.sw_failaction with
9190
| None -> ()

0 commit comments

Comments
 (0)