@grain/binaryen.ml 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.33.0](https://github.com/grain-lang/binaryen.ml/compare/v0.32.0...v0.33.0) (2025-11-12)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Upgrade to Binaryen v123 ([#256](https://github.com/grain-lang/binaryen.ml/issues/256))
9
+
10
+ ### Features
11
+
12
+ * Implement optimization settings api ([#243](https://github.com/grain-lang/binaryen.ml/issues/243)) ([1f25caf](https://github.com/grain-lang/binaryen.ml/commit/1f25cafc96a1f6969a1ecca8ea778aeefae893a8))
13
+ * Upgrade to Binaryen v123 ([#256](https://github.com/grain-lang/binaryen.ml/issues/256)) ([dd6bfa7](https://github.com/grain-lang/binaryen.ml/commit/dd6bfa7bd1c072b33bbc1731a046d169ceb9ea39))
14
+
3
15
  ## [0.32.0](https://github.com/grain-lang/binaryen.ml/compare/v0.31.0...v0.32.0) (2025-11-12)
4
16
 
5
17
 
@@ -1,5 +1,5 @@
1
1
  opam-version: "2.0"
2
- version: "0.32.0"
2
+ version: "0.33.0"
3
3
  synopsis: "OCaml bindings for Binaryen"
4
4
  maintainer: "oscar@grain-lang.org"
5
5
  author: "Oscar Spencer"
@@ -16,6 +16,6 @@ depends: [
16
16
  "dune" {>= "3.0.0"}
17
17
  "dune-configurator" {>= "3.0.0"}
18
18
  "js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"}
19
- "libbinaryen" {>= "122.0.1" < "123.0.0"}
19
+ "libbinaryen" {>= "123.0.1" < "124.0.0"}
20
20
  ]
21
21
  x-maintenance-intent: ["0.(latest)"]
@@ -1,5 +1,5 @@
1
1
  {
2
- "checksum": "55b439676e74c57977482d2499504bd2",
2
+ "checksum": "155674e15af22e7cb1432c6d5b252eee",
3
3
  "root": "@grain/binaryen.ml@link-dev:./package.json",
4
4
  "node": {
5
5
  "ocaml@5.3.0@d41d8cd9": {
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "overrides": [],
104
104
  "dependencies": [
105
- "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.0@fa72996d",
105
+ "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.1@2377d2f8",
106
106
  "@opam/ocamlfind@opam:1.9.8@ee910ff5",
107
107
  "@opam/ocamlbuild@opam:0.16.1@b3fc8209",
108
108
  "@opam/cmdliner@opam:1.3.0@8e6dd99f",
@@ -135,7 +135,7 @@
135
135
  "overrides": [],
136
136
  "dependencies": [
137
137
  "ocaml@5.3.0@d41d8cd9", "@opam/uutf@opam:1.0.4@ba7fbef7",
138
- "@opam/uucp@opam:17.0.0@843de755", "@opam/topkg@opam:1.1.0@fa72996d",
138
+ "@opam/uucp@opam:17.0.0@843de755", "@opam/topkg@opam:1.1.1@2377d2f8",
139
139
  "@opam/ocamlfind@opam:1.9.8@ee910ff5",
140
140
  "@opam/ocamlbuild@opam:0.16.1@b3fc8209",
141
141
  "@opam/cmdliner@opam:1.3.0@8e6dd99f",
@@ -169,7 +169,7 @@
169
169
  },
170
170
  "overrides": [],
171
171
  "dependencies": [
172
- "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.0@fa72996d",
172
+ "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.1@2377d2f8",
173
173
  "@opam/ocamlfind@opam:1.9.8@ee910ff5",
174
174
  "@opam/ocamlbuild@opam:0.16.1@b3fc8209",
175
175
  "@opam/cmdliner@opam:1.3.0@8e6dd99f",
@@ -183,20 +183,20 @@
183
183
  [ "windows", "x86_64" ]
184
184
  ]
185
185
  },
186
- "@opam/topkg@opam:1.1.0@fa72996d": {
187
- "id": "@opam/topkg@opam:1.1.0@fa72996d",
186
+ "@opam/topkg@opam:1.1.1@2377d2f8": {
187
+ "id": "@opam/topkg@opam:1.1.1@2377d2f8",
188
188
  "name": "@opam/topkg",
189
- "version": "opam:1.1.0",
189
+ "version": "opam:1.1.1",
190
190
  "source": {
191
191
  "type": "install",
192
192
  "source": [
193
- "archive:https://opam.ocaml.org/cache/sha512/34/34d22ae5b6bd166dd4a601a7d12d89c336684b3c56d7c7f481b40837eab263616cc3a6e6f63602f3d4a7d53c911967bf261de6c1ac205341b98a9838e5ea7aeb#sha512:34d22ae5b6bd166dd4a601a7d12d89c336684b3c56d7c7f481b40837eab263616cc3a6e6f63602f3d4a7d53c911967bf261de6c1ac205341b98a9838e5ea7aeb",
194
- "archive:https://erratique.ch/software/topkg/releases/topkg-1.1.0.tbz#sha512:34d22ae5b6bd166dd4a601a7d12d89c336684b3c56d7c7f481b40837eab263616cc3a6e6f63602f3d4a7d53c911967bf261de6c1ac205341b98a9838e5ea7aeb"
193
+ "archive:https://opam.ocaml.org/cache/sha512/c3/c36c549a362ddf5b7fe3f6ff91c79b7ab531c43633bb9737576370bcbd69db7e1625d247c278a869b503d45a175e9753231ccf595e5bfa4e3b7e2602ac3d3b42#sha512:c36c549a362ddf5b7fe3f6ff91c79b7ab531c43633bb9737576370bcbd69db7e1625d247c278a869b503d45a175e9753231ccf595e5bfa4e3b7e2602ac3d3b42",
194
+ "archive:https://erratique.ch/software/topkg/releases/topkg-1.1.1.tbz#sha512:c36c549a362ddf5b7fe3f6ff91c79b7ab531c43633bb9737576370bcbd69db7e1625d247c278a869b503d45a175e9753231ccf595e5bfa4e3b7e2602ac3d3b42"
195
195
  ],
196
196
  "opam": {
197
197
  "name": "topkg",
198
- "version": "1.1.0",
199
- "path": "esy.lock/opam/topkg.1.1.0"
198
+ "version": "1.1.1",
199
+ "path": "esy.lock/opam/topkg.1.1.1"
200
200
  }
201
201
  },
202
202
  "overrides": [],
@@ -1394,7 +1394,7 @@
1394
1394
  },
1395
1395
  "overrides": [],
1396
1396
  "dependencies": [
1397
- "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.0@fa72996d",
1397
+ "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.1@2377d2f8",
1398
1398
  "@opam/ocamlfind@opam:1.9.8@ee910ff5",
1399
1399
  "@opam/ocamlbuild@opam:0.16.1@b3fc8209",
1400
1400
  "@opam/astring@opam:0.8.5@9975798d",
@@ -1947,7 +1947,7 @@
1947
1947
  },
1948
1948
  "overrides": [],
1949
1949
  "dependencies": [
1950
- "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.0@fa72996d",
1950
+ "ocaml@5.3.0@d41d8cd9", "@opam/topkg@opam:1.1.1@2377d2f8",
1951
1951
  "@opam/ocamlfind@opam:1.9.8@ee910ff5",
1952
1952
  "@opam/ocamlbuild@opam:0.16.1@b3fc8209",
1953
1953
  "@esy-ocaml/substs@0.0.1@d41d8cd9"
@@ -1960,14 +1960,14 @@
1960
1960
  [ "windows", "x86_64" ]
1961
1961
  ]
1962
1962
  },
1963
- "@grain/libbinaryen@122.0.0@d41d8cd9": {
1964
- "id": "@grain/libbinaryen@122.0.0@d41d8cd9",
1963
+ "@grain/libbinaryen@123.0.1@d41d8cd9": {
1964
+ "id": "@grain/libbinaryen@123.0.1@d41d8cd9",
1965
1965
  "name": "@grain/libbinaryen",
1966
- "version": "122.0.0",
1966
+ "version": "123.0.1",
1967
1967
  "source": {
1968
1968
  "type": "install",
1969
1969
  "source": [
1970
- "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-122.0.0.tgz#sha1:63c01c799e798e88fbf86c60a5b4b151c062e635"
1970
+ "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-123.0.1.tgz#sha1:5d4c992f6761d67d7d297bb48f0f4093ab5328e4"
1971
1971
  ]
1972
1972
  },
1973
1973
  "overrides": [],
@@ -1999,7 +1999,7 @@
1999
1999
  "ocaml@5.3.0@d41d8cd9",
2000
2000
  "@opam/dune-configurator@opam:3.20.2@7eb6ff01",
2001
2001
  "@opam/dune@opam:3.20.2@8daef28d",
2002
- "@grain/libbinaryen@122.0.0@d41d8cd9"
2002
+ "@grain/libbinaryen@123.0.1@d41d8cd9"
2003
2003
  ],
2004
2004
  "devDependencies": [
2005
2005
  "@opam/ocamlformat@opam:0.27.0@c40d4612",
@@ -43,8 +43,8 @@ depends: [
43
43
  build: ["ocaml" "pkg/pkg.ml" "build" "--pkg-name" name "--dev-pkg" "%{dev}%"]
44
44
  dev-repo: "git+https://erratique.ch/repos/topkg.git"
45
45
  url {
46
- src: "https://erratique.ch/software/topkg/releases/topkg-1.1.0.tbz"
46
+ src: "https://erratique.ch/software/topkg/releases/topkg-1.1.1.tbz"
47
47
  checksum:
48
- "sha512=34d22ae5b6bd166dd4a601a7d12d89c336684b3c56d7c7f481b40837eab263616cc3a6e6f63602f3d4a7d53c911967bf261de6c1ac205341b98a9838e5ea7aeb"
48
+ "sha512=c36c549a362ddf5b7fe3f6ff91c79b7ab531c43633bb9737576370bcbd69db7e1625d247c278a869b503d45a175e9753231ccf595e5bfa4e3b7e2602ac3d3b42"
49
49
  }
50
50
  x-maintenance-intent: ["(latest)"]
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@grain/binaryen.ml",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "OCaml bindings for Binaryen.",
5
5
  "author": "Oscar Spencer <oscar@grain-lang.org>",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
8
  "ocaml": ">= 4.13.0 < 5.4.0",
9
- "@grain/libbinaryen": ">= 122.0.0 < 123.0.0",
9
+ "@grain/libbinaryen": ">= 123.0.0 < 124.0.0",
10
10
  "@opam/dune": ">= 3.0.0",
11
11
  "@opam/dune-configurator": ">= 3.0.0"
12
12
  },
@@ -1868,7 +1868,7 @@ caml_binaryen_ref_func(value _module, value _name, value _ty) {
1868
1868
  CAMLparam3(_module, _name, _ty);
1869
1869
  BinaryenModuleRef module = BinaryenModuleRef_val(_module);
1870
1870
  char* name = Safe_String_val(_name);
1871
- BinaryenType ty = BinaryenType_val(_ty);
1871
+ BinaryenHeapType ty = BinaryenHeapType_val(_ty);
1872
1872
  BinaryenExpressionRef exp = BinaryenRefFunc(module, name, ty);
1873
1873
  CAMLreturn(alloc_BinaryenExpressionRef(exp));
1874
1874
  }
@@ -824,7 +824,8 @@ module Ref = struct
824
824
  external as_ : Module.t -> Op.t -> t -> t = "caml_binaryen_ref_as"
825
825
  (** Module, op, value *)
826
826
 
827
- external func : Module.t -> string -> Type.t -> t = "caml_binaryen_ref_func"
827
+ external func : Module.t -> string -> Heap_type.t -> t
828
+ = "caml_binaryen_ref_func"
828
829
  (** Module, func, type *)
829
830
 
830
831
  external eq : Module.t -> t -> t -> t = "caml_binaryen_ref_eq"
@@ -343,7 +343,7 @@ module Ref : sig
343
343
  val as_ : Module.t -> Op.t -> t -> t
344
344
  (** Module, op, value *)
345
345
 
346
- val func : Module.t -> string -> Type.t -> t
346
+ val func : Module.t -> string -> Heap_type.t -> t
347
347
  (** Module, func, type *)
348
348
 
349
349
  val eq : Module.t -> t -> t -> t
@@ -14,10 +14,6 @@ module Feature = struct
14
14
 
15
15
  let atomics = atomics ()
16
16
 
17
- external bulk_memory : unit -> t = "caml_binaryen_feature_bulk_memory"
18
-
19
- let bulk_memory = bulk_memory ()
20
-
21
17
  external mutable_globals : unit -> t = "caml_binaryen_feature_mutable_globals"
22
18
 
23
19
  let mutable_globals = mutable_globals ()
@@ -27,14 +23,18 @@ module Feature = struct
27
23
 
28
24
  let nontrapping_fp_to_int = nontrapping_fp_to_int ()
29
25
 
30
- external sign_ext : unit -> t = "caml_binaryen_feature_sign_ext"
31
-
32
- let sign_ext = sign_ext ()
33
-
34
26
  external simd128 : unit -> t = "caml_binaryen_feature_simd128"
35
27
 
36
28
  let simd128 = simd128 ()
37
29
 
30
+ external bulk_memory : unit -> t = "caml_binaryen_feature_bulk_memory"
31
+
32
+ let bulk_memory = bulk_memory ()
33
+
34
+ external sign_ext : unit -> t = "caml_binaryen_feature_sign_ext"
35
+
36
+ let sign_ext = sign_ext ()
37
+
38
38
  external exception_handling : unit -> t
39
39
  = "caml_binaryen_feature_exception_handling"
40
40
 
@@ -76,6 +76,28 @@ module Feature = struct
76
76
 
77
77
  let multi_memory = multi_memory ()
78
78
 
79
+ external stack_switching : unit -> t = "caml_binaryen_feature_stack_switching"
80
+
81
+ let stack_switching = stack_switching ()
82
+
83
+ external shared_everything : unit -> t
84
+ = "caml_binaryen_feature_shared_everything"
85
+
86
+ let shared_everything = shared_everything ()
87
+
88
+ external fp16 : unit -> t = "caml_binaryen_feature_fp16"
89
+
90
+ let fp16 = fp16 ()
91
+
92
+ external bulk_memory_opt : unit -> t = "caml_binaryen_feature_bulk_memory_opt"
93
+
94
+ let bulk_memory_opt = bulk_memory_opt ()
95
+
96
+ external call_indirect_overlong : unit -> t
97
+ = "caml_binaryen_feature_call_indirect_overlong"
98
+
99
+ let call_indirect_overlong = call_indirect_overlong ()
100
+
79
101
  external all : unit -> t = "caml_binaryen_feature_all"
80
102
 
81
103
  let all = all ()
@@ -5,11 +5,11 @@ module Feature : sig
5
5
 
6
6
  val mvp : t
7
7
  val atomics : t
8
- val bulk_memory : t
9
8
  val mutable_globals : t
10
9
  val nontrapping_fp_to_int : t
11
- val sign_ext : t
12
10
  val simd128 : t
11
+ val bulk_memory : t
12
+ val sign_ext : t
13
13
  val exception_handling : t
14
14
  val tail_call : t
15
15
  val reference_types : t
@@ -20,6 +20,11 @@ module Feature : sig
20
20
  val extended_const : t
21
21
  val strings : t
22
22
  val multi_memory : t
23
+ val stack_switching : t
24
+ val shared_everything : t
25
+ val fp16 : t
26
+ val bulk_memory_opt : t
27
+ val call_indirect_overlong : t
23
28
  val all : t
24
29
  end
25
30
 
@@ -35,12 +35,6 @@ caml_binaryen_feature_atomics(value unit) {
35
35
  CAMLreturn(Val_int(BinaryenFeatureAtomics()));
36
36
  }
37
37
 
38
- CAMLprim value
39
- caml_binaryen_feature_bulk_memory(value unit) {
40
- CAMLparam1(unit);
41
- CAMLreturn(Val_int(BinaryenFeatureBulkMemory()));
42
- }
43
-
44
38
  CAMLprim value
45
39
  caml_binaryen_feature_mutable_globals(value unit) {
46
40
  CAMLparam1(unit);
@@ -54,15 +48,21 @@ caml_binaryen_feature_nontrapping_fp_to_int(value unit) {
54
48
  }
55
49
 
56
50
  CAMLprim value
57
- caml_binaryen_feature_sign_ext(value unit) {
51
+ caml_binaryen_feature_simd128(value unit) {
58
52
  CAMLparam1(unit);
59
- CAMLreturn(Val_int(BinaryenFeatureSignExt()));
53
+ CAMLreturn(Val_int(BinaryenFeatureSIMD128()));
60
54
  }
61
55
 
62
56
  CAMLprim value
63
- caml_binaryen_feature_simd128(value unit) {
57
+ caml_binaryen_feature_bulk_memory(value unit) {
64
58
  CAMLparam1(unit);
65
- CAMLreturn(Val_int(BinaryenFeatureSIMD128()));
59
+ CAMLreturn(Val_int(BinaryenFeatureBulkMemory()));
60
+ }
61
+
62
+ CAMLprim value
63
+ caml_binaryen_feature_sign_ext(value unit) {
64
+ CAMLparam1(unit);
65
+ CAMLreturn(Val_int(BinaryenFeatureSignExt()));
66
66
  }
67
67
 
68
68
  CAMLprim value
@@ -125,6 +125,36 @@ caml_binaryen_feature_multi_memory(value unit) {
125
125
  CAMLreturn(Val_int(BinaryenFeatureMultiMemory()));
126
126
  }
127
127
 
128
+ CAMLprim value
129
+ caml_binaryen_feature_stack_switching(value unit) {
130
+ CAMLparam1(unit);
131
+ CAMLreturn(Val_int(BinaryenFeatureStackSwitching()));
132
+ }
133
+
134
+ CAMLprim value
135
+ caml_binaryen_feature_shared_everything(value unit) {
136
+ CAMLparam1(unit);
137
+ CAMLreturn(Val_int(BinaryenFeatureSharedEverything()));
138
+ }
139
+
140
+ CAMLprim value
141
+ caml_binaryen_feature_fp16(value unit) {
142
+ CAMLparam1(unit);
143
+ CAMLreturn(Val_int(BinaryenFeatureFP16()));
144
+ }
145
+
146
+ CAMLprim value
147
+ caml_binaryen_feature_bulk_memory_opt(value unit) {
148
+ CAMLparam1(unit);
149
+ CAMLreturn(Val_int(BinaryenFeatureBulkMemoryOpt()));
150
+ }
151
+
152
+ CAMLprim value
153
+ caml_binaryen_feature_call_indirect_overlong(value unit) {
154
+ CAMLparam1(unit);
155
+ CAMLreturn(Val_int(BinaryenFeatureCallIndirectOverlong()));
156
+ }
157
+
128
158
  CAMLprim value
129
159
  caml_binaryen_feature_all(value unit) {
130
160
  CAMLparam1(unit);
@@ -20,12 +20,6 @@ function caml_binaryen_feature_atomics() {
20
20
  return Binaryen.Features.Atomics;
21
21
  }
22
22
 
23
- //Provides: caml_binaryen_feature_bulk_memory
24
- //Requires: Binaryen
25
- function caml_binaryen_feature_bulk_memory() {
26
- return Binaryen.Features.BulkMemory;
27
- }
28
-
29
23
  //Provides: caml_binaryen_feature_mutable_globals
30
24
  //Requires: Binaryen
31
25
  function caml_binaryen_feature_mutable_globals() {
@@ -38,18 +32,24 @@ function caml_binaryen_feature_nontrapping_fp_to_int() {
38
32
  return Binaryen.Features.NontrappingFPToInt;
39
33
  }
40
34
 
41
- //Provides: caml_binaryen_feature_sign_ext
42
- //Requires: Binaryen
43
- function caml_binaryen_feature_sign_ext() {
44
- return Binaryen.Features.SignExt;
45
- }
46
-
47
35
  //Provides: caml_binaryen_feature_simd128
48
36
  //Requires: Binaryen
49
37
  function caml_binaryen_feature_simd128() {
50
38
  return Binaryen.Features.SIMD128;
51
39
  }
52
40
 
41
+ //Provides: caml_binaryen_feature_bulk_memory
42
+ //Requires: Binaryen
43
+ function caml_binaryen_feature_bulk_memory() {
44
+ return Binaryen.Features.BulkMemory;
45
+ }
46
+
47
+ //Provides: caml_binaryen_feature_sign_ext
48
+ //Requires: Binaryen
49
+ function caml_binaryen_feature_sign_ext() {
50
+ return Binaryen.Features.SignExt;
51
+ }
52
+
53
53
  //Provides: caml_binaryen_feature_exception_handling
54
54
  //Requires: Binaryen
55
55
  function caml_binaryen_feature_exception_handling() {
@@ -110,6 +110,36 @@ function caml_binaryen_feature_multi_memory() {
110
110
  return Binaryen.Features.MultiMemory;
111
111
  }
112
112
 
113
+ //Provides: caml_binaryen_feature_stack_switching
114
+ //Requires: Binaryen
115
+ function caml_binaryen_feature_stack_switching() {
116
+ return Binaryen.Features.StackSwitching;
117
+ }
118
+
119
+ //Provides: caml_binaryen_feature_shared_everything
120
+ //Requires: Binaryen
121
+ function caml_binaryen_feature_shared_everything() {
122
+ return Binaryen.Features.SharedEverything;
123
+ }
124
+
125
+ //Provides: caml_binaryen_feature_fp16
126
+ //Requires: Binaryen
127
+ function caml_binaryen_feature_fp16() {
128
+ return Binaryen.Features.FP16;
129
+ }
130
+
131
+ //Provides: caml_binaryen_feature_bulk_memory_opt
132
+ //Requires: Binaryen
133
+ function caml_binaryen_feature_bulk_memory_opt() {
134
+ return Binaryen.Features.BulkMemoryOpt;
135
+ }
136
+
137
+ //Provides: caml_binaryen_feature_call_indirect_overlong
138
+ //Requires: Binaryen
139
+ function caml_binaryen_feature_call_indirect_overlong() {
140
+ return Binaryen.Features.BulkMemoryOpt;
141
+ }
142
+
113
143
  //Provides: caml_binaryen_feature_all
114
144
  //Requires: Binaryen
115
145
  function caml_binaryen_feature_all() {
@@ -52,6 +52,36 @@ caml_binaryen_set_debug_info(value _on) {
52
52
  CAMLreturn(Val_unit);
53
53
  }
54
54
 
55
+ CAMLprim value
56
+ caml_binaryen_get_traps_never_happen(value unit) {
57
+ CAMLparam1(unit);
58
+ bool res = BinaryenGetTrapsNeverHappen();
59
+ CAMLreturn(Val_bool(res));
60
+ }
61
+
62
+ CAMLprim value
63
+ caml_binaryen_set_traps_never_happen(value _on) {
64
+ CAMLparam1(_on);
65
+ bool on = Bool_val(_on);
66
+ BinaryenSetTrapsNeverHappen(on);
67
+ CAMLreturn(Val_unit);
68
+ }
69
+
70
+ CAMLprim value
71
+ caml_binaryen_get_closed_world(value unit) {
72
+ CAMLparam1(unit);
73
+ bool res = BinaryenGetClosedWorld();
74
+ CAMLreturn(Val_bool(res));
75
+ }
76
+
77
+ CAMLprim value
78
+ caml_binaryen_set_closed_world(value _on) {
79
+ CAMLparam1(_on);
80
+ bool on = Bool_val(_on);
81
+ BinaryenSetClosedWorld(on);
82
+ CAMLreturn(Val_unit);
83
+ }
84
+
55
85
  CAMLprim value
56
86
  caml_binaryen_get_low_memory_unused(value unit) {
57
87
  CAMLparam1(unit);
@@ -67,6 +97,66 @@ caml_binaryen_set_low_memory_unused(value _on) {
67
97
  CAMLreturn(Val_unit);
68
98
  }
69
99
 
100
+ CAMLprim value
101
+ caml_binaryen_get_zero_filled_memory(value unit) {
102
+ CAMLparam1(unit);
103
+ bool res = BinaryenGetZeroFilledMemory();
104
+ CAMLreturn(Val_bool(res));
105
+ }
106
+
107
+ CAMLprim value
108
+ caml_binaryen_set_zero_filled_memory(value _on) {
109
+ CAMLparam1(_on);
110
+ bool on = Bool_val(_on);
111
+ BinaryenSetZeroFilledMemory(on);
112
+ CAMLreturn(Val_unit);
113
+ }
114
+
115
+ CAMLprim value
116
+ caml_binaryen_get_fast_math(value unit) {
117
+ CAMLparam1(unit);
118
+ bool res = BinaryenGetFastMath();
119
+ CAMLreturn(Val_bool(res));
120
+ }
121
+
122
+ CAMLprim value
123
+ caml_binaryen_set_fast_math(value _on) {
124
+ CAMLparam1(_on);
125
+ bool on = Bool_val(_on);
126
+ BinaryenSetFastMath(on);
127
+ CAMLreturn(Val_unit);
128
+ }
129
+
130
+ CAMLprim value
131
+ caml_binaryen_get_generate_stack_ir(value unit) {
132
+ CAMLparam1(unit);
133
+ bool res = BinaryenGetGenerateStackIR();
134
+ CAMLreturn(Val_bool(res));
135
+ }
136
+
137
+ CAMLprim value
138
+ caml_binaryen_set_generate_stack_ir(value _on) {
139
+ CAMLparam1(_on);
140
+ bool on = Bool_val(_on);
141
+ BinaryenSetGenerateStackIR(on);
142
+ CAMLreturn(Val_unit);
143
+ }
144
+
145
+ CAMLprim value
146
+ caml_binaryen_get_optimize_stack_ir(value unit) {
147
+ CAMLparam1(unit);
148
+ bool res = BinaryenGetOptimizeStackIR();
149
+ CAMLreturn(Val_bool(res));
150
+ }
151
+
152
+ CAMLprim value
153
+ caml_binaryen_set_optimize_stack_ir(value _on) {
154
+ CAMLparam1(_on);
155
+ bool on = Bool_val(_on);
156
+ BinaryenSetOptimizeStackIR(on);
157
+ CAMLreturn(Val_unit);
158
+ }
159
+
70
160
  CAMLprim value
71
161
  caml_binaryen_get_pass_argument(value _name) {
72
162
  CAMLparam1(_name);
@@ -88,6 +178,36 @@ caml_binaryen_set_pass_argument(value _name, value _val) {
88
178
  CAMLreturn(Val_unit);
89
179
  }
90
180
 
181
+ CAMLprim value
182
+ caml_binaryen_clear_pass_arguments(value unit) {
183
+ CAMLparam1(unit);
184
+ BinaryenClearPassArguments();
185
+ CAMLreturn(Val_unit);
186
+ }
187
+
188
+ CAMLprim value
189
+ caml_binaryen_has_pass_to_skip(value _pass) {
190
+ CAMLparam1(_pass);
191
+ const char* pass = Safe_String_val(_pass);
192
+ bool res = BinaryenHasPassToSkip(pass);
193
+ CAMLreturn(Val_bool(res));
194
+ }
195
+
196
+ CAMLprim value
197
+ caml_binaryen_add_pass_to_skip(value _pass) {
198
+ CAMLparam1(_pass);
199
+ const char* pass = Safe_String_val(_pass);
200
+ BinaryenAddPassToSkip(pass);
201
+ CAMLreturn(Val_unit);
202
+ }
203
+
204
+ CAMLprim value
205
+ caml_binaryen_clear_passes_to_skip(value unit) {
206
+ CAMLparam1(unit);
207
+ BinaryenClearPassesToSkip();
208
+ CAMLreturn(Val_unit);
209
+ }
210
+
91
211
  CAMLprim value
92
212
  caml_binaryen_get_always_inline_max_size(value unit) {
93
213
  CAMLparam1(unit);
@@ -133,6 +253,21 @@ caml_binaryen_set_one_caller_inline_max_size(value _size) {
133
253
  CAMLreturn(Val_unit);
134
254
  }
135
255
 
256
+ CAMLprim value
257
+ caml_binaryen_get_allow_inlining_functions_with_loops(value unit) {
258
+ CAMLparam1(unit);
259
+ bool res = BinaryenGetAllowInliningFunctionsWithLoops();
260
+ CAMLreturn(Val_bool(res));
261
+ }
262
+
263
+ CAMLprim value
264
+ caml_binaryen_set_allow_inlining_functions_with_loops(value _size) {
265
+ CAMLparam1(_size);
266
+ int on = Bool_val(_size);
267
+ BinaryenSetAllowInliningFunctionsWithLoops(on);
268
+ CAMLreturn(Val_unit);
269
+ }
270
+
136
271
  CAMLprim value
137
272
  caml_binaryen_set_colors_enabled(value _on) {
138
273
  CAMLparam1(_on);
@@ -36,6 +36,34 @@ function caml_binaryen_set_debug_info(on) {
36
36
  return Binaryen._BinaryenSetDebugInfo(on);
37
37
  }
38
38
 
39
+ //Provides: caml_binaryen_get_traps_never_happen
40
+ //Requires: Binaryen
41
+ function caml_binaryen_get_traps_never_happen() {
42
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
43
+ return Binaryen._BinaryenGetTrapsNeverHappen();
44
+ }
45
+
46
+ //Provides: caml_binaryen_set_traps_never_happen
47
+ //Requires: Binaryen
48
+ function caml_binaryen_set_traps_never_happen(on) {
49
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
50
+ return Binaryen._BinaryenSetTrapsNeverHappen(on);
51
+ }
52
+
53
+ //Provides: caml_binaryen_get_closed_world
54
+ //Requires: Binaryen
55
+ function caml_binaryen_get_closed_world() {
56
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
57
+ return Binaryen._BinaryenGetClosedWorld();
58
+ }
59
+
60
+ //Provides: caml_binaryen_set_closed_world
61
+ //Requires: Binaryen
62
+ function caml_binaryen_set_closed_world(on) {
63
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
64
+ return Binaryen._BinaryenSetClosedWorld(on);
65
+ }
66
+
39
67
  //Provides: caml_binaryen_get_low_memory_unused
40
68
  //Requires: Binaryen
41
69
  function caml_binaryen_get_low_memory_unused() {
@@ -50,6 +78,62 @@ function caml_binaryen_set_low_memory_unused(on) {
50
78
  return Binaryen._BinaryenSetLowMemoryUnused(on);
51
79
  }
52
80
 
81
+ //Provides: caml_binaryen_get_zero_filled_memory
82
+ //Requires: Binaryen
83
+ function caml_binaryen_get_zero_filled_memory() {
84
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
85
+ return Binaryen._BinaryenGetZeroFilledMemory();
86
+ }
87
+
88
+ //Provides: caml_binaryen_set_zero_filled_memory
89
+ //Requires: Binaryen
90
+ function caml_binaryen_set_zero_filled_memory(on) {
91
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
92
+ return Binaryen._BinaryenSetZeroFilledMemory(on);
93
+ }
94
+
95
+ //Provides: caml_binaryen_get_fast_math
96
+ //Requires: Binaryen
97
+ function caml_binaryen_get_fast_math() {
98
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
99
+ return Binaryen._BinaryenGetFastMath();
100
+ }
101
+
102
+ //Provides: caml_binaryen_set_fast_math
103
+ //Requires: Binaryen
104
+ function caml_binaryen_set_fast_math(on) {
105
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
106
+ return Binaryen._BinaryenSetFastMath(on);
107
+ }
108
+
109
+ //Provides: caml_binaryen_get_generate_stack_ir
110
+ //Requires: Binaryen
111
+ function caml_binaryen_get_generate_stack_ir() {
112
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
113
+ return Binaryen._BinaryenGetGenerateStackIR();
114
+ }
115
+
116
+ //Provides: caml_binaryen_set_generate_stack_ir
117
+ //Requires: Binaryen
118
+ function caml_binaryen_set_generate_stack_ir(on) {
119
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
120
+ return Binaryen._BinaryenSetGenerateStackIR(on);
121
+ }
122
+
123
+ //Provides: caml_binaryen_get_optimize_stack_ir
124
+ //Requires: Binaryen
125
+ function caml_binaryen_get_optimize_stack_ir() {
126
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
127
+ return Binaryen._BinaryenGetOptimizeStackIR();
128
+ }
129
+
130
+ //Provides: caml_binaryen_set_optimize_stack_ir
131
+ //Requires: Binaryen
132
+ function caml_binaryen_set_optimize_stack_ir(on) {
133
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
134
+ return Binaryen._BinaryenSetOptimizeStackIR(on);
135
+ }
136
+
53
137
  //Provides: caml_binaryen_get_pass_argument
54
138
  //Requires: Binaryen
55
139
  //Requires: caml_jsstring_of_string
@@ -70,6 +154,39 @@ function caml_binaryen_set_pass_argument(name, value) {
70
154
  );
71
155
  }
72
156
 
157
+ //Provides: caml_binaryen_clear_pass_arguments
158
+ //Requires: Binaryen
159
+ function caml_binaryen_clear_pass_arguments() {
160
+ return Binaryen.clearPassArguments();
161
+ }
162
+
163
+ //Provides: caml_binaryen_has_pass_to_skip
164
+ //Requires: Binaryen
165
+ //Requires: caml_jsstring_of_string
166
+ //Requires: caml_js_to_bool
167
+ function caml_binaryen_has_pass_to_skip(pass) {
168
+ return caml_js_to_bool(
169
+ Binaryen.hasPassToSkip(
170
+ caml_jsstring_of_string(pass)
171
+ )
172
+ );
173
+ }
174
+
175
+ //Provides: caml_binaryen_add_pass_to_skip
176
+ //Requires: Binaryen
177
+ //Requires: caml_jsstring_of_string
178
+ function caml_binaryen_add_pass_to_skip(pass) {
179
+ return Binaryen.addPassToSkip(
180
+ caml_jsstring_of_string(pass)
181
+ );
182
+ }
183
+
184
+ //Provides: caml_binaryen_clear_passes_to_skip
185
+ //Requires: Binaryen
186
+ function caml_binaryen_clear_passes_to_skip(pass) {
187
+ return Binaryen.clearPassesToSkip();
188
+ }
189
+
73
190
  //Provides: caml_binaryen_get_always_inline_max_size
74
191
  //Requires: Binaryen
75
192
  function caml_binaryen_get_always_inline_max_size() {
@@ -106,6 +223,20 @@ function caml_binaryen_set_one_caller_inline_max_size(size) {
106
223
  return Binaryen.setOneCallerInlineMaxSize(size);
107
224
  }
108
225
 
226
+ //Provides: caml_binaryen_get_allow_inlining_functions_with_loops
227
+ //Requires: Binaryen
228
+ function caml_binaryen_get_allow_inlining_functions_with_loops() {
229
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
230
+ return Binaryen._BinaryenGetAllowInliningFunctionsWithLoops();
231
+ }
232
+
233
+ //Provides: caml_binaryen_set_allow_inlining_functions_with_loops
234
+ //Requires: Binaryen
235
+ function caml_binaryen_set_allow_inlining_functions_with_loops(on) {
236
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
237
+ return Binaryen._BinaryenSetAllowInliningFunctionsWithLoops(on);
238
+ }
239
+
109
240
  //Provides: caml_binaryen_set_colors_enabled
110
241
  //Requires: Binaryen
111
242
  function caml_binaryen_set_colors_enabled(on) {
@@ -5,18 +5,57 @@ external set_shrink_level : int -> unit = "caml_binaryen_set_shrink_level"
5
5
  external get_debug_info : unit -> bool = "caml_binaryen_get_debug_info"
6
6
  external set_debug_info : bool -> unit = "caml_binaryen_set_debug_info"
7
7
 
8
+ external get_traps_never_happen : unit -> bool
9
+ = "caml_binaryen_get_traps_never_happen"
10
+
11
+ external set_traps_never_happen : bool -> unit
12
+ = "caml_binaryen_set_traps_never_happen"
13
+
14
+ external get_closed_world : unit -> bool = "caml_binaryen_get_closed_world"
15
+ external set_closed_world : bool -> unit = "caml_binaryen_set_closed_world"
16
+
8
17
  external get_low_memory_unused : unit -> bool
9
18
  = "caml_binaryen_get_low_memory_unused"
10
19
 
11
20
  external set_low_memory_unused : bool -> unit
12
21
  = "caml_binaryen_set_low_memory_unused"
13
22
 
23
+ external get_zero_filled_memory : unit -> bool
24
+ = "caml_binaryen_get_zero_filled_memory"
25
+
26
+ external set_zero_filled_memory : bool -> unit
27
+ = "caml_binaryen_set_zero_filled_memory"
28
+
29
+ external get_fast_math : unit -> bool = "caml_binaryen_get_fast_math"
30
+ external set_fast_math : bool -> unit = "caml_binaryen_set_fast_math"
31
+
32
+ external get_generate_stack_ir : unit -> bool
33
+ = "caml_binaryen_get_generate_stack_ir"
34
+
35
+ external set_generate_stack_ir : bool -> unit
36
+ = "caml_binaryen_set_generate_stack_ir"
37
+
38
+ external get_optimize_stack_ir : unit -> bool
39
+ = "caml_binaryen_get_optimize_stack_ir"
40
+
41
+ external set_optimize_stack_ir : bool -> unit
42
+ = "caml_binaryen_set_optimize_stack_ir"
43
+
14
44
  external get_pass_argument : string -> string option
15
45
  = "caml_binaryen_get_pass_argument"
16
46
 
17
47
  external set_pass_argument : string -> string -> unit
18
48
  = "caml_binaryen_set_pass_argument"
19
49
 
50
+ external clear_pass_arguments : unit -> unit
51
+ = "caml_binaryen_clear_pass_arguments"
52
+
53
+ external has_pass_to_skip : string -> bool = "caml_binaryen_has_pass_to_skip"
54
+ external add_pass_to_skip : string -> unit = "caml_binaryen_add_pass_to_skip"
55
+
56
+ external clear_passes_to_skip : unit -> unit
57
+ = "caml_binaryen_clear_passes_to_skip"
58
+
20
59
  external get_always_inline_max_size : unit -> int
21
60
  = "caml_binaryen_get_always_inline_max_size"
22
61
 
@@ -35,5 +74,11 @@ external get_one_caller_inline_max_size : unit -> int
35
74
  external set_one_caller_inline_max_size : int -> unit
36
75
  = "caml_binaryen_set_one_caller_inline_max_size"
37
76
 
77
+ external get_allow_inlining_functions_with_loops : unit -> bool
78
+ = "caml_binaryen_get_allow_inlining_functions_with_loops"
79
+
80
+ external set_allow_inlining_functions_with_loops : bool -> unit
81
+ = "caml_binaryen_set_allow_inlining_functions_with_loops"
82
+
38
83
  external set_colors_enabled : bool -> unit = "caml_binaryen_set_colors_enabled"
39
84
  external are_colors_enabled : unit -> bool = "caml_binaryen_are_colors_enabled"
@@ -4,15 +4,33 @@ val get_shrink_level : unit -> int
4
4
  val set_shrink_level : int -> unit
5
5
  val get_debug_info : unit -> bool
6
6
  val set_debug_info : bool -> unit
7
+ val get_traps_never_happen : unit -> bool
8
+ val set_traps_never_happen : bool -> unit
9
+ val get_closed_world : unit -> bool
10
+ val set_closed_world : bool -> unit
7
11
  val get_low_memory_unused : unit -> bool
8
12
  val set_low_memory_unused : bool -> unit
13
+ val get_zero_filled_memory : unit -> bool
14
+ val set_zero_filled_memory : bool -> unit
15
+ val get_fast_math : unit -> bool
16
+ val set_fast_math : bool -> unit
17
+ val get_generate_stack_ir : unit -> bool
18
+ val set_generate_stack_ir : bool -> unit
19
+ val get_optimize_stack_ir : unit -> bool
20
+ val set_optimize_stack_ir : bool -> unit
9
21
  val get_pass_argument : string -> string option
10
22
  val set_pass_argument : string -> string -> unit
23
+ val clear_pass_arguments : unit -> unit
24
+ val has_pass_to_skip : string -> bool
25
+ val add_pass_to_skip : string -> unit
26
+ val clear_passes_to_skip : unit -> unit
11
27
  val get_always_inline_max_size : unit -> int
12
28
  val set_always_inline_max_size : int -> unit
13
29
  val get_flexible_inline_max_size : unit -> int
14
30
  val set_flexible_inline_max_size : int -> unit
15
31
  val get_one_caller_inline_max_size : unit -> int
16
32
  val set_one_caller_inline_max_size : int -> unit
33
+ val get_allow_inlining_functions_with_loops : unit -> bool
34
+ val set_allow_inlining_functions_with_loops : bool -> unit
17
35
  val set_colors_enabled : bool -> unit
18
36
  val are_colors_enabled : unit -> bool
@@ -12,11 +12,67 @@ let _ = Settings.set_debug_info true
12
12
  let _ = assert (Settings.get_debug_info () == true)
13
13
  let _ = Settings.set_debug_info false
14
14
 
15
+ (* Testing traps_never_happen enable *)
16
+ let _ = assert (Settings.get_traps_never_happen () == false)
17
+ let _ = Settings.set_traps_never_happen true
18
+ let _ = assert (Settings.get_traps_never_happen () == true)
19
+ let _ = Settings.set_traps_never_happen false
20
+
21
+ (* Testing closed_world enable *)
22
+ let _ = assert (Settings.get_closed_world () == false)
23
+ let _ = Settings.set_closed_world true
24
+ let _ = assert (Settings.get_closed_world () == true)
25
+ let _ = Settings.set_closed_world false
26
+
15
27
  (* Testing low_memory_unused enable *)
16
28
  let _ = assert (Settings.get_low_memory_unused () == false)
17
29
  let _ = Settings.set_low_memory_unused true
18
30
  let _ = assert (Settings.get_low_memory_unused () == true)
19
31
  let _ = Settings.set_low_memory_unused false
32
+
33
+ (* Testing zero_filled_memory enable *)
34
+ let _ = assert (Settings.get_zero_filled_memory () == false)
35
+ let _ = Settings.set_zero_filled_memory true
36
+ let _ = assert (Settings.get_zero_filled_memory () == true)
37
+ let _ = Settings.set_zero_filled_memory false
38
+
39
+ (* Testing fast_math enable *)
40
+ let _ = assert (Settings.get_fast_math () == false)
41
+ let _ = Settings.set_fast_math true
42
+ let _ = assert (Settings.get_fast_math () == true)
43
+ let _ = Settings.set_fast_math false
44
+
45
+ (* Testing generate_stack_ir enable *)
46
+ let _ = assert (Settings.get_generate_stack_ir () == false)
47
+ let _ = Settings.set_generate_stack_ir true
48
+ let _ = assert (Settings.get_generate_stack_ir () == true)
49
+ let _ = Settings.set_generate_stack_ir false
50
+
51
+ (* Testing optimize_stack_ir enable *)
52
+ let _ = assert (Settings.get_optimize_stack_ir () == false)
53
+ let _ = Settings.set_optimize_stack_ir true
54
+ let _ = assert (Settings.get_optimize_stack_ir () == true)
55
+ let _ = Settings.set_optimize_stack_ir false
56
+
57
+ (* Testing pass_argument *)
58
+ let _ = assert (Settings.get_pass_argument "theKey" = None)
59
+ let _ = Settings.set_pass_argument "theKey" "theValue"
60
+ let _ = assert (Settings.get_pass_argument "theKey" = Some "theValue")
61
+ let _ = Settings.clear_pass_arguments ()
62
+ let _ = assert (Settings.get_pass_argument "theKey" = None)
63
+
64
+ (* Testing skip_pass *)
65
+ let _ = assert (Settings.has_pass_to_skip "thePass" == false)
66
+ let _ = Settings.add_pass_to_skip "thePass"
67
+ let _ = assert (Settings.has_pass_to_skip "thePass" == true)
68
+ let _ = Settings.clear_passes_to_skip ()
69
+ let _ = assert (Settings.has_pass_to_skip "thePass" == false)
70
+
71
+ (* Testing allow_inlining_functions_with_loops enable *)
72
+ let _ = assert (Settings.get_allow_inlining_functions_with_loops () == false)
73
+ let _ = Settings.set_allow_inlining_functions_with_loops true
74
+ let _ = assert (Settings.get_allow_inlining_functions_with_loops () == true)
75
+ let _ = Settings.set_allow_inlining_functions_with_loops false
20
76
  let wasm_mod = Module.create ()
21
77
  let _ = Module.set_features wasm_mod [ Module.Feature.all ]
22
78
  let import_wasm_mod = Module.create ()
@@ -114,7 +170,7 @@ let start =
114
170
 
115
171
  let _ = Export.add_function_export wasm_mod "adder" "adder"
116
172
  let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
117
- let funcref_expr1 = Expression.Ref.func wasm_mod "adder" Type.funcref
173
+ let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
118
174
 
119
175
  let _ =
120
176
  Expression.Table.set wasm_mod "table"
@@ -265,11 +321,11 @@ let _ =
265
321
  [
266
322
  Module.Feature.mvp;
267
323
  Module.Feature.atomics;
268
- Module.Feature.bulk_memory;
269
324
  Module.Feature.mutable_globals;
270
325
  Module.Feature.nontrapping_fp_to_int;
271
- Module.Feature.sign_ext;
272
326
  Module.Feature.simd128;
327
+ Module.Feature.bulk_memory;
328
+ Module.Feature.sign_ext;
273
329
  Module.Feature.exception_handling;
274
330
  Module.Feature.tail_call;
275
331
  Module.Feature.reference_types;
@@ -280,6 +336,11 @@ let _ =
280
336
  Module.Feature.extended_const;
281
337
  Module.Feature.strings;
282
338
  Module.Feature.multi_memory;
339
+ Module.Feature.stack_switching;
340
+ Module.Feature.shared_everything;
341
+ Module.Feature.fp16;
342
+ Module.Feature.bulk_memory_opt;
343
+ Module.Feature.call_indirect_overlong;
283
344
  Module.Feature.all;
284
345
  ]
285
346