Skip to content

Commit

Permalink
Use caml_array_of_uniform_array rather than old name caml_make_array …
Browse files Browse the repository at this point in the history
…internally
  • Loading branch information
vouillon committed Dec 3, 2024
1 parent c5d43e4 commit c5e98de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions compiler/lib-wasm/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions compiler/lib/flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion runtime/wasm/array.wat
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit c5e98de

Please sign in to comment.