@grain/binaryen.ml 0.33.0 → 0.34.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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.34.0](https://github.com/grain-lang/binaryen.ml/compare/v0.33.0...v0.34.0) (2025-11-12)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Update Passes api for Binaryen v124
9
+ * Upgrade to Binaryen v124 ([#241](https://github.com/grain-lang/binaryen.ml/issues/241))
10
+
11
+ ### Features
12
+
13
+ * Update Passes api for Binaryen v124 ([305137a](https://github.com/grain-lang/binaryen.ml/commit/305137a264049f3f38bf8828c57aad190195ca49))
14
+ * Upgrade to Binaryen v124 ([#241](https://github.com/grain-lang/binaryen.ml/issues/241)) ([02829f8](https://github.com/grain-lang/binaryen.ml/commit/02829f805cd3133bb4b04c83abac8380996bd0ec))
15
+
3
16
  ## [0.33.0](https://github.com/grain-lang/binaryen.ml/compare/v0.32.0...v0.33.0) (2025-11-12)
4
17
 
5
18
 
@@ -1,5 +1,5 @@
1
1
  opam-version: "2.0"
2
- version: "0.33.0"
2
+ version: "0.34.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" {>= "123.0.1" < "124.0.0"}
19
+ "libbinaryen" {>= "124.0.1" < "125.0.0"}
20
20
  ]
21
21
  x-maintenance-intent: ["0.(latest)"]
@@ -1,5 +1,5 @@
1
1
  {
2
- "checksum": "155674e15af22e7cb1432c6d5b252eee",
2
+ "checksum": "43b607828957b76c0263dc0b329d0237",
3
3
  "root": "@grain/binaryen.ml@link-dev:./package.json",
4
4
  "node": {
5
5
  "ocaml@5.3.0@d41d8cd9": {
@@ -1960,14 +1960,14 @@
1960
1960
  [ "windows", "x86_64" ]
1961
1961
  ]
1962
1962
  },
1963
- "@grain/libbinaryen@123.0.1@d41d8cd9": {
1964
- "id": "@grain/libbinaryen@123.0.1@d41d8cd9",
1963
+ "@grain/libbinaryen@124.0.1@d41d8cd9": {
1964
+ "id": "@grain/libbinaryen@124.0.1@d41d8cd9",
1965
1965
  "name": "@grain/libbinaryen",
1966
- "version": "123.0.1",
1966
+ "version": "124.0.1",
1967
1967
  "source": {
1968
1968
  "type": "install",
1969
1969
  "source": [
1970
- "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-123.0.1.tgz#sha1:5d4c992f6761d67d7d297bb48f0f4093ab5328e4"
1970
+ "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-124.0.1.tgz#sha1:7b29acc4a62ab5a849c6e01c3d8e90c78efd05f2"
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@123.0.1@d41d8cd9"
2002
+ "@grain/libbinaryen@124.0.1@d41d8cd9"
2003
2003
  ],
2004
2004
  "devDependencies": [
2005
2005
  "@opam/ocamlformat@opam:0.27.0@c40d4612",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@grain/binaryen.ml",
3
- "version": "0.33.0",
3
+ "version": "0.34.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": ">= 123.0.0 < 124.0.0",
9
+ "@grain/libbinaryen": ">= 124.0.0 < 125.0.0",
10
10
  "@opam/dune": ">= 3.0.0",
11
11
  "@opam/dune-configurator": ">= 3.0.0"
12
12
  },
@@ -73,6 +73,14 @@ caml_binaryen_set_start(value _module, value _fun) {
73
73
  CAMLreturn(Val_unit);
74
74
  }
75
75
 
76
+ CAMLprim value
77
+ caml_binaryen_get_start(value _module) {
78
+ CAMLparam1(_module);
79
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
80
+ BinaryenFunctionRef fun = BinaryenGetStart(module);
81
+ CAMLreturn(alloc_BinaryenFunctionRef(fun));
82
+ }
83
+
76
84
  CAMLprim value
77
85
  caml_binaryen_function_set_debug_location(value _fun, value _exp, value _file, value _line, value _column) {
78
86
  CAMLparam5(_fun, _exp, _file, _line, _column);
@@ -56,6 +56,11 @@ function caml_binaryen_set_start(wasm_mod, func) {
56
56
  return wasm_mod.setStart(func);
57
57
  }
58
58
 
59
+ //Provides: caml_binaryen_get_start
60
+ function caml_binaryen_get_start(wasm_mod) {
61
+ return wasm_mod.getStart();
62
+ }
63
+
59
64
  //Provides: caml_binaryen_function_set_debug_location
60
65
  //Requires: Binaryen
61
66
  function caml_binaryen_function_set_debug_location(
@@ -6,6 +6,7 @@ external add_function :
6
6
  (** Module, name, params type, results type, locals types, body. *)
7
7
 
8
8
  external set_start : Module.t -> t -> unit = "caml_binaryen_set_start"
9
+ external get_start : Module.t -> t = "caml_binaryen_get_start"
9
10
 
10
11
  external set_debug_location : t -> Expression.t -> int -> int -> int -> unit
11
12
  = "caml_binaryen_function_set_debug_location"
@@ -4,6 +4,7 @@ val add_function :
4
4
  Module.t -> string -> Type.t -> Type.t -> Type.t array -> Expression.t -> t
5
5
 
6
6
  val set_start : Module.t -> t -> unit
7
+ val get_start : Module.t -> t
7
8
  val set_debug_location : t -> Expression.t -> int -> int -> int -> unit
8
9
  val get_function : Module.t -> string -> t
9
10
  val get_function_by_index : Module.t -> int -> t
@@ -37,12 +37,18 @@ let const_hoisting = "const-hoisting"
37
37
  (** propagate constant struct field values *)
38
38
  let cfp = "cfp"
39
39
 
40
+ (** propagate constant struct field values, using ref.test *)
41
+ let cfp_reftest = "cfp-reftest"
42
+
40
43
  (** removes unreachable code *)
41
44
  let dce = "dce"
42
45
 
43
46
  (** forces all loads and stores to have alignment 1 *)
44
47
  let dealign = "dealign"
45
48
 
49
+ (** propagate debug location from parents or previous siblings to child nodes *)
50
+ let propagate_debug_locs = "propagate-debug-locs"
51
+
46
52
  (** instrument the wasm to convert NaNs into 0 at runtime *)
47
53
  let denan = "denan"
48
54
 
@@ -67,6 +73,9 @@ let duplicate_function_elimination = "duplicate-function-elimination"
67
73
  (** emit the target features section in the output *)
68
74
  let emit_target_features = "emit-target-features"
69
75
 
76
+ (** modify the wasm (destructively) for closed-world *)
77
+ let enclose_world = "enclose-world"
78
+
70
79
  (** leaves just one function (useful for debugging) *)
71
80
  let extract_function = "extract-function"
72
81
 
@@ -94,9 +103,6 @@ let generate_i64_dyncalls = "generate-i64-dyncalls"
94
103
  (** generate global effect info (helps later passes) *)
95
104
  let generate_global_effects = "generate-global-effects"
96
105
 
97
- (** generate Stack IR *)
98
- let generate_stack_ir = "generate-stack-ir"
99
-
100
106
  (** refine the types of globals *)
101
107
  let global_refining = "global-refining"
102
108
 
@@ -110,15 +116,30 @@ let gto = "gto"
110
116
  about what content can actually appear in each location *)
111
117
  let gufa = "gufa"
112
118
 
119
+ (** GUFA plus add casts for all inferences *)
120
+ let gufa_cast_all = "gufa-cast-all"
121
+
113
122
  (** GUFA plus local optimizations in functions we modified *)
114
123
  let gufa_optimizing = "gufa-optimizing"
115
124
 
125
+ (** optimizes J2CL specific constructs. *)
126
+ let optimize_j2cl = "optimize-j2cl"
127
+
128
+ (** Merges itable structures into vtables to make types more compact *)
129
+ let merge_j2cl_itables = "merge-j2cl-itables"
130
+
116
131
  (** apply more specific subtypes to type fields where possible *)
117
132
  let type_refining = "type-refining"
118
133
 
134
+ (** apply more specific subtypes to type fields where possible (using GUFA) *)
135
+ let type_refining_gufa = "type-refining-gufa"
136
+
119
137
  (** replace GC allocations with locals *)
120
138
  let heap2local = "heap2local"
121
139
 
140
+ (** optimize heap (GC) stores *)
141
+ let heap_store_optimization = "heap-store-optimization"
142
+
122
143
  (** inline __original_main into main *)
123
144
  let inline_main = "inline-main"
124
145
 
@@ -137,9 +158,8 @@ let jspi = "jspi"
137
158
  (** legalizes i64 types on the import/export boundary *)
138
159
  let legalize_js_interface = "legalize-js-interface"
139
160
 
140
- (** legalizes i64 types on the import/export boundary in a minimal manner, only
141
- on things only JS will call *)
142
- let legalize_js_interface_minimally = "legalize-js-interface-minimally"
161
+ (** legalizes the import/export boundary and prunes when needed *)
162
+ let legalize_and_prune_js_interface = "legalize-and-prune-js-interface"
143
163
 
144
164
  (** common subexpression elimination inside basic blocks *)
145
165
  let local_cse = "local-cse"
@@ -153,6 +173,9 @@ let log_execution = "log-execution"
153
173
  (** lower all uses of i64s to use i32s instead *)
154
174
  let i64_to_i32_lowering = "i64-to-i32-lowering"
155
175
 
176
+ (** instrument the build with code to intercept specific function calls *)
177
+ let trace_calls = "trace-calls"
178
+
156
179
  (** instrument the build with code to intercept all loads and stores *)
157
180
  let instrument_locals = "instrument-locals"
158
181
 
@@ -168,6 +191,13 @@ let limit_segments = "limit-segments"
168
191
  (** lower loads and stores to a 64-bit memory to instead use a 32-bit one *)
169
192
  let memory64_lowering = "memory64-lowering"
170
193
 
194
+ (** alias for memory64-lowering *)
195
+ let table64_lowering = "table64-lowering"
196
+
197
+ (** Lower memory.copy and memory.fill to wasm mvp and disable the bulk-memory
198
+ feature. *)
199
+ let llvm_memory_copy_fill_lowering = "llvm-memory-copy-fill-lowering"
200
+
171
201
  (** packs memory into separate segments, skipping zeros *)
172
202
  let memory_packing = "memory-packing"
173
203
 
@@ -196,6 +226,9 @@ let minify_imports_and_exports = "minify-imports-and-exports"
196
226
  let minify_imports_and_exports_and_modules =
197
227
  "minify-imports-and-exports-and-modules"
198
228
 
229
+ (** Split types into minimal recursion groups *)
230
+ let minimize_rec_groups = "minimize-rec-groups"
231
+
199
232
  (** apply the assumption that asyncify imports always unwind, and we never
200
233
  rewind *)
201
234
  let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind"
@@ -223,6 +256,19 @@ let nm = "nm"
223
256
  (** (re)name all heap types *)
224
257
  let name_types = "name-types"
225
258
 
259
+ (** mark functions as no-inline *)
260
+ let no_inline = "no-inline"
261
+
262
+ (** mark functions as no-inline (for full inlining only) *)
263
+ let no_full_inline = "no-full-inline"
264
+
265
+ (** mark functions as no-inline (for partial inlining only) *)
266
+ let no_partial_inline = "no-partial-inline"
267
+
268
+ (** lower nontrapping float-to-int operations to wasm mvp and disable the
269
+ nontrapping fptoint feature *)
270
+ let llvm_nontrapping_fptoint_lowering = "llvm-nontrapping-fptoint-lowering"
271
+
226
272
  (** reduces calls to code that only runs once *)
227
273
  let once_reduction = "once-reduction"
228
274
 
@@ -239,9 +285,6 @@ let optimize_casts = "optimize-casts"
239
285
  (** optimizes instruction combinations *)
240
286
  let optimize_instructions = "optimize-instructions"
241
287
 
242
- (** optimize Stack IR *)
243
- let optimize_stack_ir = "optimize-stack-ir"
244
-
245
288
  (** pick load signs based on their uses *)
246
289
  let pick_load_signs = "pick-load-signs"
247
290
 
@@ -282,15 +325,15 @@ let print_function_map = "print-function-map"
282
325
  (** alias for print_function_map *)
283
326
  let symbolmap = "symbolmap"
284
327
 
285
- (** print out Stack IR (useful for internal debugging) *)
286
- let print_stack_ir = "print-stack-ir"
287
-
288
328
  (** removes operations incompatible with js *)
289
329
  let remove_non_js_ops = "remove-non-js-ops"
290
330
 
291
331
  (** removes imports and replaces them with nops *)
292
332
  let remove_imports = "remove-imports"
293
333
 
334
+ (** removes memory initialization *)
335
+ let remove_memory_init = "remove-memory-init"
336
+
294
337
  (** removes memory segments *)
295
338
  let remove_memory = "remove-memory"
296
339
 
@@ -310,15 +353,15 @@ let remove_unused_names = "remove-unused-names"
310
353
  (** remove unused private GC types *)
311
354
  let remove_unused_types = "remove-unused-types"
312
355
 
356
+ (** sorts functions by name (useful for debugging) *)
357
+ let reorder_functions_by_name = "reorder-functions-by-name"
358
+
313
359
  (** sorts functions by access frequency *)
314
360
  let reorder_functions = "reorder-functions"
315
361
 
316
362
  (** sorts globals by access frequency *)
317
363
  let reorder_globals = "reorder-globals"
318
364
 
319
- (** sorts globals by access frequency (even if there are few) *)
320
- let reorder_globals_always = "reorder-globals-always"
321
-
322
365
  (** sorts locals by access frequency *)
323
366
  let reorder_locals = "reorder-locals"
324
367
 
@@ -337,6 +380,9 @@ let safe_heap = "safe-heap"
337
380
  (** sets specified globals to specified values *)
338
381
  let set_globals = "set-globals"
339
382
 
383
+ (** write data segments to a file and strip them from the module *)
384
+ let separate_data_segments = "separate-data-segments"
385
+
340
386
  (** remove params from function signature types where possible *)
341
387
  let signature_pruning = "signature-pruning"
342
388
 
@@ -388,6 +434,23 @@ let ssa = "ssa"
388
434
  (** ssa-ify variables so that they have a single assignment, ignoring merges *)
389
435
  let ssa_nomerge = "ssa-nomerge"
390
436
 
437
+ (** gathers wasm strings to globals *)
438
+ let string_gathering = "string-gathering"
439
+
440
+ (** lift string imports to wasm strings *)
441
+ let string_lifting = "string-lifting"
442
+
443
+ (** lowers wasm strings and operations to imports *)
444
+ let string_lowering = "string-lowering"
445
+
446
+ (** same as string-lowering, but encodes well-formed strings as magic imports *)
447
+ let string_lowering_magic_imports = "string-lowering-magic-imports"
448
+
449
+ (** same as string-lowering-magic-imports, but raise a fatal error if there are
450
+ invalid strings *)
451
+ let string_lowering_magic_imports_assert =
452
+ "string-lowering-magic-imports-assert"
453
+
391
454
  (** deprecated; same as strip-debug *)
392
455
  let strip = "strip"
393
456
 
@@ -409,18 +472,33 @@ let strip_eh = "strip-eh"
409
472
  (** strip the wasm target features section *)
410
473
  let strip_target_features = "strip-target-features"
411
474
 
475
+ (** translate old Phase 3 EH instructions to new ones with exnref *)
476
+ let translate_to_exnref = "translate-to-exnref"
477
+
412
478
  (** replace trapping operations with clamping semantics *)
413
479
  let trap_mode_clamp = "trap-mode-clamp"
414
480
 
415
481
  (** replace trapping operations with js semantics *)
416
482
  let trap_mode_js = "trap-mode-js"
417
483
 
484
+ (** optimize trivial tuples away *)
485
+ let tuple_optimization = "tuple-optimization"
486
+
487
+ (** mark all leaf types as final *)
488
+ let type_finalizing = "type-finalizing"
489
+
418
490
  (** merge types to their supertypes where possible *)
419
491
  let type_merging = "type-merging"
420
492
 
421
493
  (** create new nominal types to help other optimizations *)
422
494
  let type_ssa = "type-ssa"
423
495
 
496
+ (** mark all types as non-final (open) *)
497
+ let type_unfinalizing = "type-unfinalizing"
498
+
499
+ (** removes removes unnecessary subtyping relationships *)
500
+ let unsubtyping = "unsubtyping"
501
+
424
502
  (** removes local.tees, replacing them with sets and gets *)
425
503
  let untee = "untee"
426
504
 
@@ -37,12 +37,18 @@ val const_hoisting : t
37
37
  val cfp : t
38
38
  (** propagate constant struct field values *)
39
39
 
40
+ val cfp_reftest : t
41
+ (** propagate constant struct field values, using ref.test *)
42
+
40
43
  val dce : t
41
44
  (** removes unreachable code *)
42
45
 
43
46
  val dealign : t
44
47
  (** forces all loads and stores to have alignment 1 *)
45
48
 
49
+ val propagate_debug_locs : t
50
+ (** propagate debug location from parents or previous siblings to child nodes *)
51
+
46
52
  val denan : t
47
53
  (** instrument the wasm to convert NaNs into 0 at runtime *)
48
54
 
@@ -67,6 +73,9 @@ val duplicate_function_elimination : t
67
73
  val emit_target_features : t
68
74
  (** emit the target features section in the output *)
69
75
 
76
+ val enclose_world : t
77
+ (** modify the wasm (destructively) for closed-world *)
78
+
70
79
  val extract_function : t
71
80
  (** leaves just one function (useful for debugging) *)
72
81
 
@@ -94,9 +103,6 @@ val generate_i64_dyncalls : t
94
103
  val generate_global_effects : t
95
104
  (** generate global effect info (helps later passes) *)
96
105
 
97
- val generate_stack_ir : t
98
- (** generate Stack IR *)
99
-
100
106
  val global_refining : t
101
107
  (** refine the types of globals *)
102
108
 
@@ -110,15 +116,27 @@ val gufa : t
110
116
  (** Grand Unified Flow Analysis: optimize the entire program using information
111
117
  about what content can actually appear in each location *)
112
118
 
119
+ val gufa_cast_all : t
120
+ (** GUFA plus add casts for all inferences *)
121
+
113
122
  val gufa_optimizing : t
114
123
  (** GUFA plus local optimizations in functions we modified *)
115
124
 
125
+ val optimize_j2cl : t
126
+ (** optimizes J2CL specific constructs. *)
127
+
128
+ val merge_j2cl_itables : t
129
+ (** Merges itable structures into vtables to make types more compact *)
130
+
116
131
  val type_refining : t
117
132
  (** apply more specific subtypes to type fields where possible *)
118
133
 
119
134
  val heap2local : t
120
135
  (** replace GC allocations with locals *)
121
136
 
137
+ val heap_store_optimization : t
138
+ (** optimize heap (GC) stores *)
139
+
122
140
  val inline_main : t
123
141
  (** inline __original_main into main *)
124
142
 
@@ -137,9 +155,8 @@ val jspi : t
137
155
  val legalize_js_interface : t
138
156
  (** legalizes i64 types on the import/export boundary *)
139
157
 
140
- val legalize_js_interface_minimally : t
141
- (** legalizes i64 types on the import/export boundary in a minimal manner, only
142
- on things only JS will call *)
158
+ val legalize_and_prune_js_interface : t
159
+ (** legalizes the import/export boundary and prunes when needed *)
143
160
 
144
161
  val local_cse : t
145
162
  (** common subexpression elimination inside basic blocks *)
@@ -153,6 +170,9 @@ val log_execution : t
153
170
  val i64_to_i32_lowering : t
154
171
  (** lower all uses of i64s to use i32s instead *)
155
172
 
173
+ val trace_calls : t
174
+ (** instrument the build with code to intercept specific function calls *)
175
+
156
176
  val instrument_locals : t
157
177
  (** instrument the build with code to intercept all loads and stores *)
158
178
 
@@ -168,6 +188,13 @@ val limit_segments : t
168
188
  val memory64_lowering : t
169
189
  (** lower loads and stores to a 64-bit memory to instead use a 32-bit one *)
170
190
 
191
+ val table64_lowering : t
192
+ (** alias for memory64-lowering *)
193
+
194
+ val llvm_memory_copy_fill_lowering : t
195
+ (** Lower memory.copy and memory.fill to wasm mvp and disable the bulk-memory
196
+ feature. *)
197
+
171
198
  val memory_packing : t
172
199
  (** packs memory into separate segments, skipping zeros *)
173
200
 
@@ -195,6 +222,9 @@ val minify_imports_and_exports_and_modules : t
195
222
  (** minifies both import and export names, and emits a mapping to the minified
196
223
  ones, and minifies the modules as well *)
197
224
 
225
+ val minimize_rec_groups : t
226
+ (** Split types into minimal recursion groups *)
227
+
198
228
  val mod_asyncify_always_and_only_unwind : t
199
229
  (** apply the assumption that asyncify imports always unwind, and we never
200
230
  rewind *)
@@ -221,6 +251,19 @@ val nm : t
221
251
  val name_types : t
222
252
  (** (re)name all heap types *)
223
253
 
254
+ val no_inline : t
255
+ (** mark functions as no-inline *)
256
+
257
+ val no_full_inline : t
258
+ (** mark functions as no-inline (for full inlining only) *)
259
+
260
+ val no_partial_inline : t
261
+ (** mark functions as no-inline (for partial inlining only) *)
262
+
263
+ val llvm_nontrapping_fptoint_lowering : t
264
+ (** lower nontrapping float-to-int operations to wasm mvp and disable the
265
+ nontrapping fptoint feature *)
266
+
224
267
  val once_reduction : t
225
268
  (** reduces calls to code that only runs once *)
226
269
 
@@ -237,9 +280,6 @@ val optimize_casts : t
237
280
  val optimize_instructions : t
238
281
  (** optimizes instruction combinations *)
239
282
 
240
- val optimize_stack_ir : t
241
- (** optimize Stack IR *)
242
-
243
283
  val pick_load_signs : t
244
284
  (** pick load signs based on their uses *)
245
285
 
@@ -280,15 +320,15 @@ val print_function_map : t
280
320
  val symbolmap : t
281
321
  (** alias for print_function_map *)
282
322
 
283
- val print_stack_ir : t
284
- (** print out Stack IR (useful for internal debugging) *)
285
-
286
323
  val remove_non_js_ops : t
287
324
  (** removes operations incompatible with js *)
288
325
 
289
326
  val remove_imports : t
290
327
  (** removes imports and replaces them with nops *)
291
328
 
329
+ val remove_memory_init : t
330
+ (** removes memory initialization *)
331
+
292
332
  val remove_memory : t
293
333
  (** removes memory segments *)
294
334
 
@@ -307,15 +347,15 @@ val remove_unused_names : t
307
347
  val remove_unused_types : t
308
348
  (** remove unused private GC types *)
309
349
 
350
+ val reorder_functions_by_name : t
351
+ (** sorts functions by name (useful for debugging) *)
352
+
310
353
  val reorder_functions : t
311
354
  (** sorts functions by access frequency *)
312
355
 
313
356
  val reorder_globals : t
314
357
  (** sorts globals by access frequency *)
315
358
 
316
- val reorder_globals_always : t
317
- (** sorts globals by access frequency (even if there are few) *)
318
-
319
359
  val reorder_locals : t
320
360
  (** sorts locals by access frequency *)
321
361
 
@@ -334,6 +374,9 @@ val safe_heap : t
334
374
  val set_globals : t
335
375
  (** sets specified globals to specified values *)
336
376
 
377
+ val separate_data_segments : t
378
+ (** write data segments to a file and strip them from the module *)
379
+
337
380
  val signature_pruning : t
338
381
  (** remove params from function signature types where possible *)
339
382
 
@@ -384,6 +427,22 @@ val ssa : t
384
427
  val ssa_nomerge : t
385
428
  (** ssa-ify variables so that they have a single assignment, ignoring merges *)
386
429
 
430
+ val string_gathering : t
431
+ (** gathers wasm strings to globals *)
432
+
433
+ val string_lifting : t
434
+ (** lift string imports to wasm strings *)
435
+
436
+ val string_lowering : t
437
+ (** lowers wasm strings and operations to imports *)
438
+
439
+ val string_lowering_magic_imports : t
440
+ (** same as string-lowering, but encodes well-formed strings as magic imports *)
441
+
442
+ val string_lowering_magic_imports_assert : t
443
+ (** same as string-lowering-magic-imports, but raise a fatal error if there are
444
+ invalid strings *)
445
+
387
446
  val strip : t
388
447
  (** deprecated; same as strip-debug *)
389
448
 
@@ -405,18 +464,33 @@ val strip_eh : t
405
464
  val strip_target_features : t
406
465
  (** strip the wasm target features section *)
407
466
 
467
+ val translate_to_exnref : t
468
+ (** translate old Phase 3 EH instructions to new ones with exnref *)
469
+
408
470
  val trap_mode_clamp : t
409
471
  (** replace trapping operations with clamping semantics *)
410
472
 
411
473
  val trap_mode_js : t
412
474
  (** replace trapping operations with js semantics *)
413
475
 
476
+ val tuple_optimization : t
477
+ (** optimize trivial tuples away *)
478
+
479
+ val type_finalizing : t
480
+ (** mark all leaf types as final *)
481
+
414
482
  val type_merging : t
415
483
  (** merge types to their supertypes where possible *)
416
484
 
417
485
  val type_ssa : t
418
486
  (** create new nominal types to help other optimizations *)
419
487
 
488
+ val type_unfinalizing : t
489
+ (** mark all types as non-final (open) *)
490
+
491
+ val unsubtyping : t
492
+ (** removes removes unnecessary subtyping relationships *)
493
+
420
494
  val untee : t
421
495
  (** removes local.tees, replacing them with sets and gets *)
422
496
 
@@ -170,12 +170,14 @@ let start =
170
170
 
171
171
  let _ = Export.add_function_export wasm_mod "adder" "adder"
172
172
  let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
173
- let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
173
+
174
+ (* TODO(#240): Re-enable after type-builder api is merged *)
175
+ (* let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
174
176
 
175
177
  let _ =
176
178
  Expression.Table.set wasm_mod "table"
177
179
  (Expression.Const.make wasm_mod (Literal.int32 0l))
178
- funcref_expr1
180
+ funcref_expr1 *)
179
181
 
180
182
  let funcref_expr2 =
181
183
  Expression.Table.get wasm_mod "table"
@@ -212,6 +214,8 @@ let _ =
212
214
  (Expression.Const.make wasm_mod (Literal.int32 0l))
213
215
 
214
216
  let _ = Function.set_start wasm_mod start
217
+ let start_func = Function.get_start wasm_mod
218
+ let _ = assert (Function.get_name start_func = "start")
215
219
 
216
220
  let segment : Binaryen.Memory.segment =
217
221
  let data = Bytes.of_string "hello" in