-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge wasm_of_ocaml #1724
Open
OlivierNicole
wants to merge
555
commits into
ocsigen:master
Choose a base branch
from
OlivierNicole:main
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Merge wasm_of_ocaml #1724
Changes from all commits
Commits
Show all changes
555 commits
Select commit
Hold shift + click to select a range
180c365
Merge pull request #61 from OlivierNicole/upd-number
vouillon 992cdf4
Lib: use number_t in yet a few more places
vouillon 212e4c5
Merge pull request #62 from OlivierNicole/upd-number
vouillon 26b2820
fix bounds check
TheNumbat 5b6215e
Merge pull request #63 from TheNumbat/main
vouillon 5b98a6f
Merge pull request #58 from ocaml-wasm/named-value
vouillon 09a8700
fix(url.ml): set_fragment need not any urlencode
erikmd 1540ceb
fix(url.ml): Simplify get_fragment as well
erikmd 5417acb
Merge pull request #64 from OlivierNicole/converge-jsoo-merge-01
vouillon 390f9d7
Simplify the insertion of locations in wasm code
vouillon 6b08f13
Add possibly missing debug information at beginning of functions
vouillon 4d34679
Reenable optimization prevented by the insertion of locations
vouillon fb964b6
Merge pull request #59 from OlivierNicole/add-primitives
vouillon b38e20d
added 'ellipse' method to canvasRenderingContext2D (#1555)
FayCarsons e30e540
Fix hyperbolic tree example
vouillon 5a0a119
Lib: Dialog element support (#1257)
sagotch 4ce9356
Lib: fix paragraph construction and coercion
gpetiot e3f7aa1
Lib: Add Typed_array.Bytes module (#1609)
johnridesabike de31b5a
Add download attribute to anchor element
slegrand45 6dc6697
Compiler: dedicated type for "special" values (#1573)
hhugo c860567
Compiler: remove last argument of Pushtrap (#1575)
hhugo 5db44d2
Compiler: track block mutability (#1603)
hhugo e2c98ec
Compiler: lower level switch
hhugo 3146b32
Compiler: fix free variable for classes (#1524)
hhugo 0ef5c70
Compiler: minify labels
hhugo 6beaabe
Compiler: fix es6 scopes
hhugo 7977f85
Compiler: improve complexity in parser production
hhugo 2263216
Compiler: support for es6 import/export (#1529)
hhugo 924ab20
Compiler: lazy cmdliner term
hhugo ad7a1c8
Compiler: js-parser: fix class member printing
hhugo df89877
Compiler: js-parser: preserve consise body
hhugo d2b703a
Compiler: js-parser: fix assignment target
hhugo ba117ee
Compiler: Make it possible to link runtime JavaScript file together w…
vouillon fa2742a
Compiler: small refactoring
hhugo 4f541b9
Compiler: refactoring
hhugo 3694f14
Compiler: remove deprecated cmdline runtime-only flag
hhugo efbe91a
Compiler: refactoring
hhugo 0c71444
Compiler: new include-partial-runtime flag
hhugo b4be113
Tests: add test for compact option
hhugo 7eee7ed
Compiler: use consise body in arrow when es6 is enabled
hhugo 7721b16
Misc: disable some test on older ocaml
hhugo 1c17c1e
Rename `cps_calls` into `trampolined_calls` for clarity
OlivierNicole 56919bc
Merge pull request #65 from OlivierNicole/converge-jsoo-merge-02
vouillon 08316ce
Misc: yojson is no longer optional
hhugo 3d1241e
Compiler: speedup json parsing, relying on Yojson.Raw (#1640)
hhugo c211d81
Adapt Source_map after ocsigen/js_of_ocaml#1640
OlivierNicole 6e90b4e
Move Sexp functions to wasm/ subdirectory
OlivierNicole 929eed2
Compiler: fix toplevel
hhugo 2326bd1
Merge pull request #68 from OlivierNicole/converge-jsoo-merge-04
vouillon ec0e24c
Merge pull request #69 from OlivierNicole/converge-jsoo-merge-05
vouillon 5e51faa
Merge pull request #66 from ocaml-wasm/debug-fixes
vouillon 238e5eb
Merge pull request #67 from OlivierNicole/converge-jsoo-merge-03
vouillon e15a9bc
Updated dune support
vouillon e6dbb0f
Always put Wasm code and source map into an asset directory
vouillon 8d502f6
Merge pull request #45 from ocaml-wasm/target-dir
vouillon 60a1203
Merge pull request #53 from ocaml-wasm/extern-conv
vouillon c758982
JS runtime: only link jslib_js_of_ocaml.js
vouillon a02584d
No longer ignore always annotation
vouillon c0f0c8f
Handle primitives that depend on the OCaml version
OlivierNicole d30fe1f
Move version-dependant files to subdirectory
vouillon 5e9c0ea
Small fix
vouillon 6d43b92
Format dune file
vouillon 9744f89
Fix link of packed modules
vouillon f41575c
Marshal header size change in OCaml 5.1
vouillon aaf4198
Merge pull request #73 from OlivierNicole/missing-prim
vouillon 9a01ecd
Merge pull request #75 from ocaml-wasm/packed-modules
vouillon 73b3791
Wasm code linker
vouillon 7d2d95c
Generate one single wasm file per cma archive
vouillon 5a45804
Wasm output
vouillon 965988a
Start function: directly generate wasm code
vouillon ca9dcba
Support linking wasmo files into one wasma file
vouillon db04a4a
Merge pull request #72 from ocaml-wasm/reduced-js-runtime
vouillon b2ab3a2
Merge pull request #43 from ocaml-wasm/separate-compilation-v2
vouillon dd01986
ocamlformat
vouillon 3a3ca74
Update outdated info in readme
OlivierNicole c290fb1
Update README.md
OlivierNicole ab2525d
Fix warning
vouillon dc6ebd8
Merge pull request #77 from ocaml-wasm/OlivierNicole-patch-1
vouillon cfcef83
Revert "No longer ignore always annotation"
vouillon d3969be
Revert "JS runtime: only link jslib_js_of_ocaml.js"
vouillon 272422e
Merge pull request #78 from ocaml-wasm/runtime-fix
vouillon d8a442c
README: Pin more than just dune
JasonGross e8f80e0
Update README.md
JasonGross e9befa0
Update README.md
JasonGross 65a9948
Refactor distinction between integer types
vouillon 2034c19
Distinguish float field accesses in the Code IR
OlivierNicole 1a24255
WSOO side of "Distinguish float field accesses in the Code IR"
OlivierNicole 989a1d6
Fix build
OlivierNicole d7de3b6
Fixes
vouillon 19f23aa
Merge pull request #79 from JasonGross/patch-2
vouillon 8a8664d
Merge pull request #70 from OlivierNicole/converge-jsoo-merge-06
vouillon d4853b3
Compiler: fix link of packed modules
hhugo 4174f52
JavaScript linker: make it easier to add flags
vouillon a40f9a0
Compiler: Document non-trivial function Code.constant_equal, and fix …
OlivierNicole 48b465f
WSOO side of ocsigen/js_of_ocaml#1659
OlivierNicole 68bf91e
Fixes
vouillon 26864d1
Fix constant_identical for Wasm target
OlivierNicole cfc3028
Merge pull request #71 from OlivierNicole/converge-jsoo-merge-07
vouillon 13128c5
Fix performance issue when assigning short names to variables
vouillon 91cfd1b
Merge pull request #82 from ocaml-wasm/naming-fix
vouillon c4fa5d4
opam: requires ocaml >= 4.14
vouillon 87f2119
ocamlformat
vouillon 99c46f0
Compiler: nativeInt is always 32bit
hhugo 2ab1d30
Target-specific code (#1655)
OlivierNicole f27e20b
WSOO side of Target-specific code
OlivierNicole af34f71
Upgrade Dune lang version
OlivierNicole b078432
No longer ignore always annotation
vouillon 2a7f413
JavaScript linker: add 'wasm' flag
vouillon fb225da
Fixup: Fix Source_map uses
OlivierNicole b16557e
Realign Driver.optimize
OlivierNicole 509636e
Fix Parse_bytecode types
OlivierNicole d4c21f5
Merge pull request #85 from OlivierNicole/converge-jsoo-merge-08
vouillon 3e3bf3e
Merge remote-tracking branch 'jsoo/master' into jsoo-merge
OlivierNicole a6eefa0
Add Int31.of_int32_truncate
OlivierNicole 00c87cb
Add some Source_map functions
OlivierNicole b886536
Remove special Undefined
OlivierNicole d3faed0
CI fixes
OlivierNicole af6384d
Fix compilation of the Wasm runtime under Windows.
vouillon a54ca81
Fix parsing test
vouillon db1de96
Merge pull request #86 from ocaml-wasm/jsoo-merge
OlivierNicole a6c7e89
Bump ocaml/setup-ocaml from 2 to 3
dependabot[bot] 7cd0e59
Merge pull request #94 from ocaml-wasm/dependabot/github_actions/ocam…
vouillon d49fe94
Runtime: fix primitive selection for OCaml 5.01
vouillon 0b4b6d3
Disable js_of_ocaml tests
vouillon dd3c5c1
CI: test with OCaml 5.01
vouillon bcc399f
Merge branch 'master' of github.com:ocsigen/js_of_ocaml into targetint
vouillon 90db9c5
Wasm runtime: JavaScript clean-up
vouillon 78760fd
Wasm runtime: reformat the JavaScript code
vouillon 67d2add
Disable BLAKE2b tests for now
vouillon eb1128b
CI: test with OCaml 5.02
vouillon 86d3f4b
CI: test with MacOS
vouillon ef0be34
Merge pull request #95 from ocaml-wasm/ci-mac
vouillon 734dceb
Merge pull request #96 from ocaml-wasm/targetint
vouillon 62fc9ed
CI fix
vouillon 090b7b2
Runtime: typos
vouillon 364c37c
WAT output: no longer emit 'pop' instructions
vouillon 5f736b1
Use Js_of_ocaml_compiler.Structure instead of Wa_structure
vouillon f4f188a
Remove code corresponding to an hypothetical core Wasm support
vouillon c3cf34b
Calculate fetchBase once at toplevel
rickyvetter 5105f11
Merge pull request #100 from rickyvetter/patch-1
vouillon 058036f
Merge pull request #99 from ocaml-wasm/clean-up
vouillon 1bc3ab8
Use static Object.hasOwn
rickyvetter 548a3b2
Merge pull request #106 from rickyvetter/patch-2
vouillon 38abfd5
Move boxing/unboxing outside of some runtime primitives
vouillon 6d62d29
Bigstring: add JavaScript functions to access 2 or 4 bytes at once
vouillon c3ba995
Optimized blitting between strings and bigstrings
vouillon 4206f85
Add --linkall option for compatibility with Js_of_ocaml
vouillon a4e7b05
Source maps: fix documentation of command line arguments
vouillon c2a49a5
Merge pull request #84 from ocaml-wasm/bigstring-perfs
vouillon 886b6b2
Test float record with dead field
vouillon 0b432e7
Fix bad interaction of deadcode elimination and unboxed float records
vouillon 7a1d85c
Tests: more test for float conv
hhugo aede507
Runtime: make float_of_string strict
hhugo 48c22c6
Stricter float_of_string
vouillon 15bea92
Merge pull request #108 from ocaml-wasm/dead-code-fix
vouillon 102f8dd
Merge pull request #110 from ocaml-wasm/float_of_string
vouillon 3698fe4
JavaScript if statement simplification: use appropriate locations
vouillon f1f0d24
Add location after return statement
vouillon d1ecd6b
Add location on new expression
vouillon eba73eb
Move source code location resolution from code output to code generation
vouillon fdbc151
Test: miscompilation of float array creation
vouillon 65e727a
Fix creation of float arrays
vouillon badd68f
Merge remote-tracking branch 'jsoo/master' into jsoo
vouillon 0310c5c
Add more tests of caml_make_array
vouillon fb4d189
Merge pull request #111 from ocaml-wasm/jsoo
vouillon c1390f7
Merge pull request #113 from ocaml-wasm/caml-make-array
vouillon 9293f3f
Wasm linker fixes
vouillon ea93a52
Sourcemap improvements
vouillon 3547c4c
Merge pull request #118 from ocaml-wasm/sm
vouillon b37c665
Compile a raise within a try as a branch to the exception handler
vouillon dea31d2
Delete asset directory if it already exists
vouillon f428e0e
Github action: automatically merge with js_of_ocaml
vouillon f33288a
Update README.md
vouillon ba44373
Source map: align with Js_of_ocaml
vouillon d6b458d
Run Bonsai test with profile release as well
vouillon 5cf44d5
Make sure we open files in binary mode
vouillon 93d7e83
Remove dead comments, use better exceptions
OlivierNicole eca029f
Source maps: possibility to reuse a temporary buffer when parsing
vouillon 065f096
Bump actions/checkout from 3 to 4
dependabot[bot] 85bfcb0
Merge pull request #124 from ocaml-wasm/dependabot/github_actions/act…
vouillon 37dc530
Merge pull request #121 from OlivierNicole/cr-hhugo
vouillon 5072ad2
Use dune tests
vouillon cfba5c3
Compiler tests: lighter conditions
vouillon a84940d
Quiet biome warning regarding "use strict".
vouillon 04db0cc
Source maps: avoid some code duplication
vouillon bd6e015
Merge pull request #122 from ocaml-wasm/source-map-merge
vouillon 1d6036f
Move compiler/lib/wasm to compiler/lib-wasm
vouillon a3498e0
Merge pull request #125 from ocaml-wasm/move-wasm-lib
vouillon 9d89eff
Merge pull request #123 from ocaml-wasm/use-strict
vouillon 6fe39a2
Merge pull request #120 from ocaml-wasm/tests
vouillon d323e66
Dune file formatting changes
vouillon 9e5006f
Revised dune support
vouillon 47f0707
Library tests: lighter conditions
vouillon b0c7c99
Update Yojson dependency
vouillon bd01184
Use a try_table like instruction internally
vouillon bdf5c00
CI: pin main branch of dune
vouillon ee35863
Update README.md
vouillon d7bf42c
Merge pull request #126 from ocaml-wasm/wasm-dune
vouillon a1d6554
Renamed Wa_ast into Wasm_ast
vouillon 40f4d4e
Renamed more files
vouillon f51c956
Renamed more files
vouillon 02b848f
Renamed remaining files
vouillon 34bfa2a
Update .git-blame-ignore-revs
vouillon 1a7305e
Merge pull request #127 from ocaml-wasm/renamings
vouillon e660725
Always enable tests-jsoo/lib-effects tests for OCaml >= 5.0
vouillon aa1c9c9
Tests: use an environment variable to know whether we are testing Was…
vouillon 9d6df66
Merge pull request #128 from ocaml-wasm/env-var
vouillon 1d9ac93
Tests: clean-up lib-effects tests
vouillon 49eb19f
cleanup
hhugo 1c536c2
Wasm source map resizing: clean-up
vouillon 7e071a6
Make it explicit when we manipulate standard source maps
vouillon b5ae6af
Source map related code clean-up
vouillon c04eca5
Add missing copyright headers
vouillon a42f326
Cmdliner documentation update
vouillon 370ef42
CI updates
vouillon ab1faf2
Merge pull request #129 from ocaml-wasm/wasm-source-maps
vouillon 539390d
Typo
vouillon 73df0b4
Fix CI
vouillon 416dfd2
Fix optimization of JavaScript interoperability primitives
vouillon 59f3462
Optimized JavaScript property accesses when using an OCaml string as …
vouillon 7bfec53
Merge pull request #130 from ocaml-wasm/js-prim-fixes
vouillon 6aac869
Update to new JavaScript-Promise Integration API
vouillon 1189e53
CI: move
hhugo d1566a4
Release 5.9 (#1735)
hhugo 5220982
Misc: adjust opam constraint (#1742)
hhugo 3785e99
Lib: small refactoring around js exception printing (#1743)
hhugo 3e12e52
CI: move
hhugo ae1284b
Fix ci mac (#1744)
hhugo 825941b
Tests: recursive value compilation
hhugo e16f8e3
Misc: remove macos CI fix
hhugo 285376a
Tests: promote with new compilation strategy
hhugo be634ad
Merge branch 'master' of github.com:ocsigen/js_of_ocaml into jsoo-merge
vouillon 5e25815
CI: explicitly set version of all jsoo packages
vouillon 1f11a80
Formatting
vouillon 3c9036a
Merge pull request #48 from ocaml-wasm/updated-jspi
vouillon 52c69c8
Merge pull request #131 from ocaml-wasm/jsoo-merge
vouillon bb3fb63
Merge branch 'master' of github.com:ocsigen/js_of_ocaml into jsoo-merge
vouillon ad1676f
No longer pin dune
vouillon a0b5b8c
Reformat dune files
vouillon 97db4d6
Misc: bump test dep
hhugo e83dd90
Merge pull request #133 from ocaml-wasm/dune-released
vouillon 6239d59
Use JS String Builtins to convert ASCII OCaml strings to Javascript s…
vouillon 4f76417
Merge pull request #132 from ocaml-wasm/string-conv
vouillon 3656b8f
Update examples
vouillon b12f852
Merge pull request #134 from ocaml-wasm/examples
vouillon 2e14088
Merge remote-tracking branch 'jsoo/master' into jsoo-merge
vouillon e6ca2d3
Merge pull request #135 from ocaml-wasm/jsoo-merge
vouillon 07e1752
Revert "Github action: automatically merge with js_of_ocaml"
vouillon 6e4d795
Move READMEs
vouillon b8ee2b4
Changelog
vouillon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
*.ml linguist-language=OCaml | ||
*.mli linguist-language=OCaml | ||
|
||
# We are pinning wasm_of_ocaml using this file in the CI. This would | ||
# fail on Windows otherwise. | ||
VERSION -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
name: Build wasm_of_ocaml | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
build: | ||
env: | ||
OPAMJOBS: 2 | ||
OPAMYES: true | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
ocaml-compiler: | ||
- 4.14.x | ||
- 5.00.x | ||
- 5.01.x | ||
- 5.02.x | ||
separate_compilation: | ||
- true | ||
include: | ||
- os: macos-latest | ||
ocaml-compiler: 5.02.x | ||
separate_compilation: true | ||
- os: ubuntu-latest | ||
ocaml-compiler: 4.14.x | ||
separate_compilation: false | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Set git to use LF | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global core.eol lf | ||
git config --global core.ignorecase false | ||
|
||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 23 | ||
|
||
- name: Restore cached binaryen | ||
id: cache-binaryen | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: binaryen | ||
key: ${{ runner.os }}-binaryen-version_118 | ||
|
||
- name: Checkout binaryen | ||
if: steps.cache-binaryen.outputs.cache-hit != 'true' | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: WebAssembly/binaryen | ||
path: binaryen | ||
submodules: true | ||
ref: version_118 | ||
|
||
- name: Install ninja (Ubuntu) | ||
if: matrix.os == 'ubuntu-latest' && steps.cache-binaryen.outputs.cache-hit != 'true' | ||
run: sudo apt-get install ninja-build | ||
|
||
- name: Install ninja (MacOS) | ||
if: matrix.os == 'macos-latest' && steps.cache-binaryen.outputs.cache-hit != 'true' | ||
run: brew install ninja | ||
|
||
- name: Build binaryen | ||
if: steps.cache-binaryen.outputs.cache-hit != 'true' | ||
working-directory: ./binaryen | ||
run: | | ||
cmake -G Ninja . | ||
ninja | ||
|
||
- name: Cache binaryen | ||
if: steps.cache-binaryen.outputs.cache-hit != 'true' | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: binaryen | ||
key: ${{ runner.os }}-binaryen-version_118 | ||
|
||
- name: Set binaryen's path | ||
run: | | ||
echo "$GITHUB_WORKSPACE/binaryen/bin" >> $GITHUB_PATH | ||
|
||
- name: Install OCaml ${{ matrix.ocaml-compiler }} | ||
uses: ocaml/setup-ocaml@v3 | ||
with: | ||
ocaml-compiler: ${{ matrix.ocaml-compiler }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
path: wasm_of_ocaml | ||
|
||
- name: Pin faked binaryen-bin package | ||
# It's faster to use a cached version | ||
run: opam install --fake binaryen-bin | ||
|
||
- name: Checkout Jane Street opam repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: janestreet/opam-repository | ||
ref: feaf8f831051fd5f316963b28efd728cf0b0eca1 | ||
path: jane-street/opam-repository | ||
|
||
- name: Pin wasm_of_ocaml | ||
working-directory: ./wasm_of_ocaml | ||
run: opam pin -n --with-version `< VERSION` . | ||
|
||
- name: Install some needed packages | ||
run: opam install opam-format ocamlfind dune graphics cmdliner sexplib0.v0.16.0 | ||
|
||
- name: Checkout Jane Street packages | ||
run: opam exec -- ocaml wasm_of_ocaml/tools/ci_setup.ml | ||
|
||
- name: Install wasm_of_ocaml and its test dependencies | ||
working-directory: ./wasm_of_ocaml | ||
run: | | ||
opam install `basename -s .opam *.opam` num cohttp-lwt-unix ppx_expect cstruct | ||
|
||
- name: Run tests | ||
if: ${{ matrix.separate_compilation }} | ||
working-directory: ./wasm_of_ocaml | ||
run: opam exec -- dune build @all @runtest --profile wasm | ||
|
||
- name: Run tests with CPS effects | ||
if: ${{ matrix.ocaml-compiler >= '5.' && matrix.separate_compilation }} | ||
working-directory: ./wasm_of_ocaml | ||
run: opam exec -- dune build @all @runtest --profile wasm-effects | ||
|
||
- name: Run Base tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/base | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Base bigstring tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/base_bigstring | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Core tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/core | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Bignum tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/bignum | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Bin_prot tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/bin_prot | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run String_dict tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/string_dict | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Zarith tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/zarith_stubs_js | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Virtual_dom tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/virtual_dom | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Bonsai tests | ||
if: ${{ matrix.ocaml-compiler < '5.' && matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/bonsai | ||
run: opam exec -- dune runtest | ||
|
||
- name: Run Bonsai tests (release profile) | ||
if: ${{ ! matrix.separate_compilation }} | ||
working-directory: ./jane-street/lib/bonsai | ||
run: opam exec -- dune runtest --profile release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Wasm_of_ocaml | ||
|
||
Wasm_of_ocaml is a fork of Js_of_ocaml which compiles OCaml bytecode to WebAssembly. | ||
|
||
## Supported engines | ||
|
||
The generated code works with Chrome 11.9, Node.js 22 and Firefox 122 (or more recent versions of these applications). | ||
|
||
In particular, the output code requires the following [Wasm extensions](https://webassembly.org/roadmap/) to run: | ||
- [the GC extension](https://github.com/WebAssembly/gc), including functional references and 31-bit integers | ||
- [the tail-call extension](https://github.com/WebAssembly/tail-call/blob/main/proposals/tail-call/Overview.md) | ||
- [the exception handling extension](https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md) | ||
|
||
OCaml 5.x code using effect handlers can be compiled in two different ways: | ||
One can enable the CPS transformation from `js_of_ocaml` by passing the | ||
`--enable=effects` flag. Without the flag `wasm_of_ocaml` will instead emit code | ||
utilizing | ||
- [the JavaScript-Promise Integration extension](https://github.com/WebAssembly/js-promise-integration/blob/main/proposals/js-promise-integration/Overview.md) | ||
|
||
|
||
## Installation | ||
|
||
The following commands will perform a minimal installation: | ||
``` | ||
git clone https://github.com/ocaml-wasm/wasm_of_ocaml | ||
cd wasm_of_ocaml | ||
opam pin add -n --with-version 6.0.0 . | ||
opam install dune.3.17.0 wasm_of_ocaml-compiler | ||
``` | ||
You may want to install additional packages. For instance: | ||
|
||
``` | ||
opam install js_of_ocaml-ppx js_of_ocaml-lwt | ||
``` | ||
|
||
## Usage | ||
|
||
You can try compiling the program in `examples/cubes`. Your program must first be compiled using the OCaml bytecode compiler `ocamlc`. JavaScript bindings are provided by the `js_of_ocaml` package. The syntax extension is provided by `js_of_ocaml-ppx` package. Package `js_of_ocaml-lwt` provides Javascript specific Lwt functions. | ||
|
||
``` | ||
ocamlfind ocamlc -package js_of_ocaml,js_of_ocaml-ppx,js_of_ocaml-lwt -linkpkg -o cubes.byte cubes.mli cubes.ml | ||
``` | ||
|
||
Then, run the `wasm_of_ocaml` compiler to produce WebAssembly code: | ||
|
||
``` | ||
wasm_of_ocaml cubes.byte | ||
``` | ||
|
||
This outputs a file `cubes.js` which loads the WebAssembly code from file `cube.wasm`. For debugging, we currently also output the generated WebAssembly code in text file to `cube.wat`. Since Chrome does not allow loading from the filesystem, you need to serve the files using some Web server. For instance: | ||
``` | ||
python3 -m http.server 8000 --directory . | ||
``` | ||
|
||
As a larger example, you can try [CAMLBOY](https://github.com/linoscope/CAMLBOY). You need to install a forked version of [Brr](https://github.com/ocaml-wasm/brr/tree/wasm). Once the Js_of_ocaml UI is compiled (with `dune build --profile release`), you can generate WebAssembly code instead with the following command: | ||
``` | ||
wasm_of_ocaml _build/default/bin/web/index.bc-for-jsoo | ||
``` | ||
|
||
## Implementation status | ||
|
||
A large part of the runtime is [implemented](https://github.com/ocaml-wasm/wasm_of_ocaml/issues/5). File-related functions and dynamic linking are not supported yet. | ||
|
||
## Compatibility with Js_of_ocaml | ||
|
||
Since the value representation is different, some adaptations are necessary. | ||
|
||
The most notable change is that, except for integers, OCaml numbers are no longer mapped to JavaScript numbers. So, explicit conversions `Js.to_float` and `Js.float` are now necessary to convert between OCaml floats and JavaScript numbers. The typing of JavaScript Typed Arrays has also been changed to deal with this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(* Wasm_of_ocaml compiler | ||
* http://www.ocsigen.org/js_of_ocaml/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, with linking exception; | ||
* either version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*) | ||
|
||
open! Js_of_ocaml_compiler.Stdlib | ||
|
||
let info = | ||
Info.make | ||
~name:"build-runtime" | ||
~doc:"Build standalone runtime. Used for separate compilation." | ||
~description:"Wasm_of_ocaml is a compiler from OCaml bytecode to WebAssembly." | ||
|
||
let command = | ||
let t = Cmdliner.Term.(const Compile.run $ Cmd_arg.options_runtime_only) in | ||
Cmdliner.Cmd.v info t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(* Wasm_of_ocaml compiler | ||
* http://www.ocsigen.org/js_of_ocaml/ | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, with linking exception; | ||
* either version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*) | ||
|
||
val command : unit Cmdliner.Cmd.t |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installing binaryen is pretty slow. I wonder if should not do it here and only do it in build-wasm_of_ocaml.yml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the issue is that
dune build @all
will invokewasm-merge
andwasm-opt
to buildruntime/wasm/runtime.wasm
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could cache binaryen, as is done in build-wasm_of_ocaml.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try that