diff --git a/compiler/lib-wasm/generate.ml b/compiler/lib-wasm/generate.ml index 2c1914e1..63fd81e2 100644 --- a/compiler/lib-wasm/generate.ml +++ b/compiler/lib-wasm/generate.ml @@ -1171,10 +1171,10 @@ let init () = [ "caml_ensure_stack_capacity", "%identity" ; "caml_process_pending_actions_with_root", "%identity" ; "caml_callback", "caml_trampoline" - ; "caml_array_of_uniform_array", "caml_make_array" + ; "caml_make_array", "caml_array_of_uniform_array" ] in - Primitive.register "caml_make_array" `Mutable None None; + Primitive.register "caml_array_of_uniform_array" `Mutable None None; let l = if Config.Flag.effects () then ("caml_alloc_stack", "caml_cps_alloc_stack") :: l diff --git a/compiler/lib/flow.ml b/compiler/lib/flow.ml index 799027de..db0f60ca 100644 --- a/compiler/lib/flow.ml +++ b/compiler/lib/flow.ml @@ -198,7 +198,7 @@ let rec block_escape st x = | Immutable -> () | Maybe_mutable -> Code.Var.ISet.add st.possibly_mutable y); Array.iter l ~f:(fun z -> block_escape st z) - | Expr (Prim (Extern "caml_make_array", [ Pv y ])) -> block_escape st y + | Expr (Prim (Extern "caml_array_of_uniform_array", [ Pv y ])) -> block_escape st y | _ -> Code.Var.ISet.add st.possibly_mutable y)) (Var.Tbl.get st.known_origins x) @@ -208,7 +208,7 @@ let expr_escape st _x e = | Apply { args; _ } -> List.iter args ~f:(fun x -> block_escape st x) | Prim (Array_get, [ Pv x; _ ]) -> block_escape st x | Prim ((Vectlength | Array_get | Not | IsInt | Eq | Neq | Lt | Le | Ult), _) -> () - | Prim (Extern "caml_make_array", [ Pv _ ]) -> () + | Prim (Extern "caml_array_of_uniform_array", [ Pv _ ]) -> () | Prim (Extern name, l) -> let ka = match Primitive.kind_args name with @@ -233,7 +233,7 @@ let expr_escape st _x e = | Expr (Constant (Tuple _)) -> () | Expr (Block (_, a, _, _)) -> Array.iter a ~f:(fun x -> block_escape st x) - | Expr (Prim (Extern "caml_make_array", [ Pv y ])) -> ( + | Expr (Prim (Extern "caml_array_of_uniform_array", [ Pv y ])) -> ( match st.defs.(Var.idx y) with | Expr (Block (_, a, _, _)) -> Array.iter a ~f:(fun x -> block_escape st x) @@ -416,7 +416,7 @@ let the_native_string_of ~target info x = let the_block_contents_of info x = match the_def_of info x with | Some (Block (_, a, _, _)) -> Some a - | Some (Prim (Extern "caml_make_array", [ x ])) -> ( + | Some (Prim (Extern "caml_array_of_uniform_array", [ x ])) -> ( match the_def_of info x with | Some (Block (_, a, _, _)) -> Some a | _ -> None) diff --git a/runtime/wasm/array.wat b/runtime/wasm/array.wat index 6628b7d2..00d01e80 100644 --- a/runtime/wasm/array.wat +++ b/runtime/wasm/array.wat @@ -80,7 +80,8 @@ (if (i32.eqz (local.get $sz)) (then (return (global.get $empty_array)))) (array.new $float_array (f64.const 0) (local.get $sz))) - (func (export "caml_make_array") (param $vinit (ref eq)) (result (ref eq)) + (func (export "caml_array_of_uniform_array") + (param $vinit (ref eq)) (result (ref eq)) (local $init (ref $block)) (local $res (ref $float_array)) (local $size i32) (local $i i32) (local.set $init (ref.cast (ref $block) (local.get $vinit)))