Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d1ad86b
Wasm AST: add i32/i64.trunc_sat_f32_s/u
vouillon Oct 14, 2025
d9e36ab
Wasm runtime: provide access to JavaScript eval function
vouillon Jul 10, 2025
20cbf94
ppx_optcomp_light: mark the attribute as handled
vouillon Sep 25, 2025
7c65b20
ppx_optcomp_light: compatibility with OxCaml
vouillon Sep 25, 2025
e37b2be
ppx_optcomp_light: conditional inclusion of modules in signatures
vouillon Sep 25, 2025
a827a77
ppx_optcomp_light: add oxcaml flag
vouillon Sep 25, 2025
bb01581
OxCaml support: differences in bytecode binary format
vouillon Sep 25, 2025
8fe909e
Require dune 3.20
vouillon Sep 25, 2025
93b4152
OxCaml support: fix OCaml expect tests
vouillon Sep 26, 2025
c736322
OxCaml support: update tests
vouillon Sep 25, 2025
568e96e
OxCaml support: ppx updates
vouillon Sep 25, 2025
50914c4
OxCaml support: some runtime changes
vouillon Sep 25, 2025
3a49a7f
OxCaml support: toplevel
vouillon Sep 25, 2025
4b6fbc2
OxCaml runtime: additional atomic primitives
vouillon Sep 25, 2025
d5f521d
OxCaml runtime: local variant of some primitives
vouillon Sep 25, 2025
1ee0253
OxCaml runtime: immutable array primitives
vouillon Sep 25, 2025
1149f3c
OxCaml runtime: obj primitives
vouillon Jul 10, 2025
32c10fc
Wasm runtime: stub for caml_ml_set_channel_refill
vouillon Jul 10, 2025
67d5773
OxCaml: null support
vouillon Jul 10, 2025
6d583fc
Allow the ppxlib version used by oxcaml
vouillon Sep 26, 2025
2987f9e
OxCaml: Float32 support
vouillon Sep 26, 2025
36eee53
Oxcaml runtime: GC primitives
vouillon Oct 1, 2025
a24e41e
OxCaml: add tests
vouillon Sep 30, 2025
108df66
FIX
vouillon Sep 30, 2025
737225d
Keep opam-dune-lint happy
vouillon Sep 30, 2025
ecb54cc
OxCaml: add primitive caml_with_async_exns
vouillon Oct 1, 2025
d6b1121
OxCaml: check primitives
vouillon Sep 30, 2025
9cfa159
Default use_js_string to false
vouillon Sep 25, 2025
a86d31e
OxCaml: setup CI
vouillon Sep 30, 2025
523e2ce
Fix toplevel compilation (missing runtime file)
vouillon Oct 1, 2025
a051fdf
Oxcaml: add tests (indexed by unboxed int)
vouillon Oct 15, 2025
e44b89a
OxCaml: indexing by unboxed int
vouillon Jul 10, 2025
bc754dd
OxCaml: arrays of unboxed numbers
vouillon Oct 15, 2025
d2802be
FIX
vouillon Oct 15, 2025
5df3789
fixup! OxCaml: setup CI
vouillon Oct 15, 2025
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
20 changes: 20 additions & 0 deletions .github/workflows/js_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ jobs:
skip-effects: true
skip-test: true
skip-doc: true
- os: ubuntu-latest
os-name: Ubuntu
ocaml-name: "OxCaml"
ocaml-compiler: "ocaml-variants.5.2.0+ox"
skip-effects: false
skip-test: false
skip-doc: true

runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -133,6 +140,16 @@ jobs:
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
if: matrix.ocaml-compiler != 'ocaml-variants.5.2.0+ox'

- name: Set-up OxCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-repositories: |
default: https://github.com/ocaml/opam-repository.git
ox: https://github.com/oxcaml/opam-repository.git
if: matrix.ocaml-compiler == 'ocaml-variants.5.2.0+ox'

# Work-around a race between reinstalling mingw-w64-shims
# (because of conf-pkg-config optional dep) and installing other
Expand All @@ -156,6 +173,9 @@ jobs:
# Install the test dependencies
if: ${{ !matrix.skip-test }}

- name: Pin js_of_ocaml
run: opam pin . -n --with-version 6.0.1+ox

- run: opam install .
# Install the packages (without running the tests)
if: ${{ !matrix.skip-test }}
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ jobs:
separate_compilation: false
jane_street_tests: true
all_jane_street_tests: false
- os: ubuntu-latest
os-name: Ubuntu
ocaml-compiler: "ocaml-variants.5.2.0+ox"
separate_compilation: true
jane_street_tests: true
all_jane_street_tests: true

runs-on: ${{ matrix.os }}

Expand All @@ -75,13 +81,20 @@ jobs:
path: wasm_of_ocaml

- name: Checkout Jane Street opam repository
if: matrix.jane_street_tests
if: matrix.jane_street_tests && matrix.ocaml-compiler != 'ocaml-variants.5.2.0+ox'
uses: actions/checkout@v5
with:
repository: janestreet/opam-repository
ref: 2819773f29b6f6c14b918eae3cb40c8ff6b22d0e
path: janestreet/opam-repository

- name: Checkout OxCaml opam repository
if: matrix.jane_street_tests && matrix.ocaml-compiler == 'ocaml-variants.5.2.0+ox'
uses: actions/checkout@v5
with:
repository: oxcaml/opam-repository
path: janestreet/opam-repository

- name: Set-up Node.js
uses: actions/setup-node@v5
with:
Expand All @@ -91,6 +104,16 @@ jobs:
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
if: matrix.ocaml-compiler != 'ocaml-variants.5.2.0+ox'

- name: Set-up OxCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
opam-repositories: |
default: https://github.com/ocaml/opam-repository.git
ox: https://github.com/oxcaml/opam-repository.git
if: matrix.ocaml-compiler == 'ocaml-variants.5.2.0+ox'

- name: Set-up Binaryen
uses: Aandreba/[email protected]
Expand All @@ -109,14 +132,17 @@ jobs:

- name: Pin wasm_of_ocaml
working-directory: ./wasm_of_ocaml
run: opam pin . -n --with-version dev
run: opam pin . -n --with-version 6.0.1+ox

- name: Pin ppxlib
run: opam pin add ppxlib -n 0.35.0
if: matrix.ocaml-compiler != 'ocaml-variants.5.2.0+ox'

- name: Checkout Jane Street packages
if: matrix.jane_street_tests
run: |
opam repo add js janestreet/opam-repository
opam install opam-format
opam pin add ppxlib -n 0.35.0
opam exec -- dune exec --root wasm_of_ocaml tools/ci_setup.exe

- name: Pin Jane Street packages
Expand Down
1 change: 1 addition & 0 deletions compiler/bin-js_of_ocaml/check_runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let print_groups output l =
output_string output (Printf.sprintf "%s\n" name)))

let f (runtime_files, bytecode, target_env) =
Config.Flag.set "use-js-string" true;
Config.set_target `JavaScript;
Config.set_effects_backend `Disabled;
Linker.reset ();
Expand Down
2 changes: 1 addition & 1 deletion compiler/bin-js_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ let run
sm
in
let output_partial
(cmo : Cmo_format.compilation_unit)
(cmo : Ocaml_compiler.Cmo_format.t)
~standalone
~shapes
~source_map
Expand Down
2 changes: 2 additions & 0 deletions compiler/bin-js_of_ocaml/js_of_ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ let () =
| _ -> argv
in
try
with_async_exns
@@ fun () ->
match
Cmdliner.Cmd.eval_value
~catch:false
Expand Down
2 changes: 1 addition & 1 deletion compiler/bin-jsoo_minify/jsoo_minify.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let main =
Cmdliner.Cmd.v Cmd_arg.info t

let (_ : int) =
try Cmdliner.Cmd.eval ~catch:false ~argv:Sys.argv main with
try with_async_exns @@ fun () -> Cmdliner.Cmd.eval ~catch:false ~argv:Sys.argv main with
| (Match_failure _ | Assert_failure _ | Not_found) as exc ->
let backtrace = Printexc.get_backtrace () in
Format.eprintf
Expand Down
2 changes: 2 additions & 0 deletions compiler/bin-wasm_of_ocaml/wasm_of_ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ let () =
| _ -> argv
in
try
with_async_exns
@@ fun () ->
match
Cmdliner.Cmd.eval_value
~catch:false
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib-dynlink/js_of_ocaml_compiler_dynlink.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module J = Jsoo_runtime.Js

type bytecode_sections =
{ symb : Ocaml_compiler.Symtable.GlobalMap.t
; crcs : (string * Digest.t option) list
; crcs : Ocaml_compiler.Import_info.table
; prim : string list
; dlpt : string list
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let runtime =
; graphics
; hash
; ieee_754
; float32
; int64
; ints
; io
Expand Down
2 changes: 2 additions & 0 deletions compiler/lib-runtime-files/tests/all.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let%expect_test _ =
+dynlink.js
+effect.js
+fail.js
+float32.js
+format.js
+fs.js
+fs_fake.js
Expand Down Expand Up @@ -64,6 +65,7 @@ let%expect_test _ =
+domain.js
+effect.js
+fail.js
+float32.js
+format.js
+fs.js
+fs_fake.js
Expand Down
48 changes: 48 additions & 0 deletions compiler/lib-wasm/gc_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,22 @@ module Type = struct
]
})

let float32_type =
register_type "float32" (fun () ->
let* custom_operations = custom_operations_type in
let* custom = custom_type in
return
{ supertype = Some custom
; final = true
; typ =
W.Struct
[ { mut = false
; typ = Value (Ref { nullable = false; typ = Type custom_operations })
}
; { mut = false; typ = Value F32 }
]
})

let int32_type =
register_type "int32" (fun () ->
let* custom_operations = custom_operations_type in
Expand Down Expand Up @@ -884,6 +900,24 @@ module Memory = struct
in
if_mismatch

let make_float32 e =
let* custom_operations = Type.custom_operations_type in
let* float32_ops =
register_import
~name:"float32_ops"
(Global
{ mut = false; typ = Ref { nullable = false; typ = Type custom_operations } })
in
let* ty = Type.float32_type in
let* e = e in
return (W.StructNew (ty, [ GlobalGet float32_ops; e ]))

let box_float32 = make_float32

let unbox_float32 e =
let* ty = Type.float32_type in
wasm_struct_get ty (wasm_cast ty e) 1

let make_int32 ~kind e =
let* custom_operations = Type.custom_operations_type in
let* int32_ops =
Expand Down Expand Up @@ -1043,6 +1077,9 @@ module Constant = struct
| Float f ->
let* ty = Type.float_type in
return (Const, W.StructNew (ty, [ Const (F64 (Int64.float_of_bits f)) ]))
| Float32 f ->
let* e = Memory.make_float32 (return (W.Const (F32 (Int64.float_of_bits f)))) in
return (Const, e)
| Float_array l ->
let l = Array.to_list l in
let* ty = Type.float_array_type in
Expand All @@ -1060,11 +1097,18 @@ module Constant = struct
| NativeInt i ->
let* e = Memory.make_int32 ~kind:`Nativeint (return (W.Const (I32 i))) in
return (Const, e)
| Null_ ->
let* var =
register_import ~name:"null" (Global { mut = false; typ = Type.value })
in
return (Const, W.GlobalGet var)

let translate ~unboxed c =
match c with
| Code.Int i -> return (W.Const (I32 (Targetint.to_int32 i)))
| Float f when unboxed -> return (W.Const (F64 (Int64.float_of_bits f)))
| ((Float32 f) [@if oxcaml]) when unboxed ->
return (W.Const (F32 (Int64.float_of_bits f)))
| Int64 i when unboxed -> return (W.Const (I64 i))
| (Int32 i | NativeInt i) when unboxed -> return (W.Const (I32 i))
| _ -> (
Expand Down Expand Up @@ -1418,6 +1462,7 @@ module Bigarray = struct
, fun x ->
let* x = x in
return (W.F64PromoteF32 x) )
| Float32_t -> "dv_get_f32", F32, 2, Fun.id
| Float64 -> "dv_get_f64", F64, 3, Fun.id
| Int8_signed -> "dv_get_i8", I32, 0, Fun.id
| Int8_unsigned -> "dv_get_ui8", I32, 0, Fun.id
Expand Down Expand Up @@ -1471,6 +1516,7 @@ module Bigarray = struct
let* ofs = Arith.(i lsl const (Int32.of_int size)) in
match kind with
| Float32
| Float32_t
| Float64
| Int8_signed
| Int8_unsigned
Expand Down Expand Up @@ -1503,6 +1549,7 @@ module Bigarray = struct
, fun x ->
let* x = x in
return (W.F32DemoteF64 x) )
| Float32_t -> "dv_set_f32", F32, 2, Fun.id
| Float64 -> "dv_set_f64", F64, 3, Fun.id
| Int8_signed | Int8_unsigned -> "dv_set_i8", I32, 0, Fun.id
| Int16_signed | Int16_unsigned -> "dv_set_i16", I32, 1, Fun.id
Expand Down Expand Up @@ -1555,6 +1602,7 @@ module Bigarray = struct
in
match kind with
| Float32
| Float32_t
| Float64
| Int8_signed
| Int8_unsigned
Expand Down
Loading
Loading