Skip to content

Commit

Permalink
Realign Driver.optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierNicole committed Oct 2, 2024
1 parent fb225da commit b16557e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions compiler/bin-wasm_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ let generate_prelude ~out_file =
Filename.gen_file out_file
@@ fun ch ->
let code, uinfo = Parse_bytecode.predefined_exceptions () in
let Driver.{ program; variable_uses; in_cps; _ } = Driver.optimize code in
let profile =
match Driver.profile 1 with
| Some p -> p
| None -> assert false
in
let Driver.{ program; variable_uses; in_cps; _ } = Driver.optimize ~profile code in
let context = Wa_generate.start () in
let debug = Parse_bytecode.Debug.create ~include_cmis:false false in
let _ =
Expand Down Expand Up @@ -294,7 +299,13 @@ let run
check_debug one;
let code = one.code in
let standalone = Option.is_none unit_name in
let Driver.{ program; variable_uses; in_cps; _ } = Driver.optimize ?profile code in
let profile =
match profile, Driver.profile 1 with
| Some p, _ -> p
| None, Some p -> p
| None, None -> assert false
in
let Driver.{ program; variable_uses; in_cps; _ } = Driver.optimize ~profile code in
let context = Wa_generate.start () in
let debug = one.debug in
let toplevel_name, generated_js =
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ let link_and_pack ?(standalone = true) ?(wrap_with_fun = `Iife) ?(link = `No) p
|> coloring
|> check_js

let optimize ?(profile = O1) p =
let optimize ~profile p =
let deadcode_sentinal =
(* If deadcode is disabled, this field is just fresh variable *)
Code.Var.fresh_n "dummy"
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/driver.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type optimized_result =
; deadcode_sentinal : Code.Var.t
}

val optimize : ?profile:profile -> Code.program -> optimized_result
val optimize : profile:profile -> Code.program -> optimized_result

val f :
?standalone:bool
Expand Down

0 comments on commit b16557e

Please sign in to comment.