Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ffcab72
Avoid duplicating information between modules Typing and Generate
vouillon Sep 30, 2025
c3ede29
Improved implementation of signbit
vouillon Sep 29, 2025
d678036
Fix static evaluation of caml_int64_float_of_bits
vouillon Oct 3, 2025
7f7dab9
WAT output: signed nan
vouillon Sep 25, 2025
a5bc2c8
Wasm runtime: provide access to JavaScript eval function
vouillon Jul 10, 2025
e76a14c
Float clean-up
vouillon Sep 30, 2025
b5b6770
Get magic number version from compiler-libs
vouillon Sep 26, 2025
32beb3b
Bigarray fix
vouillon Sep 30, 2025
7dc25f1
ppx_optcomp_light: mark the attribute as handled
vouillon Sep 25, 2025
6ec558a
ppx_optcomp_light: compatibility with OxCaml
vouillon Sep 25, 2025
6cd74dd
ppx_optcomp_light: conditional inclusion of modules in signatures
vouillon Sep 25, 2025
86769d4
ppx_optcomp_light: add oxcaml flag
vouillon Sep 25, 2025
380769c
OxCaml support: differences in bytecode binary format
vouillon Sep 25, 2025
3feec6a
Require dune 3.20
vouillon Sep 25, 2025
9a8fbb3
OxCaml support: fix OCaml expect tests
vouillon Sep 26, 2025
53c593d
OxCaml support: update tests
vouillon Sep 25, 2025
d11dae0
OxCaml support: ppx updates
vouillon Sep 25, 2025
d9d57ba
OxCaml support: some runtime changes
vouillon Sep 25, 2025
597def4
OxCaml support: toplevel
vouillon Sep 25, 2025
126818e
OxCaml runtime: additional atomic primitives
vouillon Sep 25, 2025
7b463a5
OxCaml runtime: local variant of some primitives
vouillon Sep 25, 2025
ef29206
OxCaml runtime: immutable array primitives
vouillon Sep 25, 2025
d7c4dfb
OxCaml runtime: obj primitives
vouillon Jul 10, 2025
3dc37b9
OxCaml runtime: stub for caml_ml_set_channel_refill
vouillon Jul 10, 2025
75cf4b9
OxCaml: null support
vouillon Jul 10, 2025
3a063ec
Allow the ppxlib version used by oxcaml
vouillon Sep 26, 2025
e60e972
OxCaml: Float32 support
vouillon Sep 26, 2025
34eb6f3
Oxcaml runtime: GC primitives
vouillon Oct 1, 2025
3f1af0d
OxCaml: add tests
vouillon Sep 30, 2025
bdd1ecb
FIX
vouillon Sep 30, 2025
ca665c3
Keep opam-dune-lint happy
vouillon Sep 30, 2025
d579095
OxCaml: add primitive caml_with_async_exns
vouillon Oct 1, 2025
d901a11
OxCaml: check primitives
vouillon Sep 30, 2025
c1ae613
Default use_js_string to false
vouillon Sep 25, 2025
a1a71c2
OxCaml: setup CI
vouillon Sep 30, 2025
ebcbcf5
Fix toplevel compilation (missing runtime file)
vouillon Oct 1, 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 @@ -140,6 +147,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 @@ -163,6 +180,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 @@ -82,13 +88,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 @@ -98,6 +111,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/setup-binaryen@v1.0.0
Expand All @@ -116,14 +139,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
53 changes: 48 additions & 5 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 @@ -1397,11 +1441,6 @@ module Math = struct

let fmod f g = binary "fmod" f g

let round x =
let* f = register_import ~name:"caml_round" (Fun (float_func_type 1)) in
let* x = x in
return (W.Call (f, [ x ]))

let exp2 x = power (return (W.Const (F64 2.))) x
end

Expand All @@ -1423,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 @@ -1476,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 @@ -1508,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 @@ -1560,6 +1602,7 @@ module Bigarray = struct
in
match kind with
| Float32
| Float32_t
| Float64
| Int8_signed
| Int8_unsigned
Expand Down
Loading
Loading