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

Draft
wants to merge 481 commits into
base: master
Choose a base branch
from
Draft

Merge wasm_of_ocaml #1724

wants to merge 481 commits into from

Conversation

OlivierNicole
Copy link
Contributor

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 March 25, 2024 09:39
In particular, include part of the string contents in the name for short strings.
We had to work around some Firefox limitations which are now fixed.
This reverts commit 8ed4e18.
The call to 'eval' is usually optimized away. So only generate it if needed.
No file in compiler/lib depends on a file in compiler/lib/wasm, so we no
longer need to compile these two directories together.
https://github.com/WebAssembly/js-string-builtins

Enabled with flag --experimental-wasm-imported-strings in node, and
through chrome://flags/#enable-experimental-webassembly-features in
Chrome.
Implement mapping between source and wasm locations.

To work, this requires a version of Binaryen compiled with Jérôme's
patch WebAssembly/binaryen#6372.

Single-stepping can jump around in slightly surprising ways in the OCaml
code, due to the different order of operations in wasm. This could be
improved by modifying Binaryen to support “no location” annotations.
Another future improvement can be to support mapping Wasm identifiers to
OCaml ones.

Co-authored-by: Jérôme Vouillon <[email protected]>
We were just numbering them. This should make the output more readable
since we are propagating names from the OCaml source code.
Directly use the name from the OCaml code if possible, with a suffix in
case of ambiguity. Use short names for not explictly named variables.
- more options
- do not keep temp files
- use a relative path as a sourcemap url
vouillon and others added 26 commits October 23, 2024 15:07
When one of the fields is not used, we fill it with the float value 0.
rather than using the generic placeholder `(ref.i31 (i32.const 0))`,
which does not make sense.
Fix bad interaction of deadcode elimination and unboxed float records
Get latest changes from js_of_ocaml
When the size of a piece of code changes, report that its end position
changes, rather than its start position.
- Wasm AST: use a standalone event instruction to indicate code locations
- Add location at end of functions
- Hide code with no location
So that we test whole-program compilation a bit.
@vouillon
Copy link
Member

@hhugo You can have a first look.

Regarding the directory structure, the wasm-specific code of wasm_of_ocaml is in compiler/lib/wasm (and compiler/lib/bin-wasm_of_ocaml for the binary itself). Initially, these files were included in the js_of_ocaml-compiler library, so I added a wa_ prefix to avoid confusing them with JavaScript related files. Now that it's a separate library, I should probably remove the prefix. The runtime files are in runtime/wasm. Maybe we should move the JavaScript runtime to runtime/js to get something more symmetric?

List.map ~f:(fun f -> f, Var.Map.find f arities) fun_lst
in
(*
Format.eprintf "AAA";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you wan't to keep this comment ?

| None -> assert false
end
(*
parse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be dropped or moved to a test directory

let single f v =
match v with
| [ v ] -> f v
| _ -> assert false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this assert be invalid_arg ? same below ..

- ocp-indent: needed to support indentation in the toplevel
- higlo: needed to support Syntax highlighting in the toplevel
- cohttp: needed to build the toplevel webserver
# Wasm_of_ocaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we merge the two readmes ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, certainly.

@@ -37,7 +37,8 @@
},
"suspicious": {
"noAssignInExpressions": "off",
"noRedeclare": "off"
"noRedeclare": "off",
"noRedundantUseStrict": "off"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ?

@@ -0,0 +1,7 @@
(library
(name wasm_of_ocaml_compiler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you feel about moving this lib to compiler/lib-wasm ?

@@ -0,0 +1,39 @@
name: Automatic Merge with Js_of_ocaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this file is not meant for this repo

@hhugo
Copy link
Member

hhugo commented Oct 31, 2024

The runtime files are in runtime/wasm. Maybe we should move the JavaScript runtime to runtime/js to get something more symmetric?

Sounds good

; mutable pos : int
}

module Vlq = struct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be merged with the vlq module from lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.