Skip to content

Commit

Permalink
Fix uses of --enable=effects in lib-wasm/
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon authored and OlivierNicole committed Dec 12, 2024
1 parent f25a1a6 commit e52ab3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/lib-wasm/gc_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ let post_process_function_body = Initialize_locals.f
let entry_point ~toplevel_fun =
let code =
let* () =
if Config.Flag.effects ()
if Option.is_some (Config.effects ())
then
let* f =
register_import
Expand Down
11 changes: 7 additions & 4 deletions compiler/lib-wasm/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ open Code
module W = Wasm_ast
open Code_generation

let effects () =
Option.is_some (Config.effects ())

module Generate (Target : Target_sig.S) = struct
open Target

Expand Down Expand Up @@ -237,9 +240,9 @@ module Generate (Target : Target_sig.S) = struct
| Constant c -> Constant.translate c
| Special (Alias_prim _) -> assert false
| Prim (Extern "caml_alloc_dummy_function", [ _; Pc (Int arity) ]) ->
Closure.dummy ~cps:(Config.Flag.effects ()) ~arity:(Targetint.to_int_exn arity)
Closure.dummy ~cps:(effects ()) ~arity:(Targetint.to_int_exn arity)
| Prim (Extern "caml_alloc_dummy_infix", _) ->
Closure.dummy ~cps:(Config.Flag.effects ()) ~arity:1
Closure.dummy ~cps:(effects ()) ~arity:1
| Prim (Extern "caml_get_global", [ Pc (String name) ]) ->
let* x =
let* context = get_context in
Expand Down Expand Up @@ -1177,7 +1180,7 @@ let init () =
in
Primitive.register "caml_array_of_uniform_array" `Mutable None None;
let l =
if Config.Flag.effects ()
if effects ()
then ("caml_alloc_stack", "caml_cps_alloc_stack") :: l
else l
in
Expand Down Expand Up @@ -1222,7 +1225,7 @@ let fix_switch_branches p =
let start () = make_context ~value_type:Gc_target.Value.value

let f ~context ~unit_name p ~live_vars ~in_cps ~deadcode_sentinal ~debug =
let p = if Config.Flag.effects () then fix_switch_branches p else p in
let p = if effects () then fix_switch_branches p else p in
let module G = Generate (Gc_target) in
G.f ~context ~unit_name ~live_vars ~in_cps ~deadcode_sentinal ~debug p

Expand Down

0 comments on commit e52ab3a

Please sign in to comment.