Skip to content
Open
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
1 change: 0 additions & 1 deletion .github/workflows/js_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
ocaml-name:
- ""
ocaml-compiler:
- "4.13"
- "5.0"
- "5.1"
- "5.2"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
with:
token: ${{ github.token }}
- run: sh tools/make_opam_dune_lint_dir.sh
- run: opam pin -n opam-dune-lint --dev-repo
- uses: ocaml/setup-ocaml/lint-opam@v3

lint-fmt:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/wasm_of_ocaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
- name: Set-up Node.js
uses: actions/setup-node@v6
with:
node-version: latest
node-version: ${{ matrix.os == 'windows-latest' && 'latest' || 'v26.0.0-v8-canary20260216631fb6e5ef' }}

- name: Set-up OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v3
Expand Down Expand Up @@ -183,6 +183,11 @@ jobs:
working-directory: ./wasm_of_ocaml
run: opam exec -- dune build @runtest-wasm --profile with-effects

- name: Run tests with native effects
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation && matrix.os != 'windows-latest' }}
working-directory: ./wasm_of_ocaml
run: opam exec -- dune build @runtest-wasm --profile with-native-effects

- name: Run Base tests
if: matrix.all_jane_street_tests
continue-on-error: ${{ matrix.os == 'windows-latest' }}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Compiler: improved shape computation (#2198)
* Add the --build-config and --apply-build-config flags (#2177)
* Runtime/wasm: optimized some bigstring primitives (#2144)
* Wasm_of_ocaml: alternative effect implementation based on the Stack Switching proposal (#2189)

## Bug fixes
* Compiler: fix reference unboxing (#2210)
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ opam install odoc lwt_log yojson ocp-indent graphics higlo
```

**Requirements:**
- OCaml 4.13 to 5.4
- OCaml 4.14 to 5.4
- Dune 3.19+
- For wasm_of_ocaml: Binaryen 119+

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
6.4.0~alpha~dev
20 changes: 14 additions & 6 deletions compiler/bin-wasm_of_ocaml/cmd_arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let trim_trailing_dir_sep s =

let normalize_include_dirs dirs = List.map dirs ~f:trim_trailing_dir_sep

let normalize_effects (effects : [ `Disabled | `Cps | `Jspi ] option) common :
let normalize_effects (effects : [ `Disabled | `Cps | `Jspi | `Native ] option) common :
Config.effects_backend =
match effects with
| None ->
Expand All @@ -47,7 +47,7 @@ let normalize_effects (effects : [ `Disabled | `Cps | `Jspi ] option) common :
if List.mem ~eq:String.equal "effects" common.Jsoo_cmdline.Arg.optim.enable
then `Cps
else `Jspi
| Some ((`Disabled | `Cps | `Jspi) as e) -> e
| Some ((`Disabled | `Cps | `Jspi | `Native) as e) -> e

type t =
{ common : Jsoo_cmdline.Arg.t
Expand Down Expand Up @@ -182,11 +182,15 @@ let options () =
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,jspi) \
(the default), $(b,cps), or $(b,disabled)."
(the default), $(b,cps), $(b,native) or $(b,disabled)."
in
Arg.(
value
& opt (some (enum [ "jspi", `Jspi; "cps", `Cps; "disabled", `Disabled ])) None
& opt
(some
(enum
[ "jspi", `Jspi; "cps", `Cps; "native", `Native; "disabled", `Disabled ]))
None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_t
Expand Down Expand Up @@ -330,11 +334,15 @@ let options_runtime_only () =
let effects =
let doc =
"Select an implementation of effect handlers. [$(docv)] should be one of $(b,jspi) \
(the default), $(b,cps), or $(b,disabled)."
(the default), $(b,cps), $(b,native) or $(b,disabled)."
in
Arg.(
value
& opt (some (enum [ "jspi", `Jspi; "cps", `Cps; "disabled", `Disabled ])) None
& opt
(some
(enum
[ "jspi", `Jspi; "cps", `Cps; "native", `Native; "disabled", `Disabled ]))
None
& info [ "effects" ] ~docv:"KIND" ~doc)
in
let build_config = Jsoo_cmdline.Arg.build_config in
Expand Down
1 change: 1 addition & 0 deletions compiler/bin-wasm_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ let preprocessor_variables () =
(match Config.effects () with
| `Disabled | `Jspi -> "jspi"
| `Cps -> "cps"
| `Native -> "native"
| `Double_translation -> assert false) )
]

Expand Down
36 changes: 29 additions & 7 deletions compiler/bin-wasm_of_ocaml/link_wasm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type options =
; variables : Preprocess.variables
; allowed_imports : string list option
; binaryen_options : binaryen_options
; effects_backend : Js_of_ocaml_compiler.Config.effects_backend
}

let options =
Expand Down Expand Up @@ -71,13 +72,30 @@ let options =
let allowed_imports =
if List.is_empty allowed_imports then None else Some (List.concat allowed_imports)
in
`Ok
{ input_modules
; output_file
; variables
; allowed_imports
; binaryen_options = { common; opt; merge }
}
let effects_backend =
match
List.find_map
~f:(fun (k, v) -> if String.equal k "effects" then Some v else None)
variables.Preprocess.set
with
| Some "native" -> Ok (`Native : Js_of_ocaml_compiler.Config.effects_backend)
| Some "cps" -> Ok `Cps
| Some "jspi" | None -> Ok `Jspi
| Some "double-translation" -> Ok `Double_translation
| Some "disabled" -> Ok `Disabled
| Some other -> Error other
in
match effects_backend with
| Ok effects_backend ->
`Ok
{ input_modules
; output_file
; variables
; allowed_imports
; binaryen_options = { common; opt; merge }
; effects_backend
}
| Error other -> `Error (false, Printf.sprintf "unknown effects backend %s" other)
in
let t =
Term.(
Expand All @@ -98,7 +116,11 @@ let link
; variables
; allowed_imports
; binaryen_options = { common; merge; opt }
; effects_backend
} =
(* So that the --enable-stack-switching option is passed to Binaryen
tools for native effects. *)
Js_of_ocaml_compiler.Config.set_effects_backend effects_backend;
let inputs =
List.map
~f:(fun (module_name, file) -> { Wat_preprocess.module_name; file; source = File })
Expand Down
5 changes: 5 additions & 0 deletions compiler/lib-wasm/binaryen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ let common_options () =
; "--enable-strings"
]
in
let l =
match Config.effects () with
| `Native -> "--enable-stack-switching" :: l
| `Disabled | `Jspi | `Cps | `Double_translation -> l
in
let l = if Config.Flag.pretty () then "-g" :: l else l in
let l = if times () then "--no-validation" :: l else l in
l
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib-wasm/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let times = Debug.find "times"
let effects_cps () =
match Config.effects () with
| `Cps -> true
| `Disabled | `Jspi -> false
| `Disabled | `Jspi | `Native -> false
| `Double_translation -> assert false

module Generate (Target : Target_sig.S) = struct
Expand Down
17 changes: 15 additions & 2 deletions compiler/lib-wasm/link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,20 @@ module Wasm_binary = struct

let reftype' i ch =
match i with
| 0x6a | 0x6b | 0x6c | 0x6d | 0x6e | 0x6f | 0x70 | 0x71 | 0x72 | 0x73 -> ()
| 0x68
| 0x69
| 0x6a
| 0x6b
| 0x6c
| 0x6d
| 0x6e
| 0x6f
| 0x70
| 0x71
| 0x72
| 0x73
| 0x74
| 0x75 -> ()
| 0x63 | 0x64 -> heaptype ch
| _ ->
Format.eprintf "Unknown reftype %x@." i;
Expand Down Expand Up @@ -550,7 +563,7 @@ let build_runtime_arguments
let props =
match Config.effects () with
| `Disabled -> ("disable_effects", Javascript.EBool true) :: props
| `Jspi | `Cps -> props
| `Jspi | `Cps | `Native -> props
| `Double_translation -> assert false
in
let props =
Expand Down
Loading
Loading