From 2b890d27d9e52f6132726af2e283e076ba3b70ec Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Mon, 21 Sep 2026 19:54:48 -0400 Subject: [PATCH 1/3] feat!: Upgrade to Binaryen v133 Full Diff: https://github.com/WebAssembly/binaryen/compare/version_132...version_133 API Additions: * Passes.remove_empty_function_exports * Passes.tail_call * Type.exnref * Type.null_exnref * HeapType.exn * HeapType.noexn API Removals: * Passes.trap_mode_clamp * Passes.trap_mode_js Changes not made: * exception handling (brand new api not implemented yet) * BinaryenTryTable * BinaryenThrowRef * BinaryenTryTableGetBody * BinaryenTryTableSetBody * BinaryenTryTableGetNumCatches * BinaryenTryTableGetCatchTagAt * BinaryenTryTableSetCatchTagAt * BinaryenTryTableGetCatchDestAt * BinaryenTryTableSetCatchDestAt * BinaryenTryTableIsCatchRefAt * BinaryenTryTableSetCatchRefAt * BinaryenTryTableGetSentTypeAt * BinaryenTryTableAppendCatch * BinaryenTryTableInsertCatchAt * BinaryenTryTableRemoveCatchAt * BinaryenTryTableHasCatchAll * BinaryenThrowRefGetExnref * BinaryenThrowRefSetExnref * wait (new api, we should open an issue) * BinaryenStructWait * BinaryenWaitqueueNew * BinaryenWaitqueueNotify * BinaryenPublish * BinaryenStructWaitGetRef * BinaryenStructWaitSetRef * BinaryenStructWaitGetIndex * BinaryenStructWaitSetIndex * BinaryenStructWaitGetExpected * BinaryenStructWaitSetExpected * BinaryenStructWaitGetTimeout * BinaryenStructWaitSetTimeout * BinaryenStructWaitGetWaitqueue * BinaryenStructWaitSetWaitqueue * BinaryenWaitqueueNotifyGetWaitqueue * BinaryenWaitqueueNotifySetWaitqueue * BinaryenWaitqueueNotifyGetCount * BinaryenWaitqueueNotifySetCount * BinaryenPublishGetRef * BinaryenPublishSetRef * general apis (not handled by us) * BinaryenSideEffectSuspends Notes: * I changed the `HeapTypes` api to use the js api rather than the underlying binaryen calls, this is more inline with how we handle things elsewhere. (The only reason this wasn't done originally is the js api didn't originally support them). Grain Notes: * `addDefaultFunctionOptimizationPasses` was modified so we need to update our grain passes. --- binaryen.opam | 2 +- esy.lock/index.json | 107 +++++++++--------- .../opam | 6 +- .../opam/{uucp.17.0.0 => uucp.18.0.0}/opam | 8 +- .../opam/{uuseg.17.0.0 => uuseg.18.0.0}/opam | 6 +- .../opam/{yojson.3.0.0 => yojson.2.2.2}/opam | 11 +- package.json | 5 +- src/heap_type.c | 14 +++ src/heap_type.js | 34 ++++-- src/heap_type.ml | 2 + src/heap_type.mli | 2 + src/passes.ml | 14 +-- src/passes.mli | 14 +-- src/type.c | 14 +++ src/type.js | 48 +++++--- src/type.ml | 8 ++ src/type.mli | 2 + 17 files changed, 183 insertions(+), 114 deletions(-) rename esy.lock/opam/{ocaml-version.4.1.3 => ocaml-version.4.1.4}/opam (88%) rename esy.lock/opam/{uucp.17.0.0 => uucp.18.0.0}/opam (82%) rename esy.lock/opam/{uuseg.17.0.0 => uuseg.18.0.0}/opam (86%) rename esy.lock/opam/{yojson.3.0.0 => yojson.2.2.2}/opam (74%) diff --git a/binaryen.opam b/binaryen.opam index 817e8010..7f6e339d 100644 --- a/binaryen.opam +++ b/binaryen.opam @@ -16,6 +16,6 @@ depends: [ "dune" {>= "3.0.0"} "dune-configurator" {>= "3.0.0"} "js_of_ocaml-compiler" {>= "6.4.0" < "7.0.0"} - "libbinaryen" {>= "132.0.0" < "133.0.0"} + "libbinaryen" {>= "133.0.0" < "134.0.0"} ] x-maintenance-intent: ["0.(latest)"] diff --git a/esy.lock/index.json b/esy.lock/index.json index b52a8549..cc460fb9 100644 --- a/esy.lock/index.json +++ b/esy.lock/index.json @@ -1,5 +1,5 @@ { - "checksum": "1aeef89459a404e11b8d626c6bb90c12", + "checksum": "38db7bfd53e9889be55ce209233ee019", "root": "@grain/binaryen.ml@link-dev:./package.json", "node": { "ocaml@5.3.0@d41d8cd9": { @@ -22,29 +22,30 @@ [ "windows", "x86_64" ] ] }, - "@opam/yojson@opam:3.0.0@b2c9a6c1": { - "id": "@opam/yojson@opam:3.0.0@b2c9a6c1", + "@opam/yojson@opam:2.2.2@0786d153": { + "id": "@opam/yojson@opam:2.2.2@0786d153", "name": "@opam/yojson", - "version": "opam:3.0.0", + "version": "opam:2.2.2", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha256/99/99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610#sha256:99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610", - "archive:https://github.com/ocaml-community/yojson/releases/download/3.0.0/yojson-3.0.0.tbz#sha256:99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610" + "archive:https://opam.ocaml.org/cache/sha256/9a/9abfad8c9a79d4723ad2f6448e669c1e68dbfc87cc54a1b7c064b0c90912c595#sha256:9abfad8c9a79d4723ad2f6448e669c1e68dbfc87cc54a1b7c064b0c90912c595", + "archive:https://github.com/ocaml-community/yojson/releases/download/2.2.2/yojson-2.2.2.tbz#sha256:9abfad8c9a79d4723ad2f6448e669c1e68dbfc87cc54a1b7c064b0c90912c595" ], "opam": { "name": "yojson", - "version": "3.0.0", - "path": "esy.lock/opam/yojson.3.0.0" + "version": "2.2.2", + "path": "esy.lock/opam/yojson.2.2.2" } }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/dune@opam:3.24.2@dc9091c2", - "@esy-ocaml/substs@0.0.1@d41d8cd9" + "ocaml@5.3.0@d41d8cd9", "@opam/seq@opam:base@5ed5af70", + "@opam/dune@opam:3.24.2@dc9091c2", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/dune@opam:3.24.2@dc9091c2" + "ocaml@5.3.0@d41d8cd9", "@opam/seq@opam:base@5ed5af70", + "@opam/dune@opam:3.24.2@dc9091c2" ], "available": [ [ "darwin", "x86_64" ], @@ -116,33 +117,33 @@ [ "windows", "x86_64" ] ] }, - "@opam/uuseg@opam:17.0.0@52f3d276": { - "id": "@opam/uuseg@opam:17.0.0@52f3d276", + "@opam/uuseg@opam:18.0.0@e4b4a7ed": { + "id": "@opam/uuseg@opam:18.0.0@e4b4a7ed", "name": "@opam/uuseg", - "version": "opam:17.0.0", + "version": "opam:18.0.0", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha512/8d/8d81ca0a57516b94c66a0da256f3455ba26b0875ca9e354a665ec30223c9216be57abdd52c39c8c384fe127df8060c18ff07d92d4d9f53892bc4ed20699df3ef#sha512:8d81ca0a57516b94c66a0da256f3455ba26b0875ca9e354a665ec30223c9216be57abdd52c39c8c384fe127df8060c18ff07d92d4d9f53892bc4ed20699df3ef", - "archive:https://erratique.ch/software/uuseg/releases/uuseg-17.0.0.tbz#sha512:8d81ca0a57516b94c66a0da256f3455ba26b0875ca9e354a665ec30223c9216be57abdd52c39c8c384fe127df8060c18ff07d92d4d9f53892bc4ed20699df3ef" + "archive:https://opam.ocaml.org/cache/sha512/ff/ff7f8d2548e6fe887813d98dae8240236d9881354200bdcf6c8186a958bf9d95ccdc2a19ae31f1dffdf266adaabdc444ba7727c1e50c8a3f1f339b99427f92f1#sha512:ff7f8d2548e6fe887813d98dae8240236d9881354200bdcf6c8186a958bf9d95ccdc2a19ae31f1dffdf266adaabdc444ba7727c1e50c8a3f1f339b99427f92f1", + "archive:https://erratique.ch/software/uuseg/releases/uuseg-18.0.0.tbz#sha512:ff7f8d2548e6fe887813d98dae8240236d9881354200bdcf6c8186a958bf9d95ccdc2a19ae31f1dffdf266adaabdc444ba7727c1e50c8a3f1f339b99427f92f1" ], "opam": { "name": "uuseg", - "version": "17.0.0", - "path": "esy.lock/opam/uuseg.17.0.0" + "version": "18.0.0", + "path": "esy.lock/opam/uuseg.18.0.0" } }, "overrides": [], "dependencies": [ "ocaml@5.3.0@d41d8cd9", "@opam/uutf@opam:1.0.4@ba7fbef7", - "@opam/uucp@opam:17.0.0@843de755", "@opam/topkg@opam:1.1.1@2377d2f8", + "@opam/uucp@opam:18.0.0@942b0b80", "@opam/topkg@opam:1.1.1@2377d2f8", "@opam/ocamlfind@opam:1.9.8@c9de249d", "@opam/ocamlbuild@opam:0.16.1@6ccbffe8", "@opam/cmdliner@opam:2.1.1@071b019b", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/uucp@opam:17.0.0@843de755" + "ocaml@5.3.0@d41d8cd9", "@opam/uucp@opam:18.0.0@942b0b80" ], "available": [ [ "darwin", "x86_64" ], @@ -151,20 +152,20 @@ [ "windows", "x86_64" ] ] }, - "@opam/uucp@opam:17.0.0@843de755": { - "id": "@opam/uucp@opam:17.0.0@843de755", + "@opam/uucp@opam:18.0.0@942b0b80": { + "id": "@opam/uucp@opam:18.0.0@942b0b80", "name": "@opam/uucp", - "version": "opam:17.0.0", + "version": "opam:18.0.0", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/sha512/c2/c2b5c883c2ed1ee8e7bc9102339dfbca5940e68cd2af59a10abc827fb64c91ad03f85cfc12d4c79605c10e9b3a90743267af8b069143fefeeff6658ec8ed843f#sha512:c2b5c883c2ed1ee8e7bc9102339dfbca5940e68cd2af59a10abc827fb64c91ad03f85cfc12d4c79605c10e9b3a90743267af8b069143fefeeff6658ec8ed843f", - "archive:https://erratique.ch/software/uucp/releases/uucp-17.0.0.tbz#sha512:c2b5c883c2ed1ee8e7bc9102339dfbca5940e68cd2af59a10abc827fb64c91ad03f85cfc12d4c79605c10e9b3a90743267af8b069143fefeeff6658ec8ed843f" + "archive:https://opam.ocaml.org/cache/sha512/89/89047b5586244c6636e8ebef64c911cb830bfe4e3cb62a344a1938a934ef51fdde75418785dc46da6e9a8d0eec1bdd22d508b6c4a4b29f6a48a220c8f718ad9f#sha512:89047b5586244c6636e8ebef64c911cb830bfe4e3cb62a344a1938a934ef51fdde75418785dc46da6e9a8d0eec1bdd22d508b6c4a4b29f6a48a220c8f718ad9f", + "archive:https://erratique.ch/software/uucp/releases/uucp-18.0.0.tbz#sha512:89047b5586244c6636e8ebef64c911cb830bfe4e3cb62a344a1938a934ef51fdde75418785dc46da6e9a8d0eec1bdd22d508b6c4a4b29f6a48a220c8f718ad9f" ], "opam": { "name": "uucp", - "version": "17.0.0", - "path": "esy.lock/opam/uucp.17.0.0" + "version": "18.0.0", + "path": "esy.lock/opam/uucp.18.0.0" } }, "overrides": [], @@ -506,11 +507,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/dune@opam:3.24.2@dc9091c2", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/dune@opam:3.24.2@dc9091c2" ], "available": [ @@ -699,10 +700,10 @@ "overrides": [], "dependencies": [ "ocaml@5.3.0@d41d8cd9", "@opam/uutf@opam:1.0.4@ba7fbef7", - "@opam/uuseg@opam:17.0.0@52f3d276", + "@opam/uuseg@opam:18.0.0@e4b4a7ed", "@opam/stdio@opam:v0.17.0@80c625cc", "@opam/ocp-indent@opam:1.9.0@4c8ca689", - "@opam/ocaml-version@opam:4.1.3@41c3ecd9", + "@opam/ocaml-version@opam:4.1.4@1e413173", "@opam/menhirSdk@opam:20260209@1b57a7c9", "@opam/menhirLib@opam:20260209@f5704f2b", "@opam/menhir@opam:20260209@61084610", @@ -719,10 +720,10 @@ ], "devDependencies": [ "ocaml@5.3.0@d41d8cd9", "@opam/uutf@opam:1.0.4@ba7fbef7", - "@opam/uuseg@opam:17.0.0@52f3d276", + "@opam/uuseg@opam:18.0.0@e4b4a7ed", "@opam/stdio@opam:v0.17.0@80c625cc", "@opam/ocp-indent@opam:1.9.0@4c8ca689", - "@opam/ocaml-version@opam:4.1.3@41c3ecd9", + "@opam/ocaml-version@opam:4.1.4@1e413173", "@opam/menhirSdk@opam:20260209@1b57a7c9", "@opam/menhirLib@opam:20260209@f5704f2b", "@opam/menhir@opam:20260209@61084610", @@ -903,20 +904,20 @@ [ "windows", "x86_64" ] ] }, - "@opam/ocaml-version@opam:4.1.3@41c3ecd9": { - "id": "@opam/ocaml-version@opam:4.1.3@41c3ecd9", + "@opam/ocaml-version@opam:4.1.4@1e413173": { + "id": "@opam/ocaml-version@opam:4.1.4@1e413173", "name": "@opam/ocaml-version", - "version": "opam:4.1.3", + "version": "opam:4.1.4", "source": { "type": "install", "source": [ - "archive:https://opam.ocaml.org/cache/md5/86/867c6b0abd51a8a04781a495db97f2ea#md5:867c6b0abd51a8a04781a495db97f2ea", - "archive:https://github.com/ocurrent/ocaml-version/releases/download/v4.1.3/ocaml-version-4.1.3.tbz#md5:867c6b0abd51a8a04781a495db97f2ea" + "archive:https://opam.ocaml.org/cache/md5/16/16b2f5a111525588fc52655baf9c3d38#md5:16b2f5a111525588fc52655baf9c3d38", + "archive:https://github.com/ocurrent/ocaml-version/releases/download/v4.1.4/ocaml-version-4.1.4.tbz#md5:16b2f5a111525588fc52655baf9c3d38" ], "opam": { "name": "ocaml-version", - "version": "4.1.3", - "path": "esy.lock/opam/ocaml-version.4.1.3" + "version": "4.1.4", + "path": "esy.lock/opam/ocaml-version.4.1.4" } }, "overrides": [], @@ -952,7 +953,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/xdg@opam:3.24.2@cb11774c", "@opam/stdune@opam:3.20.2@c89dc074", "@opam/spawn@opam:v0.17.0@d0f69739", "@opam/re@opam:1.14.0@62aa9f42", @@ -975,7 +976,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/xdg@opam:3.24.2@cb11774c", "@opam/stdune@opam:3.20.2@c89dc074", "@opam/spawn@opam:v0.17.0@d0f69739", "@opam/re@opam:1.14.0@62aa9f42", @@ -1246,14 +1247,14 @@ }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/uutf@opam:1.0.4@ba7fbef7", "@opam/ppx_yojson_conv_lib@opam:v0.17.0@e7e988bb", "@opam/jsonrpc@opam:1.23.1@f2566740", "@opam/dune@opam:3.24.2@dc9091c2", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/uutf@opam:1.0.4@ba7fbef7", "@opam/ppx_yojson_conv_lib@opam:v0.17.0@e7e988bb", "@opam/jsonrpc@opam:1.23.1@f2566740", @@ -1284,11 +1285,11 @@ }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/dune@opam:3.24.2@dc9091c2", "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/dune@opam:3.24.2@dc9091c2" ], "available": [ @@ -1316,7 +1317,7 @@ }, "overrides": [], "dependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/sedlex@opam:3.7@7fb2caab", "@opam/ppxlib@opam:0.39.0~5.6preview@31af2f7c", "@opam/ocamlfind@opam:1.9.8@c9de249d", @@ -1329,7 +1330,7 @@ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], "devDependencies": [ - "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:3.0.0@b2c9a6c1", + "ocaml@5.3.0@d41d8cd9", "@opam/yojson@opam:2.2.2@0786d153", "@opam/sedlex@opam:3.7@7fb2caab", "@opam/ppxlib@opam:0.39.0~5.6preview@31af2f7c", "@opam/ocaml-compiler-libs@opam:v0.17.0@6bdcfede", @@ -1934,14 +1935,14 @@ [ "windows", "x86_64" ] ] }, - "@grain/libbinaryen@132.0.0@d41d8cd9": { - "id": "@grain/libbinaryen@132.0.0@d41d8cd9", + "@grain/libbinaryen@git:https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2@d41d8cd9": { + "id": "@grain/libbinaryen@git:https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2@d41d8cd9", "name": "@grain/libbinaryen", - "version": "132.0.0", + "version": "git:https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2", "source": { "type": "install", "source": [ - "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-132.0.0.tgz#sha1:6190c5ff61db997474fd8d0fbdb25c76fa65b4a1" + "git:https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2" ] }, "overrides": [], @@ -1974,7 +1975,7 @@ "ocaml@5.3.0@d41d8cd9", "@opam/dune-configurator@opam:3.24.2@7928eaef", "@opam/dune@opam:3.24.2@dc9091c2", - "@grain/libbinaryen@132.0.0@d41d8cd9" + "@grain/libbinaryen@git:https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2@d41d8cd9" ], "devDependencies": [ "@opam/ocamlformat@opam:0.29.0@966c16ee", diff --git a/esy.lock/opam/ocaml-version.4.1.3/opam b/esy.lock/opam/ocaml-version.4.1.4/opam similarity index 88% rename from esy.lock/opam/ocaml-version.4.1.3/opam rename to esy.lock/opam/ocaml-version.4.1.4/opam index 28d73f8e..577748af 100644 --- a/esy.lock/opam/ocaml-version.4.1.3/opam +++ b/esy.lock/opam/ocaml-version.4.1.4/opam @@ -45,10 +45,10 @@ build: [ dev-repo: "git+https://github.com/ocurrent/ocaml-version.git" url { src: - "https://github.com/ocurrent/ocaml-version/releases/download/v4.1.3/ocaml-version-4.1.3.tbz" + "https://github.com/ocurrent/ocaml-version/releases/download/v4.1.4/ocaml-version-4.1.4.tbz" checksum: [ - "md5=867c6b0abd51a8a04781a495db97f2ea" - "sha512=654c76169f8bccfa370a782684f5df753d5bfb37e23cb2f011e2591ea0b6bda1544d8454e9c6c2a74695892bb5a9155466e5d546763c0b07e18a61b3c061130c" + "md5=16b2f5a111525588fc52655baf9c3d38" + "sha512=646b021765fb078e65b0f373de9f1f2ca076f60995b6d137ba61ae0828905f9ffd4a81fe331ace3bc63d20d6a433bbd5f55a4f87d6e324f0985924113c59274f" ] } x-maintenance-intent: ["(latest)"] \ No newline at end of file diff --git a/esy.lock/opam/uucp.17.0.0/opam b/esy.lock/opam/uucp.18.0.0/opam similarity index 82% rename from esy.lock/opam/uucp.17.0.0/opam rename to esy.lock/opam/uucp.18.0.0/opam index a15cdee6..9514f4fb 100644 --- a/esy.lock/opam/uucp.17.0.0/opam +++ b/esy.lock/opam/uucp.18.0.0/opam @@ -21,12 +21,12 @@ depends: [ "ocamlfind" {build} "ocamlbuild" {build} "topkg" {build & >= "1.1.0"} - "uucd" {with-test & dev & >= "17.0.0" & < "18.0.0"} + "uucd" {with-test & dev & >= "18.0.0" & < "19.0.0"} "uunf" {with-test} ] depopts: ["uunf" "cmdliner"] conflicts: [ - "uunf" {< "17.0.0" | >= "18.0.0"} + "uunf" {< "18.0.0" | >= "19.0.0"} "cmdliner" {< "1.1.0"} ] build: [ @@ -45,8 +45,8 @@ post-messages: {failure & (arch = "ppc64" | arch = "arm64")} dev-repo: "git+https://erratique.ch/repos/uucp.git" url { - src: "https://erratique.ch/software/uucp/releases/uucp-17.0.0.tbz" + src: "https://erratique.ch/software/uucp/releases/uucp-18.0.0.tbz" checksum: - "sha512=c2b5c883c2ed1ee8e7bc9102339dfbca5940e68cd2af59a10abc827fb64c91ad03f85cfc12d4c79605c10e9b3a90743267af8b069143fefeeff6658ec8ed843f" + "sha512=89047b5586244c6636e8ebef64c911cb830bfe4e3cb62a344a1938a934ef51fdde75418785dc46da6e9a8d0eec1bdd22d508b6c4a4b29f6a48a220c8f718ad9f" } x-maintenance-intent: ["(latest)"] \ No newline at end of file diff --git a/esy.lock/opam/uuseg.17.0.0/opam b/esy.lock/opam/uuseg.18.0.0/opam similarity index 86% rename from esy.lock/opam/uuseg.17.0.0/opam rename to esy.lock/opam/uuseg.18.0.0/opam index 35d6cc6e..44847320 100644 --- a/esy.lock/opam/uuseg.17.0.0/opam +++ b/esy.lock/opam/uuseg.18.0.0/opam @@ -29,7 +29,7 @@ depends: [ "ocamlfind" {build} "ocamlbuild" {build} "topkg" {build & >= "1.1.0"} - "uucp" {>= "17.0.0" & < "18.0.0"} + "uucp" {>= "18.0.0" & < "19.0.0"} ] depopts: ["uutf" "cmdliner"] conflicts: [ @@ -49,8 +49,8 @@ build: [ ] dev-repo: "git+https://erratique.ch/repos/uuseg.git" url { - src: "https://erratique.ch/software/uuseg/releases/uuseg-17.0.0.tbz" + src: "https://erratique.ch/software/uuseg/releases/uuseg-18.0.0.tbz" checksum: - "sha512=8d81ca0a57516b94c66a0da256f3455ba26b0875ca9e354a665ec30223c9216be57abdd52c39c8c384fe127df8060c18ff07d92d4d9f53892bc4ed20699df3ef" + "sha512=ff7f8d2548e6fe887813d98dae8240236d9881354200bdcf6c8186a958bf9d95ccdc2a19ae31f1dffdf266adaabdc444ba7727c1e50c8a3f1f339b99427f92f1" } x-maintenance-intent: ["(latest)"] \ No newline at end of file diff --git a/esy.lock/opam/yojson.3.0.0/opam b/esy.lock/opam/yojson.2.2.2/opam similarity index 74% rename from esy.lock/opam/yojson.3.0.0/opam rename to esy.lock/opam/yojson.2.2.2/opam index 6946038b..1d971fe0 100644 --- a/esy.lock/opam/yojson.3.0.0/opam +++ b/esy.lock/opam/yojson.2.2.2/opam @@ -16,8 +16,9 @@ doc: "https://ocaml.org/p/yojson/latest" bug-reports: "https://github.com/ocaml-community/yojson/issues" depends: [ "dune" {>= "2.7"} - "ocaml" {>= "4.08"} + "ocaml" {>= "4.02.3"} "alcotest" {with-test & >= "0.8.5"} + "seq" {>= "0.2.2"} "odoc" {with-doc} ] build: [ @@ -37,10 +38,10 @@ build: [ dev-repo: "git+https://github.com/ocaml-community/yojson.git" url { src: - "https://github.com/ocaml-community/yojson/releases/download/3.0.0/yojson-3.0.0.tbz" + "https://github.com/ocaml-community/yojson/releases/download/2.2.2/yojson-2.2.2.tbz" checksum: [ - "sha256=99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610" - "sha512=896d0ea829a36ccadba6628800369c1a3ab9e7c64dbda8b76331889c9db481cd64e137f467481ae80a8dd5fca45d748bfa71f58641806cc1bb1a007f8291789f" + "sha256=9abfad8c9a79d4723ad2f6448e669c1e68dbfc87cc54a1b7c064b0c90912c595" + "sha512=ac52eae3ca1d3129a7885ca638e6ae5bcfc387598a82cc30d3e4988fd154f1756719c399f96e950d898c79a6dbd4ccc44b6f468bcafbd620e6945a0415b41e0c" ] } -x-commit-hash: "b2193e8e0c88c6501710d08b836b3219673383f3" +x-commit-hash: "3f82b79d1865eec82c6f498ee1835a90c74c31b4" diff --git a/package.json b/package.json index 0c09ad3f..dff823c2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "ocaml": ">= 4.14.0 < 6.0.0", - "@grain/libbinaryen": ">= 132.0.0 < 133.0.0", + "@grain/libbinaryen": "*", "@opam/dune": ">= 3.0.0", "@opam/dune-configurator": ">= 3.0.0" }, @@ -24,7 +24,8 @@ }, "resolutions": { "@opam/ocp-indent": "1.9.0", - "@opam/ocamlfind": "1.9.8" + "@opam/ocamlfind": "1.9.8", + "@grain/libbinaryen": "git+https://github.com/grain-lang/libbinaryen.git#f4ed1e3d7efac8851b43062575a4a3703f3634a2" }, "esy": { "build": "dune build -p binaryen" diff --git a/src/heap_type.c b/src/heap_type.c index b4a78bc6..b29c1d30 100644 --- a/src/heap_type.c +++ b/src/heap_type.c @@ -84,6 +84,20 @@ caml_binaryen_heap_type_nofunc(value unit) { CAMLreturn(alloc_BinaryenHeapType(ty)); } +CAMLprim value +caml_binaryen_heap_type_exn(value unit) { + CAMLparam1(unit); + BinaryenHeapType ty = BinaryenHeapTypeExn(); + CAMLreturn(alloc_BinaryenHeapType(ty)); +} + +CAMLprim value +caml_binaryen_heap_type_noexn(value unit) { + CAMLparam1(unit); + BinaryenHeapType ty = BinaryenHeapTypeNoexn(); + CAMLreturn(alloc_BinaryenHeapType(ty)); +} + CAMLprim value caml_binaryen_heap_type_is_basic(value _ty) { CAMLparam1(_ty); diff --git a/src/heap_type.js b/src/heap_type.js index acf0a30b..f2da597e 100644 --- a/src/heap_type.js +++ b/src/heap_type.js @@ -1,67 +1,79 @@ //Provides: caml_binaryen_heap_type_ext //Requires: Binaryen function caml_binaryen_heap_type_ext() { - return Binaryen._BinaryenHeapTypeExt(); + return Binaryen.HeapType.extern; } //Provides: caml_binaryen_heap_type_func //Requires: Binaryen function caml_binaryen_heap_type_func() { - return Binaryen._BinaryenHeapTypeFunc(); + return Binaryen.HeapType.func; } //Provides: caml_binaryen_heap_type_any //Requires: Binaryen function caml_binaryen_heap_type_any() { - return Binaryen._BinaryenHeapTypeAny(); + return Binaryen.HeapType.any; } //Provides: caml_binaryen_heap_type_eq //Requires: Binaryen function caml_binaryen_heap_type_eq() { - return Binaryen._BinaryenHeapTypeEq(); + return Binaryen.HeapType.eq; } //Provides: caml_binaryen_heap_type_i31 //Requires: Binaryen function caml_binaryen_heap_type_i31() { - return Binaryen._BinaryenHeapTypeI31(); + return Binaryen.HeapType.i31; } //Provides: caml_binaryen_heap_type_struct //Requires: Binaryen function caml_binaryen_heap_type_struct() { - return Binaryen._BinaryenHeapTypeStruct(); + return Binaryen.HeapType.struct; } //Provides: caml_binaryen_heap_type_array //Requires: Binaryen function caml_binaryen_heap_type_array() { - return Binaryen._BinaryenHeapTypeArray(); + return Binaryen.HeapType.array; } //Provides: caml_binaryen_heap_type_string //Requires: Binaryen function caml_binaryen_heap_type_string() { - return Binaryen._BinaryenHeapTypeString(); + return Binaryen.HeapType.string; } //Provides: caml_binaryen_heap_type_none //Requires: Binaryen function caml_binaryen_heap_type_none() { - return Binaryen._BinaryenHeapTypeNone(); + return Binaryen.HeapType.none; } //Provides: caml_binaryen_heap_type_noext //Requires: Binaryen function caml_binaryen_heap_type_noext() { - return Binaryen._BinaryenHeapTypeNoext(); + return Binaryen.HeapType.noextern; } //Provides: caml_binaryen_heap_type_nofunc //Requires: Binaryen function caml_binaryen_heap_type_nofunc() { - return Binaryen._BinaryenHeapTypeNofunc(); + return Binaryen.HeapType.nofunc; +} + +//Provides: caml_binaryen_heap_type_exn +//Requires: Binaryen +function caml_binaryen_heap_type_exn() { + return Binaryen.HeapType.exn; +} + +//Provides: caml_binaryen_heap_type_noexn +//Requires: Binaryen +function caml_binaryen_heap_type_noexn() { + return Binaryen.HeapType.noexn; } //Provides: caml_binaryen_heap_type_is_basic diff --git a/src/heap_type.ml b/src/heap_type.ml index 36ca38af..45231337 100644 --- a/src/heap_type.ml +++ b/src/heap_type.ml @@ -11,6 +11,8 @@ external string : unit -> t = "caml_binaryen_heap_type_string" external none : unit -> t = "caml_binaryen_heap_type_none" external noext : unit -> t = "caml_binaryen_heap_type_noext" external nofunc : unit -> t = "caml_binaryen_heap_type_nofunc" +external exn : unit -> t = "caml_binaryen_heap_type_exn" +external noexn : unit -> t = "caml_binaryen_heap_type_noexn" external is_basic : t -> bool = "caml_binaryen_heap_type_is_basic" external is_signature : t -> bool = "caml_binaryen_heap_type_is_signature" external is_struct : t -> bool = "caml_binaryen_heap_type_is_struct" diff --git a/src/heap_type.mli b/src/heap_type.mli index 471d1aa9..bdf25690 100644 --- a/src/heap_type.mli +++ b/src/heap_type.mli @@ -11,6 +11,8 @@ val string : unit -> t val none : unit -> t val noext : unit -> t val nofunc : unit -> t +val exn : unit -> t +val noexn : unit -> t val is_basic : t -> bool val is_signature : t -> bool val is_struct : t -> bool diff --git a/src/passes.ml b/src/passes.ml index 08783e45..b63c5b9a 100644 --- a/src/passes.ml +++ b/src/passes.ml @@ -216,7 +216,7 @@ let memory_packing = "memory-packing" (** merges blocks to their parents *) let merge_blocks = "merge-blocks" -(** merges similar functions when benefical *) +(** merges similar functions when beneficial *) let merge_similar_functions = "merge-similar-functions" (** merges locals when beneficial *) @@ -339,6 +339,9 @@ let remove_non_js_ops = "remove-non-js-ops" (** replaces relaxed SIMD instructions with unreachable *) let remove_relaxed_simd = "remove-relaxed-simd" +(** removes exports of empty functions *) +let remove_empty_function_exports = "remove-empty-function-exports" + (** removes exports using a wildcard *) let remove_exports = "remove-exports" @@ -474,6 +477,9 @@ let strip = "strip" (** enforce limits on llvm's __stack_pointer global *) let stack_check = "stack-check" +(** convert calls in tail position to return calls *) +let tail_call = "tail-call" + (** strip debug info (including the names section) *) let strip_debug = "strip-debug" @@ -495,12 +501,6 @@ let strip_toolchain_annotations = "strip-toolchain-annotations" (** translate old Phase 3 EH instructions to new ones with exnref *) let translate_to_exnref = "translate-to-exnref" -(** replace trapping operations with clamping semantics *) -let trap_mode_clamp = "trap-mode-clamp" - -(** replace trapping operations with js semantics *) -let trap_mode_js = "trap-mode-js" - (** optimize trivial tuples away *) let tuple_optimization = "tuple-optimization" diff --git a/src/passes.mli b/src/passes.mli index 52ff4706..c522cefc 100644 --- a/src/passes.mli +++ b/src/passes.mli @@ -214,7 +214,7 @@ val merge_blocks : t (** merges blocks to their parents *) val merge_similar_functions : t -(** merges similar functions when benefical *) +(** merges similar functions when beneficial *) val merge_locals : t (** merges locals when beneficial *) @@ -334,6 +334,9 @@ val remove_non_js_ops : t val remove_relaxed_simd : t (** replaces relaxed SIMD instructions with unreachable *) +val remove_empty_function_exports : t +(** removes exports of empty functions *) + val remove_exports : t (** removes exports using a wildcard *) @@ -466,6 +469,9 @@ val strip : t val stack_check : t (** enforce limits on llvm's __stack_pointer global *) +val tail_call : t +(** convert calls in tail position to return calls *) + val strip_debug : t (** strip debug info (including the names section) *) @@ -487,12 +493,6 @@ val strip_toolchain_annotations : t val translate_to_exnref : t (** translate old Phase 3 EH instructions to new ones with exnref *) -val trap_mode_clamp : t -(** replace trapping operations with clamping semantics *) - -val trap_mode_js : t -(** replace trapping operations with js semantics *) - val tuple_optimization : t (** optimize trivial tuples away *) diff --git a/src/type.c b/src/type.c index e8303ca5..06f435fe 100644 --- a/src/type.c +++ b/src/type.c @@ -118,6 +118,20 @@ caml_binaryen_type_null_funcref(value unit) { CAMLreturn(alloc_BinaryenType(ty)); } +CAMLprim value +caml_binaryen_type_exnref(value unit) { + CAMLparam1(unit); + BinaryenType ty = BinaryenTypeExnref(); + CAMLreturn(alloc_BinaryenType(ty)); +} + +CAMLprim value +caml_binaryen_type_null_exnref(value unit) { + CAMLparam1(unit); + BinaryenType ty = BinaryenTypeNullExnref(); + CAMLreturn(alloc_BinaryenType(ty)); +} + CAMLprim value caml_binaryen_type_unreachable(value unit) { CAMLparam1(unit); diff --git a/src/type.js b/src/type.js index 9100766b..c4b7511f 100644 --- a/src/type.js +++ b/src/type.js @@ -1,109 +1,121 @@ //Provides: caml_binaryen_type_none //Requires: Binaryen function caml_binaryen_type_none() { - return Binaryen.none; + return Binaryen.Type.none; } //Provides: caml_binaryen_type_int32 //Requires: Binaryen function caml_binaryen_type_int32() { - return Binaryen.i32; + return Binaryen.Type.i32; } //Provides: caml_binaryen_type_int64 //Requires: Binaryen function caml_binaryen_type_int64() { - return Binaryen.i64; + return Binaryen.Type.i64; } //Provides: caml_binaryen_type_float32 //Requires: Binaryen function caml_binaryen_type_float32() { - return Binaryen.f32; + return Binaryen.Type.f32; } //Provides: caml_binaryen_type_float64 //Requires: Binaryen function caml_binaryen_type_float64() { - return Binaryen.f64; + return Binaryen.Type.f64; } //Provides: caml_binaryen_type_vec128 //Requires: Binaryen function caml_binaryen_type_vec128() { - return Binaryen.v128; + return Binaryen.Type.v128; } //Provides: caml_binaryen_type_funcref //Requires: Binaryen function caml_binaryen_type_funcref() { - return Binaryen.funcref; + return Binaryen.Type.funcref; } //Provides: caml_binaryen_type_anyref //Requires: Binaryen function caml_binaryen_type_anyref() { - return Binaryen.anyref; + return Binaryen.Type.anyref; } //Provides: caml_binaryen_type_eqref //Requires: Binaryen function caml_binaryen_type_eqref() { - return Binaryen.eqref; + return Binaryen.Type.eqref; } //Provides: caml_binaryen_type_i31ref //Requires: Binaryen function caml_binaryen_type_i31ref() { - return Binaryen.i31ref; + return Binaryen.Type.i31ref; } //Provides: caml_binaryen_type_structref //Requires: Binaryen function caml_binaryen_type_structref() { - return Binaryen.structref; + return Binaryen.Type.structref; } //Provides: caml_binaryen_type_arrayref //Requires: Binaryen function caml_binaryen_type_arrayref() { - return Binaryen.arrayref; + return Binaryen.Type.arrayref; } //Provides: caml_binaryen_type_stringref //Requires: Binaryen function caml_binaryen_type_stringref() { - return Binaryen.stringref; + return Binaryen.Type.stringref; } //Provides: caml_binaryen_type_nullref //Requires: Binaryen function caml_binaryen_type_nullref() { - return Binaryen.nullref; + return Binaryen.Type.nullref; } //Provides: caml_binaryen_type_null_externref //Requires: Binaryen function caml_binaryen_type_null_externref() { - return Binaryen.nullexternref; + return Binaryen.Type.nullexternref; } //Provides: caml_binaryen_type_null_funcref //Requires: Binaryen function caml_binaryen_type_null_funcref() { - return Binaryen.nullfuncref; + return Binaryen.Type.nullfuncref; +} + +//Provides: caml_binaryen_type_exnref +//Requires: Binaryen +function caml_binaryen_type_exnref() { + return Binaryen.Type.exnref; +} + +//Provides: caml_binaryen_type_null_exnref +//Requires: Binaryen +function caml_binaryen_type_null_exnref() { + return Binaryen.Type.nullexnref; } //Provides: caml_binaryen_type_unreachable //Requires: Binaryen function caml_binaryen_type_unreachable() { - return Binaryen.unreachable; + return Binaryen.Type.unreachable; } //Provides: caml_binaryen_type_auto //Requires: Binaryen function caml_binaryen_type_auto() { - return Binaryen.auto; + return Binaryen.Type.auto; } //Provides: caml_binaryen_type_create diff --git a/src/type.ml b/src/type.ml index 8090acb6..9aafdfc0 100644 --- a/src/type.ml +++ b/src/type.ml @@ -64,6 +64,14 @@ external null_funcref : unit -> t = "caml_binaryen_type_null_funcref" let null_funcref = null_funcref () +external exnref : unit -> t = "caml_binaryen_type_exnref" + +let exnref = exnref () + +external null_exnref : unit -> t = "caml_binaryen_type_null_exnref" + +let null_exnref = null_exnref () + external unreachable : unit -> t = "caml_binaryen_type_unreachable" let unreachable = unreachable () diff --git a/src/type.mli b/src/type.mli index 868ac579..34b5a692 100644 --- a/src/type.mli +++ b/src/type.mli @@ -16,6 +16,8 @@ val stringref : t val nullref : t val null_externref : t val null_funcref : t +val exnref : t +val null_exnref : t val unreachable : t val auto : t val create : t array -> t From 9bde6f5b44cca297da80856109dd98871d90e390 Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Wed, 23 Sep 2026 15:57:39 -0400 Subject: [PATCH 2/3] fix: Correct `BinaryenRefNull` type It seems the ci errors we were getting is because the underyling type of `BinaryenRefNull` changed to take a `HeapType` instead of a regular type however the c api wasn't updated. --- src/expression.ml | 2 +- src/expression.mli | 2 +- test/test.ml | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/expression.ml b/src/expression.ml index db7807b3..442dd12a 100644 --- a/src/expression.ml +++ b/src/expression.ml @@ -853,7 +853,7 @@ module Null = struct end module Ref = struct - external null : Module.t -> Type.t -> t = "caml_binaryen_ref_null" + external null : Module.t -> Heap_type.t -> t = "caml_binaryen_ref_null" (** Module, type *) external is_null : Module.t -> t -> t = "caml_binaryen_ref_is_null" diff --git a/src/expression.mli b/src/expression.mli index bd647ac7..5493ce52 100644 --- a/src/expression.mli +++ b/src/expression.mli @@ -349,7 +349,7 @@ module Null : sig end module Ref : sig - val null : Module.t -> Type.t -> t + val null : Module.t -> Heap_type.t -> t (** Module, type *) val is_null : Module.t -> t -> t diff --git a/test/test.ml b/test/test.ml index 2f3f1cb2..41cc9202 100644 --- a/test/test.ml +++ b/test/test.ml @@ -195,7 +195,7 @@ let table_size = Expression.Table.size wasm_mod "table" let _ = Expression.print table_size let table_name = Expression.Table_size.get_table table_size let _ = Expression.Table_size.set_table table_size table_name -let null_ref = Expression.Ref.null wasm_mod Type.funcref +let null_ref = Expression.Ref.null wasm_mod (Heap_type.func ()) let table_grow = Expression.Table.grow wasm_mod "table" null_ref @@ -456,9 +456,7 @@ let _ = let cons first rest = Expression.Struct.new_ wasm_mod (Some [ first; rest ]) list_type in - let empty () = - Expression.Ref.null wasm_mod (Type.from_heap_type list_type true) - in + let empty () = Expression.Ref.null wasm_mod list_type in Function.add_function wasm_mod "gc" Type.anyref (Type.create [| Type.anyref; Type.anyref |]) [| From d46150158d58af998c6d69137eb1e794011e404f Mon Sep 17 00:00:00 2001 From: Spotandjake Date: Wed, 23 Sep 2026 16:02:34 -0400 Subject: [PATCH 3/3] fix: Correct js types --- src/expression.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/expression.js b/src/expression.js index d9b3d5ae..94b1e316 100644 --- a/src/expression.js +++ b/src/expression.js @@ -210,7 +210,7 @@ function caml_binaryen_load( var name = caml_jsstring_of_string(memoryName); switch (typ) { - case Binaryen.i32: { + case Binaryen.Type.i32: { // Using four bytes doesn't matter if it is signed or unsigned if (bytes === 4) { return wasm_mod.i32.load(offset, align, ptr, name); @@ -236,7 +236,7 @@ function caml_binaryen_load( break; } - case Binaryen.i64: { + case Binaryen.Type.i64: { // Using eight bytes doesn't matter if it is signed or unsigned if (bytes === 8) { return wasm_mod.i64.load(offset, align, ptr, name); @@ -270,13 +270,13 @@ function caml_binaryen_load( break; } - case Binaryen.f32: { + case Binaryen.Type.f32: { return wasm_mod.f32.load(offset, align, ptr, name); } - case Binaryen.f64: { + case Binaryen.Type.f64: { return wasm_mod.f64.load(offset, align, ptr, name); } - case Binaryen.v128: { + case Binaryen.Type.v128: { return wasm_mod.v128.load(offset, align, ptr, name); } default: { @@ -316,7 +316,7 @@ function caml_binaryen_store( var name = caml_jsstring_of_string(memoryName); switch (typ) { - case Binaryen.i32: { + case Binaryen.Type.i32: { if (bytes === 4) { return wasm_mod.i32.store(offset, align, ptr, value, name); } @@ -331,7 +331,7 @@ function caml_binaryen_store( break; } - case Binaryen.i64: { + case Binaryen.Type.i64: { if (bytes === 8) { return wasm_mod.i64.store(offset, align, ptr, value, name); } @@ -350,13 +350,13 @@ function caml_binaryen_store( break; } - case Binaryen.f32: { + case Binaryen.Type.f32: { return wasm_mod.f32.store(offset, align, ptr, value, name); } - case Binaryen.f64: { + case Binaryen.Type.f64: { return wasm_mod.f64.store(offset, align, ptr, value, name); } - case Binaryen.v128: { + case Binaryen.Type.v128: { return wasm_mod.v128.store(offset, align, ptr, value, name); } default: {