Skip to content

feat/hack: wasm_of_ocaml initial prototype.#5904

Draft
alexandru-uta wants to merge 7 commits intomasterfrom
alex/wasm_caml
Draft

feat/hack: wasm_of_ocaml initial prototype.#5904
alexandru-uta wants to merge 7 commits intomasterfrom
alex/wasm_caml

Conversation

@alexandru-uta
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 12, 2026

Comparing from 9c1a8ff to 7237785:
The produced WebAssembly code seems to be completely unchanged.
In terms of gas, no changes are observed in 5 tests.
In terms of size, no changes are observed in 5 tests.

@crusso
Copy link
Copy Markdown
Contributor

crusso commented Mar 12, 2026

This is cool. Any reason we can't just ship the whole compiler and they use the existing moc --stable-compatible old new

@alexandru-uta
Copy link
Copy Markdown
Contributor Author

alexandru-uta commented Mar 12, 2026

This is cool. Any reason we can't just ship the whole compiler and they use the existing moc --stable-compatible old new

Yeah, unfortunately several. For example: one is that in code generation we assume system int is at least 32 bit, but wasm_of_ocaml gives you wasm_gc with i31ref ints; another one is the num library we use in the frontend -- it doesn't play nicely with wasm_of_ocaml either.

@crusso
Copy link
Copy Markdown
Contributor

crusso commented Mar 12, 2026

Indeed. Maybe not worth tackling those just now. The 32 bit assumption should not be too hard to remove if we ever try again in future.

@alexandru-uta
Copy link
Copy Markdown
Contributor Author

alexandru-uta commented Mar 13, 2026

=== WASM (moc_check_wasm) — 20 runs ===
version: 1.3.0-16-ge3b0a0823-dirty

  --- Cold (no cache) ---
  fail/inference.mo (193L) [21 err, 1 warn]  avg=    3.1ms  med=    3.1ms  min=    2.3ms  max=    4.0ms
  fail/pretty.mo (146L) [43 err, 0 warn]     avg=    3.9ms  med=    3.8ms  min=    3.5ms  max=    4.5ms
  fail/edit-suggestions.mo (149L) [1 err, 1 warn] avg=  105.3ms  med=   95.4ms  min=   85.6ms  max=  268.0ms
  fail/nonproductive.mo (124L) [14 err, 0 warn] avg=    0.9ms  med=    0.8ms  min=    0.7ms  max=    1.3ms
  fail/wrong-call-args.mo (118L) [16 err, 1 warn] avg=  218.6ms  med=  191.8ms  min=   84.8ms  max=  463.5ms
  run/type-combine.mo (462L) [22 warn]       avg=   22.1ms  med=   10.7ms  min=    7.1ms  max=  110.3ms
  run/numeric-ops.mo (392L) [1 warn]         avg=   51.8ms  med=   27.8ms  min=   22.1ms  max=  158.2ms
  run/type-inclusion.mo (242L) [49 warn]     avg=    9.7ms  med=    4.4ms  min=    2.8ms  max=   77.8ms
  run/coverage.mo (236L) [140 warn]          avg=   11.5ms  med=    5.3ms  min=    3.1ms  max=  104.8ms
  core/test/Map.test.mo (1627L) [9 warn]     avg=  240.1ms  med=  240.3ms  min=  210.7ms  max=  279.6ms
  core/test/pure/Map.test.mo (1212L) [5 warn] avg=  119.8ms  med=  117.7ms  min=  112.5ms  max=  145.8ms
  TOTAL (avg)                                786.6ms

  --- Warm (with scope cache) ---
  fail/inference.mo (193L) [21 err, 1 warn]  avg=    2.9ms  med=    2.9ms  min=    2.2ms  max=    3.8ms
  fail/pretty.mo (146L) [43 err, 0 warn]     avg=    3.7ms  med=    3.6ms  min=    3.3ms  max=    4.3ms
  fail/edit-suggestions.mo (149L) [1 err, 1 warn] avg=    1.8ms  med=    1.6ms  min=    1.5ms  max=    3.8ms
  fail/nonproductive.mo (124L) [14 err, 0 warn] avg=    0.7ms  med=    0.7ms  min=    0.6ms  max=    1.0ms
  fail/wrong-call-args.mo (118L) [16 err, 1 warn] avg=    2.2ms  med=    2.1ms  min=    1.9ms  max=    3.3ms
  run/type-combine.mo (462L) [22 warn]       avg=    5.5ms  med=    5.6ms  min=    4.8ms  max=    6.0ms
  run/numeric-ops.mo (392L) [1 warn]         avg=    4.6ms  med=    4.4ms  min=    3.8ms  max=    6.1ms
  run/type-inclusion.mo (242L) [49 warn]     avg=    2.3ms  med=    2.3ms  min=    1.8ms  max=    2.7ms
  run/coverage.mo (236L) [140 warn]          avg=    2.4ms  med=    2.4ms  min=    2.0ms  max=    2.8ms
  core/test/Map.test.mo (1627L) [0 warn]     avg=   31.4ms  med=   31.0ms  min=   30.4ms  max=   34.8ms
  core/test/pure/Map.test.mo (1212L) [0 warn] avg=   22.0ms  med=   21.5ms  min=   19.3ms  max=   28.9ms
  TOTAL (avg)                                79.4ms

  Speedup from cache: 9.9x

vs.

=== JS (moc_js) — 20 runs ===
version: 1.3.0-16-ge3b0a0823-dirty

  --- Cold (no cache) ---
  fail/inference.mo (193L) [19 err, 1 warn]  avg=    7.0ms  med=    6.8ms  min=    5.6ms  max=    8.4ms
  fail/pretty.mo (146L) [43 err, 0 warn]     avg=   10.6ms  med=   10.6ms  min=    9.2ms  max=   11.9ms
  fail/edit-suggestions.mo (149L) [1 err, 1 warn] avg=  178.9ms  med=  181.5ms  min=  156.8ms  max=  220.1ms
  fail/nonproductive.mo (124L) [14 err, 0 warn] avg=    1.6ms  med=    1.3ms  min=    1.1ms  max=    2.6ms
  fail/wrong-call-args.mo (118L) [16 err, 1 warn] avg=  158.2ms  med=  156.1ms  min=  147.8ms  max=  173.3ms
  run/type-combine.mo (462L) [22 warn]       avg=   13.2ms  med=   12.5ms  min=   10.9ms  max=   19.8ms
  run/numeric-ops.mo (392L) [1 warn]         avg=   31.3ms  med=   30.7ms  min=   28.7ms  max=   36.5ms
  run/type-inclusion.mo (242L) [49 warn]     avg=    5.4ms  med=    5.1ms  min=    4.4ms  max=    8.5ms
  run/coverage.mo (236L) [140 warn]          avg=    5.8ms  med=    5.9ms  min=    4.9ms  max=    7.0ms
  core/test/Map.test.mo (1627L) [9 warn]     avg=  490.7ms  med=  470.6ms  min=  449.5ms  max=  661.0ms
  core/test/pure/Map.test.mo (1212L) [5 warn] avg=  276.0ms  med=  276.9ms  min=  255.8ms  max=  299.5ms
  TOTAL (avg)                                1178.7ms

  --- Warm (with scope cache) ---
  fail/inference.mo (193L) [19 err, 1 warn]  avg=    5.8ms  med=    5.7ms  min=    5.2ms  max=    6.5ms
  fail/pretty.mo (146L) [43 err, 0 warn]     avg=   10.2ms  med=    9.1ms  min=    8.3ms  max=   15.6ms
  fail/edit-suggestions.mo (149L) [1 err, 1 warn] avg=    2.9ms  med=    2.9ms  min=    2.4ms  max=    3.4ms
  fail/nonproductive.mo (124L) [14 err, 0 warn] avg=    1.4ms  med=    1.3ms  min=    1.1ms  max=    1.9ms
  fail/wrong-call-args.mo (118L) [16 err, 1 warn] avg=    4.3ms  med=    4.3ms  min=    3.9ms  max=    4.7ms
  run/type-combine.mo (462L) [22 warn]       avg=   12.0ms  med=   11.6ms  min=   10.6ms  max=   15.3ms
  run/numeric-ops.mo (392L) [1 warn]         avg=    9.7ms  med=    9.0ms  min=    8.4ms  max=   16.7ms
  run/type-inclusion.mo (242L) [49 warn]     avg=    4.9ms  med=    4.8ms  min=    4.4ms  max=    6.1ms
  run/coverage.mo (236L) [140 warn]          avg=    6.0ms  med=    5.7ms  min=    5.0ms  max=    9.4ms
  core/test/Map.test.mo (1627L) [0 warn]     avg=   61.3ms  med=   60.4ms  min=   59.5ms  max=   67.1ms
  core/test/pure/Map.test.mo (1212L) [0 warn] avg=   40.5ms  med=   38.9ms  min=   37.7ms  max=   49.7ms
  TOTAL (avg)                                159.1ms

  Speedup from cache: 7.4x

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.

2 participants