Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
604a3b7
Wasm runtime: stub for caml_ml_set_channel_refill
vouillon Jul 10, 2025
969fcac
Wasm AST: add i32/i64.trunc_sat_f32_s/u
vouillon Oct 14, 2025
a3a5ef5
WIP caml_csel_value
vouillon Oct 16, 2025
6a5344a
Remove unix-Win32.5.2.output
vouillon Oct 16, 2025
c1d767b
Wasm runtime: provide access to JavaScript eval function
vouillon Jul 10, 2025
334b1ea
ppx_optcomp_light: mark the attribute as handled
vouillon Sep 25, 2025
7b07d04
ppx_optcomp_light: compatibility with OxCaml
vouillon Sep 25, 2025
df8a519
ppx_optcomp_light: conditional inclusion of modules in signatures
vouillon Sep 25, 2025
d05e0cb
ppx_optcomp_light: explicitly drop code
vouillon Oct 16, 2025
bc479a7
ppx_optcomp_light: add oxcaml flag
vouillon Sep 25, 2025
e953d51
OxCaml support: differences in bytecode binary format
vouillon Sep 25, 2025
c6bccdf
Require dune 3.20
vouillon Sep 25, 2025
55fd00b
Allow the ppxlib version used by oxcaml
vouillon Sep 26, 2025
259e7ff
OxCaml support: fix OCaml expect tests
vouillon Sep 26, 2025
bd002e3
OxCaml support: update tests
vouillon Sep 25, 2025
19ff8c5
OxCaml support: ppx updates
vouillon Sep 25, 2025
8d1541a
OxCaml support: some runtime changes
vouillon Sep 25, 2025
b39166d
OxCaml support: toplevel
vouillon Sep 25, 2025
02de7b8
OxCaml runtime: additional atomic primitives
vouillon Sep 25, 2025
9e0dced
OxCaml runtime: local variant of some primitives
vouillon Sep 25, 2025
bf008d5
OxCaml runtime: immutable array primitives
vouillon Sep 25, 2025
abf4c37
OxCaml runtime: Obj primitives
vouillon Jul 10, 2025
ad87495
Oxcaml runtime: GC primitives
vouillon Oct 1, 2025
b4eb163
OxCaml: null support
vouillon Jul 10, 2025
520638e
OxCaml: Float32 support
vouillon Sep 26, 2025
a8d71db
OxCaml: add tests
vouillon Sep 30, 2025
c465ab9
OxCaml: indexing by unboxed int
vouillon Jul 10, 2025
746c313
Oxcaml: add tests (indexed by unboxed int)
vouillon Oct 15, 2025
819ae66
OxCaml: add primitive caml_with_async_exns
vouillon Oct 1, 2025
2be6df2
OxCaml: small integers
vouillon Oct 16, 2025
60438ac
Oxcaml: add tests (small ints)
vouillon Oct 16, 2025
cfcf900
OxCaml: arrays of unboxed numbers
vouillon Oct 15, 2025
b6a3653
OxCaml: expose float16 <-> float conversion primitives
vouillon Oct 16, 2025
9ee5a16
FIX
vouillon Sep 30, 2025
997d349
Keep opam-dune-lint happy
vouillon Sep 30, 2025
7b62c9c
Default use_js_string to false
vouillon Sep 25, 2025
140751d
Fix toplevel compilation (missing runtime file)
vouillon Oct 1, 2025
2e166f5
OxCaml: check primitives
vouillon Sep 30, 2025
6fec446
OxCaml: setup CI
vouillon Sep 30, 2025
5940c2f
WIP: more tests
vouillon Oct 16, 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
24 changes: 24 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 @@ -152,10 +169,17 @@ jobs:
- run: opam install . --best-effort --solver builtin-mccs+glpk
if: ${{ matrix.skip-test }}

- name: Pin qcheck
run: opam pin add -n https://github.com/vouillon/qcheck.git#oxcaml
if: matrix.ocaml-compiler == 'ocaml-variants.5.2.0+ox'

- run: opam install . --deps-only --with-test
# 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
38 changes: 35 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,23 @@ 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: Pin specific packages for OxCaml
run: |
opam pin add -n https://github.com/vouillon/qcheck.git#oxcaml
opam pin add -n zarith 1.12+ox
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
50 changes: 49 additions & 1 deletion 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 All @@ -1517,7 +1564,7 @@ module Bigarray = struct
, fun x ->
let* conv =
register_import
~name:"caml_double_to_float16"
~name:"caml_float16_of_double"
(Fun { W.params = [ F64 ]; result = [ I32 ] })
in
let* x = x in
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