Skip to content
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

Merged
merged 569 commits into from
Dec 4, 2024
Merged

Merge wasm_of_ocaml #1724

merged 569 commits into from
Dec 4, 2024

Conversation

OlivierNicole
Copy link
Contributor

@OlivierNicole OlivierNicole commented Oct 31, 2024

This aims to merge wasm_of_ocaml, currently hosted at https://github.com/ocaml-wasm/wasm_of_ocaml, back into this repo.

This is pending on Dune support ocaml/dune#11029. For now, Dune is pinned for the CI jobs.

vouillon and others added 30 commits September 3, 2024 16:43
* Support for dialogElement

* Added cancel and close events

---------

Co-authored-by: Hugo Heuzard <[email protected]>
* Compiler: fix free variable for classes
…ith OCaml libraries

Use: js_of_ocaml --toplevel --no-runtime runtime.js library.cma
Integrate "added 'ellipse' method to canvasRenderingContext2D" (ocsigen#1555)
@hhugo hhugo merged commit 9cfbfc4 into ocsigen:master Dec 4, 2024
27 checks passed
@hhugo
Copy link
Member

hhugo commented Dec 4, 2024

Thanks for all the hard work

@dbuenzli
Copy link
Contributor

dbuenzli commented Dec 4, 2024

Bravo! Is there some high level docs on how to use the stuff ?

@vouillon
Copy link
Member

vouillon commented Dec 4, 2024

Bravo! Is there some high level docs on how to use the stuff ?

There is a short README_wasm_of_ocaml.md. But I still need to write some documentation...

@rickyvetter
Copy link
Contributor

Incredible! This is awesome.

@dbuenzli
Copy link
Contributor

dbuenzli commented Dec 4, 2024

There is a short README_wasm_of_ocaml.md.

This looks to good to be true :–) The browsers APIs can be used as is ?

However it is possible to make it work over the file:// protocol ? And what's the story with webworkers ?

I have a number crunching app (computing thousands of polygon intersections) that I distribute as a single double-clickable .html file. It would be interesting to see the gains there. However it uses extremely dirty tricks to make webworkers work out of a single js_of_ocaml compiled file with code paths differentiated in the main via Worker.ami.

@vouillon
Copy link
Member

vouillon commented Dec 4, 2024

The browsers APIs can be used as is ?

Right.

However it is possible to make it work over the file:// protocol ?

Not at the moment. Source Phase Imports might make it possible at some point. Or maybe we could have an option to somehow embed the Wasm code in the JavaScript code.

And what's the story with webworkers ?

I'm not sure. What problem could there be?

I have a number crunching app (computing thousands of polygon intersections) that I distribute as a single double-clickable .html file. It would be interesting to see the gains there. However it uses extremely dirty tricks to make webworkers work out of a single js_of_ocaml compiled file with code paths differentiated in the main via Worker.ami.

This might just work if we embed the Wasm code.

@dbuenzli
Copy link
Contributor

dbuenzli commented Dec 4, 2024

I'm not sure. What problem could there be?

I'm concerned about data transfers. With webworkers you are supposed to transfer JavaScript values that that go through the structured clone algorithm.

As we once discussed that worked relatively flawlessly with js_of_ocaml's encoding of OCaml values encoded as JavaScript values.

Now I don't know how OCaml values are represented in wasm_of_ocaml, but in the webworker work queue I linked to I'm basically using Obj.magic on OCaml values to transfer work items but if those are no longer represented as JavaScript values then I expect kaboom.

@vouillon
Copy link
Member

vouillon commented Dec 5, 2024

OCaml values are represented using Wasm GC values, so indeed the structured clone algorithm will not work on them. You have to serialize them somehow. You can try Marshal which works much better than with Js_of_ocaml (integers and floats do not share the same representation).

I have some experimental code to embed the Wasm code within the JavaScript code. Maybe you could give it a try.

@micahcantor
Copy link
Contributor

Congrats @vouillon @OlivierNicole @hhugo 🎉 !

Leonidas-from-XIV added a commit to Leonidas-from-XIV/dune that referenced this pull request Dec 5, 2024
The attempts to update the workflow as Wasm_of_ocaml has been merged
upstream in ocsigen/js_of_ocaml#1724 and the
wasm-dune branch is gone.

Signed-off-by: Marek Kubica <[email protected]>
Leonidas-from-XIV added a commit to ocaml/dune that referenced this pull request Dec 6, 2024
The attempts to update the workflow as Wasm_of_ocaml has been merged
upstream in ocsigen/js_of_ocaml#1724 and the
wasm-dune branch is gone.

Signed-off-by: Marek Kubica <[email protected]>
chris-armstrong pushed a commit to chris-armstrong/dune that referenced this pull request Jan 29, 2025
The attempts to update the workflow as Wasm_of_ocaml has been merged
upstream in ocsigen/js_of_ocaml#1724 and the
wasm-dune branch is gone.

Signed-off-by: Marek Kubica <[email protected]>
Signed-off-by: Chris Armstrong <[email protected]>
hhugo added a commit to hhugo/opam-repository that referenced this pull request Feb 7, 2025
CHANGES:

## Features/Changes
* Compiler/Runtime: Make resuming a continuation more efficient in js (ocsigen/js_of_ocaml#1765)
* Compiler/Runtime: Effects: add an optional feature of "dynamic switching" between CPS
  and direct style, resulting in better performance when
  no effect handler is installed
* Compiler: Merged Wasm_of_ocaml (ocsigen/js_of_ocaml#1724)
* Lib: fix the type of some DOM properties and methods (ocsigen/js_of_ocaml#1747)
* Lib: removed no longer relevant Js.optdef type annotations (ocsigen/js_of_ocaml#1769)
* Lib: Add other textMetrics property (ocsigen/js_of_ocaml#1784)
* Lib: rename Firebug to Console (ocsigen/js_of_ocaml#1802)
* Test: use dune test stanzas (ocsigen/js_of_ocaml#1631)
* Test: run wasm tests on windows
* Misc: drop support for IE
* Misc: move tests to OCaml 5.3
* Misc: import many test from the OCaml codebase
* Runtime: support for float16 bigarrays
* Runtime: support more Unix functions (ocsigen/js_of_ocaml#1823)
* Runtime: various filesystem fixes (ocsigen/js_of_ocaml#1825)

## Bug fixes
* Compiler: Fix small bug in global data flow analysis (ocsigen/js_of_ocaml#1768)
* Runtime: no longer leak channels
* Runtime: Fix Marshal.to_buffer (ocsigen/js_of_ocaml#1798)
* Runtime: unmarshalling objects should refresh its id
* Runtime: check size upper bound during array creation
* Runtime: return sys_error when reading from a closed channels
* Runtime: fix parsing of hex-float with very large exponent
* Runtime: make sure [n / 0L] is not optimized away by DCE
* Runtime: fix Unix.LargeFile.stat/lstat
* Runtime: fix stat/lstat times
* Runtime: fix reading from stdin in an interactive nodejs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants