Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/js_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
skip-doc: true
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "5.3"
ocaml-name: "5.3.1+pr"
ocaml-compiler: "ocaml-variants.5.3.1+trunk"
skip-effects: false
skip-test: false
skip-doc: false
Expand Down Expand Up @@ -141,6 +142,10 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- name: patch compiler
if: matrix.ocaml-compiler == 'ocaml-variants.5.3.1+trunk'
run: opam pin ocaml-variants https://github.com/hhugo/ocaml.git#optimization-hints

# Work-around a race between reinstalling mingw-w64-shims
# (because of conf-pkg-config optional dep) and installing other
# packages that implicitly depend on mingw-w64-shims.
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jobs:
# Jane Street tests disabled for now (basement only works on Linux)
jane_street_tests: false
all_jane_street_tests: false
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "ocaml-variants.5.3.1+trunk"
separate_compilation: true
jane_street_tests: true
all_jane_street_tests: true
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "5.3"
Expand Down Expand Up @@ -99,6 +105,10 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- name: patch compiler
if: matrix.ocaml-compiler == 'ocaml-variants.5.3.1+trunk'
run: opam pin ocaml-variants https://github.com/hhugo/ocaml.git#optimization-hints

- name: Set-up Binaryen
uses: Aandreba/[email protected]
with:
Expand Down
4 changes: 4 additions & 0 deletions bench.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ RUN sudo ln -sf /usr/bin/opam-2.3 /usr/bin/opam
RUN opam remote add origin https://github.com/ocaml/opam-repository.git \
&& opam update

# Switch to patched OCaml compiler
RUN opam switch create hints ocaml-variants.5.3.1+trunk \
&& opam pin ocaml-variants https://github.com/hhugo/ocaml.git#optimization-hints

# Install node
ENV NODE_VERSION=v24.0.0-v8-canary2025030537242e55ac
ENV NODE=node-$NODE_VERSION-linux-x64
Expand Down
5 changes: 4 additions & 1 deletion benchmarks/benchmark-others/bigarrays/bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ let deltay = 40_000. /. 360. /. 3600. *. 1000.

let deltax = deltay *. cos (44. *. pi /. 180.)

let precompute tile_height tile_width tile =
let precompute
tile_height
tile_width
(tile : (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Array2.t) =
let normals =
Bigarray.(Array3.create Int8_signed C_layout) (tile_height - 2) (tile_width - 2) 3
in
Expand Down
8 changes: 5 additions & 3 deletions compiler/bin-js_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,11 @@ let run
let var_k = Code.Var.fresh () in
let var_v = Code.Var.fresh () in
Code.
[ Let (var_k, Prim (Extern "caml_jsstring_of_string", [ Pc (String k) ]))
; Let (var_v, Prim (Extern "caml_jsstring_of_string", [ Pc (String v) ]))
; Let (Var.fresh (), Prim (Extern "caml_set_static_env", [ Pv var_k; Pv var_v ]))
[ Let (var_k, Prim (Extern ("caml_jsstring_of_string", None), [ Pc (String k) ]))
; Let (var_v, Prim (Extern ("caml_jsstring_of_string", None), [ Pc (String v) ]))
; Let
( Var.fresh ()
, Prim (Extern ("caml_set_static_env", None), [ Pv var_k; Pv var_v ]) )
])
in
let output
Expand Down
26 changes: 17 additions & 9 deletions compiler/lib-wasm/gc_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ module Bigarray = struct
(Memory.wasm_struct_get ty (Memory.wasm_cast ty a) 3)
(Arith.const (Int32.of_int n))

let get_at_offset ~(kind : Typing.Bigarray.kind) a i =
let get_at_offset ~(kind : Optimization_hint.Bigarray.kind) a i =
let name, (typ : Wasm_ast.value_type), size, box =
match kind with
| Float32 ->
Expand Down Expand Up @@ -1500,7 +1500,7 @@ module Bigarray = struct

let set_at_offset ~kind a i v =
let name, (typ : Wasm_ast.value_type), size, unbox =
match (kind : Typing.Bigarray.kind) with
match (kind : Optimization_hint.Bigarray.kind) with
| Float32 ->
( "dv_set_f32"
, F32
Expand Down Expand Up @@ -1585,7 +1585,12 @@ module Bigarray = struct
let* y = unbox (Memory.wasm_array_get ~ty v (Arith.const 1l)) in
instr (W.CallInstr (f, [ ta; ofs'; y; W.GlobalGet little_endian ]))

let offset ~bound_error_index ~(layout : Typing.Bigarray.layout) ta ~indices =
let offset
~bound_error_index
~unsafe
~(layout : Optimization_hint.Bigarray.layout)
ta
~indices =
let l =
List.mapi
~f:(fun pos i ->
Expand All @@ -1598,8 +1603,11 @@ module Bigarray = struct
let dim = Code.Var.fresh () in
( (let* () = store ~typ:I32 i' i in
let* () = store ~typ:I32 dim (dimension pos ta) in
let* cond = Arith.uge (load i') (load dim) in
instr (W.Br_if (bound_error_index, cond)))
if unsafe
then return ()
else
let* cond = Arith.uge (load i') (load dim) in
instr (W.Br_if (bound_error_index, cond)))
, i'
, dim ))
indices
Expand All @@ -1622,12 +1630,12 @@ module Bigarray = struct
rem
| [] -> return (), Arith.const 0l

let get ~bound_error_index ~kind ~layout ta ~indices =
let instrs, ofs = offset ~bound_error_index ~layout ta ~indices in
let get ~bound_error_index ~unsafe ~kind ~layout ta ~indices =
let instrs, ofs = offset ~bound_error_index ~unsafe ~layout ta ~indices in
seq instrs (get_at_offset ~kind ta ofs)

let set ~bound_error_index ~kind ~layout ta ~indices v =
let instrs, ofs = offset ~bound_error_index ~layout ta ~indices in
let set ~bound_error_index ~unsafe ~kind ~layout ta ~indices v =
let instrs, ofs = offset ~bound_error_index ~unsafe ~layout ta ~indices in
seq
(let* () = instrs in
set_at_offset ~kind ta ofs v)
Expand Down
Loading
Loading