Skip to content

Commit f017f10

Browse files
committed
add probes for profiling
1 parent 5e55444 commit f017f10

File tree

9 files changed

+82
-94
lines changed

9 files changed

+82
-94
lines changed

jscomp/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,25 +380,25 @@ force-snapshotml:
380380
make snapshotml
381381

382382
bin/bsppx.ml:./bin/bspack.exe
383-
BS_DEBUG=false $< -bs-MD -prelude-str 'module Config = Config_bsppx' -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing/ -I common -I ext -I syntax -I core -bs-main Bsppx_main -o $@
383+
unset BS_DEBUG; $< -bs-MD -prelude-str 'module Config = Config_bsppx' -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing/ -I common -I ext -I syntax -I core -bs-main Bsppx_main -o $@
384384

385385
bin/whole_compiler.ml:./bin/bspack.exe
386-
BS_DEBUG=false $< -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Js_main -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/typing/ -I ../ocaml/bytecomp/ -I ../ocaml/driver/ -I stubs -I ext -I syntax -I depends -I common -I core
386+
unset BS_DEBUG; $< -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Js_main -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/typing/ -I ../ocaml/bytecomp/ -I ../ocaml/driver/ -I stubs -I ext -I syntax -I depends -I common -I core
387387

388388
bin/bsdep.ml:./bin/bspack.exe
389-
BS_DEBUG=false BS_OCAMLDEP=true $< -bs-MD -prelude-str 'module Config = Config_bsdep' -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/driver -I ../ocaml/tools -I common -I ext -I syntax -I depends -I core -I stubs -bs-main Ocamldep -o $@
389+
unset BS_DEBUG; BS_OCAMLDEP=true $< -bs-MD -prelude-str 'module Config = Config_bsdep' -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/driver -I ../ocaml/tools -I common -I ext -I syntax -I depends -I core -I stubs -bs-main Ocamldep -o $@
390390

391391
bin/bsb_helper.ml:./bin/bspack.exe
392-
BS_DEBUG=false $< -bs-MD -I stubs -I common -I ext -I syntax -I depends -I bsb -bs-main Bsb_helper_main -o $@
392+
unset BS_DEBUG; $< -bs-MD -I stubs -I common -I ext -I syntax -I depends -I bsb -bs-main Bsb_helper_main -o $@
393393

394394
bin/bsb.ml:./bin/bspack.exe
395-
BS_DEBUG=false $< -bs-MD -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -bs-main Bsb_main -o $@
395+
unset BS_DEBUG; $< -bs-MD -I stubs -I common -I ext -I syntax -I depends -I bsb -I ext -bs-main Bsb_main -o $@
396396

397397
bin/bspp.ml:./bin/bspack.exe
398-
BS_DEBUG=false BS_MIN_LEX_DEPS=true $< -bs-MD -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing?parser -I common -I ext -I syntax -I depends -I bspp -I core -bs-main Bspp_main -o $@
398+
unset BS_DEBUG; BS_MIN_LEX_DEPS=true $< -bs-MD -bs-exclude-I config -I ../ocaml/utils/ -I ../ocaml/parsing?parser -I common -I ext -I syntax -I depends -I bspp -I core -bs-main Bspp_main -o $@
399399

400400
bin/js_compiler.ml:./bin/bspack.exe
401-
BS_DEBUG=false BS_COMPILER_IN_BROWSER=true bspack.exe -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Jsoo_main -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/typing/ -I ../ocaml/bytecomp/ -I ../ocaml/driver/ -I ext -I syntax -I depends -I common -I core
401+
unset BS_DEBUG; BS_COMPILER_IN_BROWSER=true bspack.exe -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Jsoo_main -I ../ocaml/utils/ -I ../ocaml/parsing/ -I ../ocaml/typing/ -I ../ocaml/bytecomp/ -I ../ocaml/driver/ -I ext -I syntax -I depends -I common -I core
402402

403403
bin/all_ounit_tests.ml:./bin/bspack.exe
404404
$< -bs-MD -I ounit -I ounit_tests -I stubs -I bsb -I common -I ext -I syntax -I depends -I bspp -I core -bs-main Ounit_tests_main -o $@

jscomp/all.depend

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ core/lam_compile_const.cmx : core/lam_compile_util.cmx \
404404
core/lam_inner.cmx : core/lam.cmx core/lam_inner.cmi
405405
core/lam_util.cmx : ext/literals.cmx core/lam_stats.cmx core/lam_print.cmx \
406406
core/lam_analysis.cmx core/lam.cmx common/js_config.cmx ext/ident_set.cmx \
407-
ext/ident_map.cmx ext/ident_hashtbl.cmx ext/ext_list.cmx \
408-
ext/ext_filename.cmx ext/ext_array.cmx core/lam_util.cmi
407+
ext/ident_map.cmx ext/ident_hashtbl.cmx common/ext_log.cmx \
408+
ext/ext_list.cmx ext/ext_filename.cmx ext/ext_array.cmx core/lam_util.cmi
409409
core/lam_group.cmx : core/lam_print.cmx core/lam.cmx core/lam_group.cmi
410410
core/lam_pass_deep_flatten.cmx : core/lam_util.cmx core/lam_group.cmx \
411411
core/lam.cmx core/js_number.cmx ext/ident_set.cmx \
@@ -466,7 +466,8 @@ core/js_dump.cmx : ext/literals.cmx core/lam_module_ident.cmx \
466466
ext/ident_set.cmx ext/ext_string.cmx ext/ext_pp_scope.cmx ext/ext_pp.cmx \
467467
ext/ext_list.cmx ext/ext_ident.cmx common/bs_version.cmx core/js_dump.cmi
468468
core/js_pass_debug.cmx : core/js_dump.cmx common/js_config.cmx core/j.cmx \
469-
ext/ext_pervasives.cmx ext/ext_filename.cmx core/js_pass_debug.cmi
469+
ext/ext_pervasives.cmx common/ext_log.cmx ext/ext_filename.cmx \
470+
core/js_pass_debug.cmi
470471
core/js_of_lam_option.cmx : core/js_exp_make.cmx common/js_config.cmx \
471472
core/js_analyzer.cmx core/j.cmx core/js_of_lam_option.cmi
472473
core/js_output.cmx : core/lam_compile_defs.cmx core/lam_analysis.cmx \

jscomp/bin/whole_compiler.ml

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70356,20 +70356,10 @@ let log_counter = ref 0
7035670356

7035770357

7035870358
let dump env ext lam =
70359-
70360-
if Js_config.is_same_file ()
70361-
then
70362-
(* ATTENTION: easy to introduce a bug during refactoring when forgeting `begin` `end`*)
70363-
begin
70364-
incr log_counter;
70365-
Lam_print.seriaize env
70366-
(Ext_filename.chop_extension
70367-
~loc:__LOC__
70368-
(Js_config.get_current_file ()) ^
70369-
(Printf.sprintf ".%02d%s.lam" !log_counter ext)
70370-
) lam;
70371-
end;
70372-
lam
70359+
70360+
lam
70361+
70362+
7037370363

7037470364

7037570365

@@ -83528,20 +83518,8 @@ end = struct
8352883518
let log_counter = ref 0
8352983519

8353083520
let dump name (prog : J.program) =
83531-
83532-
begin
83533-
let () =
83534-
if Js_config.is_same_file ()
83535-
then
83536-
begin
83537-
incr log_counter ;
83538-
Ext_pervasives.with_file_as_chan
83539-
(Ext_filename.chop_extension ~loc:__LOC__ (Js_config.get_current_file()) ^
83540-
(Printf.sprintf ".%02d.%s.jsx" !log_counter name)
83541-
) (fun chan -> Js_dump.dump_program prog chan )
83542-
end in
83543-
prog
83544-
end
83521+
83522+
prog
8354583523

8354683524

8354783525

@@ -96982,12 +96960,14 @@ let compile ~filename output_prefix env _sigs
9698296960
in
9698396961
let maybe_pure = no_side_effects rest
9698496962
in
96963+
9698596964
let body =
9698696965
rest
9698796966
|> List.map (fun group -> compile_group meta group)
9698896967
|> Js_output.concat
9698996968
|> Js_output.to_block
9699096969
in
96970+
9699196971
(* The file is not big at all compared with [cmo] *)
9699296972
(* Ext_marshal.to_file (Ext_filename.chop_extension filename ^ ".mj") js; *)
9699396973
let js =

jscomp/core/js_pass_debug.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@
3030
let log_counter = ref 0
3131

3232
let dump name (prog : J.program) =
33-
#if BS_COMPILER_IN_BROWSER then
33+
#if BS_COMPILER_IN_BROWSER || (undefined BS_DEBUG) then
3434
prog
35-
#else
35+
#else
3636
begin
3737
let () =
3838
if Js_config.is_same_file ()
3939
then
4040
begin
4141
incr log_counter ;
42+
Ext_log.dwarn __LOC__ "\n@[[TIME:]%s: %f@]@." name (Sys.time () *. 1000.);
4243
Ext_pervasives.with_file_as_chan
4344
(Ext_filename.chop_extension ~loc:__LOC__ (Js_config.get_current_file()) ^
4445
(Printf.sprintf ".%02d.%s.jsx" !log_counter name)

jscomp/core/lam_compile_group.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,18 @@ let compile ~filename output_prefix env _sigs
303303
in
304304
let maybe_pure = no_side_effects rest
305305
in
306+
#if BS_DEBUG then
307+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Pre-compile: %f@]@." (Sys.time () *. 1000.) in
308+
#end
306309
let body =
307310
rest
308311
|> List.map (fun group -> compile_group meta group)
309312
|> Js_output.concat
310313
|> Js_output.to_block
311314
in
315+
#if BS_DEBUG then
316+
let () = Ext_log.dwarn __LOC__ "\n@[[TIME:]Post-compile: %f@]@." (Sys.time () *. 1000.) in
317+
#end
312318
(* The file is not big at all compared with [cmo] *)
313319
(* Ext_marshal.to_file (Ext_filename.chop_extension filename ^ ".mj") js; *)
314320
let js =
@@ -370,7 +376,7 @@ let lambda_as_module
370376
begin
371377
Js_config.set_current_file filename ;
372378
#if BS_DEBUG then
373-
Js_config.set_debug_file "test_include.ml";
379+
Js_config.set_debug_file "gpr_1150.ml";
374380
#end
375381
let lambda_output = compile ~filename output_prefix env sigs lam in
376382
let (//) = Filename.concat in

jscomp/core/lam_util.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,15 @@ let log_counter = ref 0
276276

277277

278278
let dump env ext lam =
279-
#if BS_COMPILER_IN_BROWSER then
279+
#if BS_COMPILER_IN_BROWSER || (undefined BS_DEBUG) then
280280
lam
281-
#else
281+
#else
282282
if Js_config.is_same_file ()
283283
then
284284
(* ATTENTION: easy to introduce a bug during refactoring when forgeting `begin` `end`*)
285285
begin
286286
incr log_counter;
287+
Ext_log.dwarn __LOC__ "\n@[[TIME:]%s: %f@]@." ext (Sys.time () *. 1000.);
287288
Lam_print.seriaize env
288289
(Ext_filename.chop_extension
289290
~loc:__LOC__
@@ -292,7 +293,9 @@ let dump env ext lam =
292293
) lam;
293294
end;
294295
lam
295-
#end
296+
#end
297+
298+
296299

297300

298301

jscomp/test/.depend

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ gpr496_test.cmj : ../stdlib/pervasives.cmj mt.cmj ../runtime/js.cmj
183183
gpr_1063_test.cmj :
184184
gpr_1072.cmj : ../runtime/js.cmj
185185
gpr_1072_reg.cmj :
186-
gpr_1150.cmj : ../stdlib/array.cmj
186+
gpr_1150.cmj :
187187
gpr_1154_test.cmj : mt.cmj ../stdlib/int64.cmj
188188
gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi
189189
gpr_441.cmj :

jscomp/test/gpr_1150.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
'use strict';
22

3-
var $$Array = require("../../lib/js/array");
4-
var Pervasives = require("../../lib/js/pervasives");
53

6-
function print_arr(foo) {
7-
return $$Array.iter(Pervasives.print_int, foo);
8-
}
94

10-
exports.print_arr = print_arr;
115
/* No side effect */

jscomp/test/gpr_1150.ml

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,75 @@
33
44
*)
55

6-
let print_arr foo = Array.iter print_int foo
6+
77

88
(*
99
let f children =
1010
match children with
11-
| [] -> print_arr [||]
11+
| [] -> [||]
1212
| a0::children ->
1313
match children with
14-
| [] -> print_arr [|a0|]
14+
| [] -> [|a0|]
1515
| a1 :: children ->
1616
match children with
17-
| [] -> print_arr [|a0;a1|]
17+
| [] -> [|a0;a1|]
1818
| a2:: children ->
1919
match children with
20-
| [] -> print_arr [|a0;a1;a2|]
20+
| [] -> [|a0;a1;a2|]
2121
| a3::children ->
2222
match children with
23-
| [] -> print_arr [|a0;a1;a2;a3|]
23+
| [] -> [|a0;a1;a2;a3|]
2424
| a4::children ->
2525
match children with
26-
| [] -> print_arr [|a0;a1;a2;a3;a4|]
26+
| [] -> [|a0;a1;a2;a3;a4|]
2727
| a5::children ->
2828
match children with
29-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5|]
29+
| [] -> [|a0;a1;a2;a3;a4;a5|]
3030
| a6::children ->
3131
match children with
32-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6|]
32+
| [] -> [|a0;a1;a2;a3;a4;a5;a6|]
3333
| a7:: children ->
3434
match children with
35-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6; a7|]
35+
| [] -> [|a0;a1;a2;a3;a4;a5;a6; a7|]
3636
| a8::children ->
3737
match children with
38-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8|]
38+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8|]
3939
| a9::children ->
4040
match children with
41-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9|]
41+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9|]
4242
| a10::children ->
4343
match children with
44-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10|]
44+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10|]
4545
| a11::children ->
4646
match children with
47-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11|]
47+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11|]
4848
| a12::children ->
4949
match children with
50-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12|]
50+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12|]
5151
| a13::children ->
5252
match children with
53-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13|]
53+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13|]
5454
| a14::children ->
5555
match children with
56-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14|]
56+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14|]
5757
| a15::children ->
5858
match children with
59-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15|]
59+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15|]
6060
| a16::children ->
61+
assert false
62+
*)
63+
(*
6164
match children with
62-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16|]
65+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16|]
6366
| a17::children ->
6467
match children with
65-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17|]
68+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17|]
6669
| a18::children ->
6770
match children with
68-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18|]
71+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18|]
6972
| a19::children ->
7073
match children with
71-
| [] -> print_arr [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18;a19|]
74+
| [] -> [|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18;a19|]
7275
| _ -> assert false
7376
7477
*)
@@ -84,52 +87,52 @@ let f children =
8487
(*
8588
let f children =
8689
match children with
87-
| [] -> print_arr [||]
88-
| a::[] -> print_arr [|a|]
89-
| a::b::[] -> print_arr [|a;b|]
90-
| a::b::c::[] -> print_arr [|a;b;c|]
90+
| [] -> [||]
91+
| a::[] -> [|a|]
92+
| a::b::[] -> [|a;b|]
93+
| a::b::c::[] -> [|a;b;c|]
9194
| a::b::c::d::[] ->
92-
print_arr [|a;b;c;d|]
95+
[|a;b;c;d|]
9396
| a::b::c::d::e::[] ->
94-
print_arr [|a;b;c;d;e|]
97+
[|a;b;c;d;e|]
9598
| a::b::c::d::e::f::[] ->
96-
print_arr [|a;b;c;d;e;f|]
99+
[|a;b;c;d;e;f|]
97100
| a::b::c::d::e::f::g::[] ->
98-
print_arr [|a;b;c;d;e;f;g|]
101+
[|a;b;c;d;e;f;g|]
99102
| a::b::c::d::e::f::g::h::[] ->
100-
print_arr [|a;b;c;d;e;f;g;h|]
103+
[|a;b;c;d;e;f;g;h|]
101104
| a::b::c::d::e::f::g::h::i::[] ->
102-
print_arr [|a;b;c;d;e;f;g;h;i|]
105+
[|a;b;c;d;e;f;g;h;i|]
103106
| a::b::c::d::e::f::g::h::i::j::[] ->
104-
print_arr [|a;b;c;d;e;f;g;h;i;j|]
107+
[|a;b;c;d;e;f;g;h;i;j|]
105108
| a::b::c::d::e::f::g::h::i::j::k::[] ->
106-
print_arr [|a;b;c;d;e;f;g;h;i;j;k|]
109+
[|a;b;c;d;e;f;g;h;i;j;k|]
107110
| a::b::c::d::e::f::g::h::i::j::k::l::[] ->
108-
print_arr
111+
109112
[|a;b;c;d;e;f;g;h;i;j;k;l|]
110113
| a::b::c::d::e::f::g::h::i::j::k::l::m::[] ->
111-
print_arr
114+
112115
[|a;b;c;d;e;f;g;h;i;j;k;l;m|]
113116
| a::b::c::d::e::f::g::h::i::j::k::l::m::n::[] ->
114-
print_arr
117+
115118
[|a;b;c;d;e;f;g;h;i;j;k;l;m;n|]
116119
| a::b::c::d::e::f::g::h::i::j::k::l::m::n::o::[] ->
117-
print_arr
120+
118121
[|a;b;c;d;e;f;g;h;i;j;k;l;m;n;o|]
119122
| a::b::c::d::e::f::g::h::i::j::k::l::m::n::o::p::[] ->
120-
print_arr
123+
121124
[|a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p|]
122125
| a::b::c::d::e::f::g::h::i::j::k::l::m::n::o::p::q::[] ->
123-
print_arr
126+
124127
[|a;b;c;d;e;f;g;h;i;j;k;l;m;n;o;p;q|]
125128
| a0::a1::a2::a3::a4::a5::a6::a7::a8::a9::a10::a11::a12::a13::a14::a15::a16::a17::[] ->
126-
print_arr
129+
127130
[|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17|]
128131
| a0::a1::a2::a3::a4::a5::a6::a7::a8::a9::a10::a11::a12::a13::a14::a15::a16::a17::a18::[] ->
129-
print_arr
132+
130133
[|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18|]
131134
| a0::a1::a2::a3::a4::a5::a6::a7::a8::a9::a10::a11::a12::a13::a14::a15::a16::a17::a18::a19::[] ->
132-
print_arr
135+
133136
[|a0;a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15;a16;a17;a18;a19|]
134137
135138
| _ ->

0 commit comments

Comments
 (0)