From e52ab3aa96cbf7fb4241e3f07e5e47014312922f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Thu, 12 Dec 2024 17:18:30 +0100 Subject: [PATCH] Fix uses of `--enable=effects` in lib-wasm/ --- compiler/lib-wasm/gc_target.ml | 2 +- compiler/lib-wasm/generate.ml | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/lib-wasm/gc_target.ml b/compiler/lib-wasm/gc_target.ml index f2e6b7eccd..f7bdc62f61 100644 --- a/compiler/lib-wasm/gc_target.ml +++ b/compiler/lib-wasm/gc_target.ml @@ -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 diff --git a/compiler/lib-wasm/generate.ml b/compiler/lib-wasm/generate.ml index d5e590dff2..d9c7fcc3ab 100644 --- a/compiler/lib-wasm/generate.ml +++ b/compiler/lib-wasm/generate.ml @@ -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 @@ -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 @@ -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 @@ -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