Skip to content

Commit 3f3a295

Browse files
committed
fix ci
1 parent c08f7c2 commit 3f3a295

File tree

91 files changed

+559
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+559
-592
lines changed

jscomp/core/js_dump.ml

+7-22
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,15 @@ let continue f s =
216216
P.space f ;
217217
P.string f s;
218218
semi f
219-
let rec formal_parameter_list cxt (f : P.t) (is_method : bool) (l : Ident.t list) (env : Js_fun_env.t) =
220-
let offset = if is_method then 1 else 0 in
221-
let rec aux i cxt l =
222-
match l with
223-
| [] -> cxt
224-
| [id] -> ipp_ident cxt f id (Js_fun_env.get_unused env i)
225-
| id :: r ->
226-
let cxt = ipp_ident cxt f id (Js_fun_env.get_unused env i) in
227-
comma_sp f;
228-
aux (i + 1) cxt r in
229-
match l with
230-
| [] -> cxt
231-
| [i] ->
232-
(** necessary, since some js libraries like [mocha]...*)
233-
if Js_fun_env.get_unused env offset then cxt
234-
(* FIXME: maye we dont need such ad-hoc optmization
235-
it was bought to address arity zero issue which is no longer
236-
needed *)
237-
else
238-
Ext_pp_scope.ident cxt f i
239-
| _ ->
240-
aux offset cxt l
241219

242220

221+
let formal_parameter_list cxt f is_method l env =
222+
match l with
223+
| [x] when
224+
Js_fun_env.get_unused env (if is_method then 1 else 0) ->
225+
cxt
226+
| _ ->
227+
iter_lst cxt f l Ext_pp_scope.ident comma_sp
243228
(* IdentMap *)
244229
(*
245230
f/122 -->

jscomp/core/js_pass_flatten.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@
2727

2828

2929

30-
31-
30+
(* open recursion is hard
31+
Take cond for example:
32+
CHECK? Trick semantics difference
33+
super#statement (S.if_ a ([ (\* self#statement *\) (S.exp b) ])
34+
~else_:([self#statement (S.exp c)])
35+
)
36+
*)
3237
module E = Js_exp_make
3338
module S = Js_stmt_make
3439

@@ -38,15 +43,10 @@ let flatten_map =
3843
method! statement x =
3944
match x.statement_desc with
4045
| Exp ({expression_desc = Seq _; _} as v) ->
41-
(S.block ( List.rev_map (self#statement) (Js_analyzer.rev_flatten_seq v )))
46+
S.block ( List.rev_map self#statement (Js_analyzer.rev_flatten_seq v ))
4247
| Exp ({expression_desc = Cond(a,b,c); comment} ) ->
43-
(* Note that we need apply [self#statement] recursively *)
4448
{ statement_desc = If (a, [ self#statement (S.exp b)],
4549
Some [ self#statement (S.exp c)]); comment}
46-
(* CHECK? Trick semantics difference *)
47-
(* super#statement (S.if_ a ([ (\* self#statement *\) (S.exp b) ]) *)
48-
(* ~else_:([self#statement (S.exp c)]) *)
49-
(* ) *)
5050

5151
| Exp ({expression_desc = Bin(Eq, a, ({expression_desc = Seq _; _ } as v)); _} )
5252
->

jscomp/core/js_pass_flatten_and_mark_dead.ml

+3-6
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,10 @@ let subst_map name = object (self)
191191
(** If we do this, we should prevent incorrect inlning to inline it into an array :)
192192
do it only when block size is larger than one
193193
*)
194-
195194
let (_, e, bindings) =
196-
List.fold_left
197-
(fun (i,e, acc) (x : J.expression) ->
195+
Ext_list.fold_left ls (0, [], []) (fun x (i,e, acc) ->
198196
match x.expression_desc with
199-
| J.Var _ | Number _ | Str _ | J.Bool _ | Undefined
197+
| Var _ | Number _ | Str _ | J.Bool _ | Undefined
200198
-> (* TODO: check the optimization *)
201199
(i + 1, x :: e, acc)
202200
| _ ->
@@ -211,8 +209,7 @@ let subst_map name = object (self)
211209
Ext_ident.create
212210
(Printf.sprintf "%s_%03d"
213211
ident.name i) in
214-
(i + 1, E.var match_id :: e, (match_id, v') :: acc)
215-
) (0, [], []) ls in
212+
(i + 1, E.var match_id :: e, (match_id, v') :: acc)) in
216213
let e =
217214
{block with
218215
expression_desc =

jscomp/core/js_pass_tailcall_inline.ml

+48-50
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module E = Js_exp_make
4646
TODO: Ident Hashtbl could be improved,
4747
since in this case it can not be global?
4848
49-
*)
49+
*)
5050
let count_collects () =
5151
object (self)
5252
inherit Js_fold.fold as super
@@ -69,13 +69,12 @@ let count_collects () =
6969
method! variable_declaration
7070
({ident; value ; property ; ident_info } as v)
7171
=
72-
Ident_hashtbl.add defined_idents ident v;
73-
match value with
74-
| None
75-
->
76-
self
77-
| Some x
78-
-> self#expression x
72+
Ident_hashtbl.add defined_idents ident v;
73+
match value with
74+
| None ->
75+
self
76+
| Some x
77+
-> self#expression x
7978
method! ident id = self#add_use id; self
8079
method get_stats =
8180
Ident_hashtbl.iter (fun ident (v : J.variable_declaration) ->
@@ -85,16 +84,15 @@ let count_collects () =
8584
let pure =
8685
match v.value with
8786
| None -> false (* can not happen *)
88-
| Some x -> Js_analyzer.no_side_effect_expression x
89-
in
87+
| Some x -> Js_analyzer.no_side_effect_expression x in
9088
match Ident_hashtbl.find_opt stats ident with
91-
| None ->
89+
| None ->
90+
Js_op_util.update_used_stats v.ident_info
91+
(if pure then Dead_pure else Dead_non_pure)
92+
| Some num ->
93+
if !num = 1 then
9294
Js_op_util.update_used_stats v.ident_info
93-
(if pure then Dead_pure else Dead_non_pure)
94-
| Some num ->
95-
if !num = 1 then
96-
Js_op_util.update_used_stats v.ident_info
97-
(if pure then Once_pure else Used)
95+
(if pure then Once_pure else Used)
9896
) defined_idents; defined_idents
9997
end
10098

@@ -113,29 +111,29 @@ let get_stats program
113111
*)
114112

115113
(** There is a side effect when traversing dead code, since
116-
we assume that substitue a node would mark a node as dead node,
117-
114+
we assume that substitue a node would mark a node as dead node,
115+
118116
so if we traverse a dead node, this would get a wrong result.
119-
it does happen in such scenario
120-
{[
121-
let generic_basename is_dir_sep current_dir_name name =
122-
let rec find_end n =
123-
if n < 0 then String.sub name 0 1
124-
else if is_dir_sep name n then find_end (n - 1)
125-
else find_beg n (n + 1)
126-
and find_beg n p =
127-
if n < 0 then String.sub name 0 p
128-
else if is_dir_sep name n then String.sub name (n + 1) (p - n - 1)
129-
else find_beg (n - 1) p
130-
in
131-
if name = ""
132-
then current_dir_name
133-
else find_end (String.length name - 1)
134-
]}
135-
[find_beg] can potentially be expanded in [find_end] and in [find_end]'s expansion,
136-
if the order is not correct, or even worse, only the wrong one [find_beg] in [find_end] get expanded
137-
(when we forget to recursive apply), then some code non-dead [find_beg] will be marked as dead,
138-
while it is still called
117+
it does happen in such scenario
118+
{[
119+
let generic_basename is_dir_sep current_dir_name name =
120+
let rec find_end n =
121+
if n < 0 then String.sub name 0 1
122+
else if is_dir_sep name n then find_end (n - 1)
123+
else find_beg n (n + 1)
124+
and find_beg n p =
125+
if n < 0 then String.sub name 0 p
126+
else if is_dir_sep name n then String.sub name (n + 1) (p - n - 1)
127+
else find_beg (n - 1) p
128+
in
129+
if name = ""
130+
then current_dir_name
131+
else find_end (String.length name - 1)
132+
]}
133+
[find_beg] can potentially be expanded in [find_end] and in [find_end]'s expansion,
134+
if the order is not correct, or even worse, only the wrong one [find_beg] in [find_end] get expanded
135+
(when we forget to recursive apply), then some code non-dead [find_beg] will be marked as dead,
136+
while it is still called
139137
*)
140138
let subst name export_set stats =
141139
object (self)
@@ -192,29 +190,29 @@ let subst name export_set stats =
192190
{expression_desc =
193191
Call({expression_desc = Var (Id id)},args,_info)}} }
194192
as st
195-
:: rest
193+
:: rest
196194
->
197195
begin match Ident_hashtbl.find_opt stats id with
198196

199197
| Some ({ value =
200-
Some {expression_desc = Fun (false, params, block, _env) ; comment = _};
201-
(*TODO: don't inline method tail call yet,
202-
[this] semantics are weird
203-
*)
204-
property = (Alias | StrictOpt | Strict);
205-
ident_info = {used_stats = Once_pure };
206-
ident = _
207-
} as v)
198+
Some {expression_desc = Fun (false, params, block, _env) ; comment = _};
199+
(*TODO: don't inline method tail call yet,
200+
[this] semantics are weird
201+
*)
202+
property = (Alias | StrictOpt | Strict);
203+
ident_info = {used_stats = Once_pure };
204+
ident = _
205+
} as v)
208206
when Ext_list.same_length params args
209207
->
210208
(* Ext_log.dwarn __LOC__ "%s is dead \n %s " id.name *)
211209
(* (Js_dump.string_of_block [st]); *)
212210
Js_op_util.update_used_stats v.ident_info Dead_pure;
213211
let block =
214212
Ext_list.fold_right2
215-
params args ( self#block block) (* see #278 before changes*)
216-
(fun param arg acc ->
217-
S.define_variable ~kind:Variable param arg :: acc)
213+
params args ( self#block block) (* see #278 before changes*)
214+
(fun param arg acc ->
215+
S.define_variable ~kind:Variable param arg :: acc)
218216
in
219217
(* Mark a function as dead means it will never be scanned,
220218
here we inline the function

jscomp/test/and_or_tailcall_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Mt = require("./mt.js");
44
var Block = require("../../lib/js/block.js");
55

6-
function f(b, _, _n) {
6+
function f(b, x, _n) {
77
while(true) {
88
var n = _n;
99
if (n > 100000 || !b) {
@@ -15,7 +15,7 @@ function f(b, _, _n) {
1515
};
1616
}
1717

18-
function or_f(b, _, _n) {
18+
function or_f(b, x, _n) {
1919
while(true) {
2020
var n = _n;
2121
if (n > 100000) {

jscomp/test/bang_primitive.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function test(x, y) {
1212
];
1313
}
1414

15-
function f(x, _) {
15+
function f(x, y) {
1616
return /* tuple */[
1717
String.fromCharCode.apply(null, x),
1818
0

jscomp/test/bs_array_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ b("File \"bs_array_test.ml\", line 274, characters 4-11", (Belt_Array.forEachWit
12151215
return /* () */0;
12161216
})), c$1[0] === 6));
12171217

1218-
function id$1(_, x) {
1218+
function id$1(loc, x) {
12191219
var u = x.slice(0);
12201220
return eq("File \"bs_array_test.ml\", line 284, characters 5-12", Belt_Array.reverse(x), (Belt_Array.reverseInPlace(u), u));
12211221
}

jscomp/test/bs_auto_uncurry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function f_02(xs) {
5151
}));
5252
}
5353

54-
function f_03(_, u) {
54+
function f_03(xs, u) {
5555
return hi((function () {
5656
return Curry._1(u, /* () */0);
5757
}));

jscomp/test/bs_list_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ function mod2(x) {
430430
return x % 2 === 0;
431431
}
432432

433-
function evenIndex(_, i) {
433+
function evenIndex(_x, i) {
434434
return i % 2 === 0;
435435
}
436436

jscomp/test/bs_poly_map_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function emptyMap() {
4040
}
4141

4242
function mergeInter(s1, s2) {
43-
var m = Belt_Map.merge(s1, s2, (function (_, v1, v2) {
43+
var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) {
4444
if (v1 !== undefined && v2 !== undefined) {
4545
return /* () */0;
4646
}
@@ -51,7 +51,7 @@ function mergeInter(s1, s2) {
5151
}
5252

5353
function mergeUnion(s1, s2) {
54-
var m = Belt_Map.merge(s1, s2, (function (_, v1, v2) {
54+
var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) {
5555
if (v1 !== undefined || v2 !== undefined) {
5656
return /* () */0;
5757
}
@@ -62,7 +62,7 @@ function mergeUnion(s1, s2) {
6262
}
6363

6464
function mergeDiff(s1, s2) {
65-
var m = Belt_Map.merge(s1, s2, (function (_, v1, v2) {
65+
var m = Belt_Map.merge(s1, s2, (function (k, v1, v2) {
6666
if (v1 !== undefined && v2 === undefined) {
6767
return /* () */0;
6868
}

jscomp/test/bs_unwrap_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ console.log(6, undefined);
5050

5151
console.log(7, Js_primitive.option_get_unwrap((console.log("trace"), undefined)));
5252

53-
function dyn_log3(prim, prim$1, _) {
53+
function dyn_log3(prim, prim$1, prim$2) {
5454
console.log(prim[1], prim$1 !== undefined ? Js_primitive.valFromOption(prim$1)[1] : undefined);
5555
return /* () */0;
5656
}

jscomp/test/caml_format_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var of_string = /* array */[
8585
];
8686

8787
function from_float_of_string(xs) {
88-
return $$Array.mapi((function (_, _$1) {
88+
return $$Array.mapi((function (i, param) {
8989
return Pervasives.string_of_float;
9090
}), xs);
9191
}

0 commit comments

Comments
 (0)