Skip to content

Commit b47cea0

Browse files
committed
feat!: Upgrade to Binaryen v126
Full Diff: WebAssembly/binaryen@version_125...version_126 Ocaml Summary: * `Feature.relaxed_atomics` was implented * The following passes were added `Passes.gsi_desc_cast`, `Passes.remove_relaxed_simd`, `Passes.strip_toolchain_annotations` * `Passes.jspi` was removed. * Internally `Binaryen.arrayref` was exposed directly through the js api * Internally `module.updateMaps()` is now provided by the js api allowing us to properly handle `Module.update_maps` through jsoo compilations Disregarded Change Summary: * MemoryOrder was added throughout the atomics api however since we do not implement the atomics api no changes have been made to binaryen.ml * More `TableRef` api functions were exposed through the js api however since we don't currently implement the api for tablerefs these are not being added in this pr we should open an issue before merging this to implement that api. * `BinaryenReturnCallRef` was added to the c api along with `module.call_ref` and `module.return_call_ref` in the js api however these are being left to the gc pr * The `Call_ref` api was imlemented however we are leaving this as well to the gc pr.
1 parent 4dbd1b3 commit b47cea0

File tree

11 files changed

+50
-22
lines changed

11 files changed

+50
-22
lines changed

binaryen.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ depends: [
1616
"dune" {>= "3.0.0"}
1717
"dune-configurator" {>= "3.0.0"}
1818
"js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"}
19-
"libbinaryen" {>= "125.0.0" < "126.0.0"}
19+
"libbinaryen" {>= "126.0.0" < "127.0.0"}
2020
]
2121
x-maintenance-intent: ["0.(latest)"]

esy.lock/index.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"dependencies": {
88
"ocaml": ">= 4.13.0 < 5.4.0",
9-
"@grain/libbinaryen": ">= 125.0.0 < 126.0.0",
9+
"@grain/libbinaryen": ">= 126.0.0 < 127.0.0",
1010
"@opam/dune": ">= 3.0.0",
1111
"@opam/dune-configurator": ">= 3.0.0"
1212
},
@@ -16,7 +16,8 @@
1616
"@opam/ocaml-lsp-server": ">= 1.9.1 < 2.0.0"
1717
},
1818
"resolutions": {
19-
"@opam/ocp-indent": "1.7.0"
19+
"@opam/ocp-indent": "1.7.0",
20+
"@grain/libbinaryen": "git+https://www.github.com/spotandjake/libbinaryen.git#c596fe826ccb9edd91e060becb6284a2d429ea6d"
2021
},
2122
"esy": {
2223
"build": "dune build -p binaryen"

src/module.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,5 @@ function caml_binaryen_add_custom_section(wasm_mod, name, contents) {
132132

133133
//Provides: caml_binaryen_module_update_maps
134134
function caml_binaryen_module_update_maps(wasm_mod) {
135-
// The JS version doesn't expose `update_maps`
136-
return;
135+
return wasm_mod.updateMaps();
137136
}

src/module.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ module Feature = struct
9898

9999
let call_indirect_overlong = call_indirect_overlong ()
100100

101+
external relaxed_atomics : unit -> t = "caml_binaryen_feature_relaxed_atomics"
102+
103+
let relaxed_atomics = relaxed_atomics ()
104+
101105
external all : unit -> t = "caml_binaryen_feature_all"
102106

103107
let all = all ()

src/module.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module Feature : sig
2525
val fp16 : t
2626
val bulk_memory_opt : t
2727
val call_indirect_overlong : t
28+
val relaxed_atomics : t
2829
val all : t
2930
end
3031

src/module_feature.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ caml_binaryen_feature_call_indirect_overlong(value unit) {
155155
CAMLreturn(Val_int(BinaryenFeatureCallIndirectOverlong()));
156156
}
157157

158+
CAMLprim value
159+
caml_binaryen_feature_relaxed_atomics(value unit) {
160+
CAMLparam1(unit);
161+
CAMLreturn(Val_int(BinaryenFeatureRelaxedAtomics()));
162+
}
163+
158164
CAMLprim value
159165
caml_binaryen_feature_all(value unit) {
160166
CAMLparam1(unit);

src/module_feature.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ function caml_binaryen_feature_call_indirect_overlong() {
140140
return Binaryen.Features.BulkMemoryOpt;
141141
}
142142

143+
//Provides: caml_binaryen_feature_relaxed_atomics
144+
//Requires: Binaryen
145+
function caml_binaryen_feature_relaxed_atomics() {
146+
return Binaryen.Features.RelaxedAtomics;
147+
}
148+
143149
//Provides: caml_binaryen_feature_all
144150
//Requires: Binaryen
145151
function caml_binaryen_feature_all() {

src/passes.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ let generate_global_effects = "generate-global-effects"
106106
(** refine the types of globals *)
107107
let global_refining = "global-refining"
108108

109+
(** globally optimize struct values, also emitting ref.cast_desc_eq *)
110+
let gsi_desc_cast = "gsi-desc-cast"
111+
109112
(** globally optimize struct values *)
110113
let gsi = "gsi"
111114

@@ -152,9 +155,6 @@ let inlining_optimizing = "inlining-optimizing"
152155
(** lower away binaryen intrinsics *)
153156
let intrinsic_lowering = "intrinsic-lowering"
154157

155-
(** wrap imports and exports for JavaScript promise integration *)
156-
let jspi = "jspi"
157-
158158
(** legalizes i64 types on the import/export boundary *)
159159
let legalize_js_interface = "legalize-js-interface"
160160

@@ -321,6 +321,9 @@ let symbolmap = "symbolmap"
321321
(** removes operations incompatible with js *)
322322
let remove_non_js_ops = "remove-non-js-ops"
323323

324+
(** replaces relaxed SIMD instructions with unreachable *)
325+
let remove_relaxed_simd = "remove-relaxed-simd"
326+
324327
(** removes imports and replaces them with nops *)
325328
let remove_imports = "remove-imports"
326329

@@ -468,6 +471,9 @@ let strip_eh = "strip-eh"
468471
(** strip the wasm target features section *)
469472
let strip_target_features = "strip-target-features"
470473

474+
(** strip all toolchain-specific code annotations *)
475+
let strip_toolchain_annotations = "strip-toolchain-annotations"
476+
471477
(** translate old Phase 3 EH instructions to new ones with exnref *)
472478
let translate_to_exnref = "translate-to-exnref"
473479

@@ -486,7 +492,7 @@ let type_finalizing = "type-finalizing"
486492
(** merge types to their supertypes where possible *)
487493
let type_merging = "type-merging"
488494

489-
(** create new nominal types to help other optimizations *)
495+
(** create new types to help other optimizations *)
490496
let type_ssa = "type-ssa"
491497

492498
(** mark all types as non-final (open) *)

src/passes.mli

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ val generate_global_effects : t
106106
val global_refining : t
107107
(** refine the types of globals *)
108108

109+
val gsi_desc_cast : t
110+
(** globally optimize struct values, also emitting ref.cast_desc_eq *)
111+
109112
val gsi : t
110113
(** globally optimize struct values *)
111114

@@ -149,9 +152,6 @@ val inlining_optimizing : t
149152
val intrinsic_lowering : t
150153
(** lower away binaryen intrinsics *)
151154

152-
val jspi : t
153-
(** wrap imports and exports for JavaScript promise integration *)
154-
155155
val legalize_js_interface : t
156156
(** legalizes i64 types on the import/export boundary *)
157157

@@ -316,6 +316,9 @@ val symbolmap : t
316316
val remove_non_js_ops : t
317317
(** removes operations incompatible with js *)
318318

319+
val remove_relaxed_simd : t
320+
(** replaces relaxed SIMD instructions with unreachable *)
321+
319322
val remove_imports : t
320323
(** removes imports and replaces them with nops *)
321324

@@ -352,7 +355,7 @@ val reorder_globals : t
352355
val reorder_locals : t
353356
(** sorts locals by access frequency *)
354357

355-
val reorder_types: t
358+
val reorder_types : t
356359
(** sorts private types by access frequency *)
357360

358361
val rereloop : t
@@ -460,6 +463,9 @@ val strip_eh : t
460463
val strip_target_features : t
461464
(** strip the wasm target features section *)
462465

466+
val strip_toolchain_annotations : t
467+
(** strip all toolchain-specific code annotations *)
468+
463469
val translate_to_exnref : t
464470
(** translate old Phase 3 EH instructions to new ones with exnref *)
465471

@@ -479,7 +485,7 @@ val type_merging : t
479485
(** merge types to their supertypes where possible *)
480486

481487
val type_ssa : t
482-
(** create new nominal types to help other optimizations *)
488+
(** create new types to help other optimizations *)
483489

484490
val type_unfinalizing : t
485491
(** mark all types as non-final (open) *)

0 commit comments

Comments
 (0)