Skip to content

Commit d15f107

Browse files
committed
Harmonize command flag with the existing ones
1 parent 4f68b8c commit d15f107

File tree

8 files changed

+14
-84
lines changed

8 files changed

+14
-84
lines changed

compiler/bin-js_of_ocaml/build_fs.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ function jsoo_create_file_extern(name,content){
8080
~standalone:true
8181
~wrap_with_fun:`Iife
8282
~link:`Needed
83-
~lambda_lift_all:false
8483
~formatter:pfs_fmt
8584
~source_map:false
8685
code

compiler/bin-js_of_ocaml/cmd_arg.ml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ type t =
7878
; fs_external : bool
7979
; keep_unit_names : bool
8080
; effects : Config.effects_backend
81-
; lambda_lift_all : bool
8281
}
8382

8483
let set_param =
@@ -307,14 +306,6 @@ let options =
307306
None
308307
& info [ "effects" ] ~docv:"KIND" ~doc)
309308
in
310-
let lambda_lift_all =
311-
let doc =
312-
"Lambda-lift all functions in the compilation result. This can improve the \
313-
performance of some programs on some engines (such as V8). Ignored when effects \
314-
are enabled."
315-
in
316-
Arg.(value & flag & info [ "lambda-lift-all" ] ~doc)
317-
in
318309
let build_t
319310
common
320311
set_param
@@ -344,7 +335,6 @@ let options =
344335
js_files
345336
keep_unit_names
346337
effects
347-
lambda_lift_all
348338
shape_files =
349339
let inline_source_content = not sourcemap_don't_inline_content in
350340
let chop_extension s = try Filename.chop_extension s with Invalid_argument _ -> s in
@@ -416,7 +406,6 @@ let options =
416406
; source_map
417407
; keep_unit_names
418408
; effects
419-
; lambda_lift_all
420409
; shape_files
421410
}
422411
in
@@ -451,7 +440,6 @@ let options =
451440
$ js_files
452441
$ keep_unit_names
453442
$ effects
454-
$ lambda_lift_all
455443
$ shape_files)
456444
in
457445
Term.ret t
@@ -674,7 +662,6 @@ let options_runtime_only =
674662
; keep_unit_names = false
675663
; effects
676664
; shape_files = []
677-
; lambda_lift_all = false
678665
}
679666
in
680667
let t =

compiler/bin-js_of_ocaml/cmd_arg.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type t =
5151
; fs_external : bool
5252
; keep_unit_names : bool
5353
; effects : Config.effects_backend
54-
; lambda_lift_all : bool
5554
}
5655

5756
val options : t Cmdliner.Term.t

compiler/bin-js_of_ocaml/compile.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ let run
156156
; keep_unit_names
157157
; include_runtime
158158
; effects
159-
; lambda_lift_all
160159
; shape_files
161160
} =
162161
let source_map_base =
@@ -280,7 +279,6 @@ let run
280279
~wrap_with_fun
281280
~source_map:(source_map_enabled source_map)
282281
~formatter
283-
~lambda_lift_all
284282
code
285283
| `File, formatter ->
286284
let fs_instr1, fs_instr2 =
@@ -302,7 +300,6 @@ let run
302300
~shapes
303301
?profile
304302
~link
305-
~lambda_lift_all
306303
~wrap_with_fun
307304
~source_map:(source_map_enabled source_map)
308305
~formatter

compiler/lib/config.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ module Flag = struct
106106
let es6 = o ~name:"es6" ~default:false
107107

108108
let load_shapes_auto = o ~name:"load-shapes-auto" ~default:false
109+
110+
let lambda_lift_all = o ~name:"lambda-lift-all" ~default:false
109111
end
110112

111113
module Param = struct

compiler/lib/config.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ module Flag : sig
7676

7777
val load_shapes_auto : unit -> bool
7878

79+
val lambda_lift_all : unit -> bool
80+
7981
val enable : string -> unit
8082

8183
val disable : string -> unit

compiler/lib/driver.ml

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ let effects_and_exact_calls
156156
~keep_flow_data
157157
~deadcode_sentinal
158158
~shapes
159-
~lambda_lift_all
160159
(profile : Profile.t)
161160
p =
162161
let fast =
@@ -177,7 +176,7 @@ let effects_and_exact_calls
177176
else Deadcode.f pure_fun p
178177
in
179178
let p =
180-
match lambda_lift_all, Config.target (), Config.effects () with
179+
match Config.(Flag.lambda_lift_all (), target (), effects ()) with
181180
| true, `JavaScript, `Disabled ->
182181
let to_lift = all_functions p in
183182
let p, _ = Lambda_lifting_simple.f ~to_lift p in
@@ -715,7 +714,7 @@ let link_and_pack ?(standalone = true) ?(wrap_with_fun = `Iife) ?(link = `No) p
715714
|> pack ~wrap_with_fun ~standalone
716715
|> check_js
717716

718-
let optimize ~shapes ~profile ~keep_flow_data ~lambda_lift_all p =
717+
let optimize ~shapes ~profile ~keep_flow_data p =
719718
let deadcode_sentinal =
720719
(* If deadcode is disabled, this field is just fresh variable *)
721720
Code.Var.fresh_n "dummy"
@@ -728,12 +727,7 @@ let optimize ~shapes ~profile ~keep_flow_data ~lambda_lift_all p =
728727
| O2 -> o2
729728
| O3 -> o3)
730729
+> specialize_js_once_after
731-
+> effects_and_exact_calls
732-
~keep_flow_data
733-
~deadcode_sentinal
734-
~shapes
735-
~lambda_lift_all
736-
profile
730+
+> effects_and_exact_calls ~keep_flow_data ~deadcode_sentinal ~shapes profile
737731
+> map_fst5
738732
(match Config.target (), Config.effects () with
739733
| `JavaScript, `Disabled -> Generate_closure.f
@@ -753,26 +747,15 @@ let optimize ~shapes ~profile ~keep_flow_data ~lambda_lift_all p =
753747

754748
let optimize_for_wasm ~shapes ~profile p =
755749
let optimized_code, global_flow_data =
756-
optimize ~shapes ~profile ~keep_flow_data:true ~lambda_lift_all:false p
750+
optimize ~shapes ~profile ~keep_flow_data:true p
757751
in
758752
( optimized_code
759753
, match global_flow_data with
760754
| Some data -> data
761755
| None -> Global_flow.f ~fast:false optimized_code.program )
762756

763-
let full
764-
~standalone
765-
~wrap_with_fun
766-
~shapes
767-
~profile
768-
~link
769-
~source_map
770-
~formatter
771-
~lambda_lift_all
772-
p =
773-
let optimized_code, _ =
774-
optimize ~shapes ~profile ~keep_flow_data:false ~lambda_lift_all p
775-
in
757+
let full ~standalone ~wrap_with_fun ~shapes ~profile ~link ~source_map ~formatter p =
758+
let optimized_code, _ = optimize ~shapes ~profile ~keep_flow_data:false p in
776759
let exported_runtime = not standalone in
777760
let emit formatter =
778761
generate ~exported_runtime ~wrap_with_fun ~warn_on_unhandled_effect:standalone
@@ -792,26 +775,9 @@ let full
792775
shapes_v;
793776
emit formatter optimized_code, shapes_v
794777

795-
let full_no_source_map
796-
~formatter
797-
~shapes
798-
~standalone
799-
~wrap_with_fun
800-
~profile
801-
~link
802-
~lambda_lift_all
803-
p =
778+
let full_no_source_map ~formatter ~shapes ~standalone ~wrap_with_fun ~profile ~link p =
804779
let (_ : Source_map.info * _) =
805-
full
806-
~shapes
807-
~standalone
808-
~wrap_with_fun
809-
~profile
810-
~link
811-
~source_map:false
812-
~formatter
813-
~lambda_lift_all
814-
p
780+
full ~shapes ~standalone ~wrap_with_fun ~profile ~link ~source_map:false ~formatter p
815781
in
816782
()
817783

@@ -823,36 +789,17 @@ let f
823789
~link
824790
~source_map
825791
~formatter
826-
~lambda_lift_all
827792
p =
828-
full
829-
~standalone
830-
~wrap_with_fun
831-
~shapes
832-
~profile
833-
~link
834-
~source_map
835-
~formatter
836-
~lambda_lift_all
837-
p
793+
full ~standalone ~wrap_with_fun ~shapes ~profile ~link ~source_map ~formatter p
838794

839795
let f'
840796
?(standalone = true)
841797
?(wrap_with_fun = `Iife)
842798
?(profile = Profile.O1)
843-
?(lambda_lift_all = false)
844799
~link
845800
formatter
846801
p =
847-
full_no_source_map
848-
~formatter
849-
~shapes:false
850-
~standalone
851-
~wrap_with_fun
852-
~profile
853-
~link
854-
~lambda_lift_all
855-
p
802+
full_no_source_map ~formatter ~shapes:false ~standalone ~wrap_with_fun ~profile ~link p
856803

857804
let from_string ~prims ~debug s formatter =
858805
let p = Parse_bytecode.from_string ~prims ~debug s in
@@ -863,5 +810,4 @@ let from_string ~prims ~debug s formatter =
863810
~wrap_with_fun:`Anonymous
864811
~profile:O1
865812
~link:`No
866-
~lambda_lift_all:false
867813
p

compiler/lib/driver.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,13 @@ val f :
4343
-> link:[ `All | `All_from of string list | `Needed | `No ]
4444
-> source_map:bool
4545
-> formatter:Pretty_print.t
46-
-> lambda_lift_all:bool
4746
-> Code.program
4847
-> Source_map.info * Shape.t StringMap.t
4948

5049
val f' :
5150
?standalone:bool
5251
-> ?wrap_with_fun:[ `Iife | `Anonymous | `Named of string ]
5352
-> ?profile:Profile.t
54-
-> ?lambda_lift_all:bool
5553
-> link:[ `All | `All_from of string list | `Needed | `No ]
5654
-> Pretty_print.t
5755
-> Code.program

0 commit comments

Comments
 (0)