@grain/binaryen.ml 0.33.0 → 0.35.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.
Files changed (56) hide show
  1. binaryen-archive/CHANGELOG.md +30 -0
  2. binaryen-archive/binaryen.opam +2 -2
  3. binaryen-archive/esy.lock/index.json +392 -293
  4. binaryen-archive/esy.lock/opam/base.v0.17.3/opam +4 -2
  5. binaryen-archive/esy.lock/opam/{chrome-trace.3.20.2 → chrome-trace.3.21.1}/opam +5 -5
  6. binaryen-archive/esy.lock/opam/{dune-build-info.3.20.2 → dune-build-info.3.21.1}/opam +5 -5
  7. binaryen-archive/esy.lock/opam/{dune-configurator.3.20.2 → dune-configurator.3.21.1}/opam +5 -5
  8. binaryen-archive/esy.lock/opam/{dune-rpc.3.20.2 → dune-rpc.3.21.1}/opam +5 -5
  9. binaryen-archive/esy.lock/opam/{dune.3.20.2 → dune.3.21.1}/opam +6 -5
  10. binaryen-archive/esy.lock/opam/{dyn.3.20.2 → dyn.3.21.1}/opam +6 -6
  11. binaryen-archive/esy.lock/opam/fs-io.3.21.1/opam +41 -0
  12. binaryen-archive/esy.lock/opam/{menhir.20250912 → menhir.20260209}/opam +6 -4
  13. binaryen-archive/esy.lock/opam/{menhirCST.20250912 → menhirCST.20260209}/opam +4 -3
  14. binaryen-archive/esy.lock/opam/menhirGLR.20260209/opam +30 -0
  15. binaryen-archive/esy.lock/opam/{menhirLib.20250912 → menhirLib.20260209}/opam +5 -4
  16. binaryen-archive/esy.lock/opam/{menhirSdk.20250912 → menhirSdk.20260209}/opam +5 -4
  17. binaryen-archive/esy.lock/opam/ocaml_intrinsics_kernel.v0.17.1/opam +2 -0
  18. binaryen-archive/esy.lock/opam/{ocamlc-loc.3.20.2 → ocamlc-loc.3.21.1}/opam +6 -6
  19. binaryen-archive/esy.lock/opam/ocamlfind.1.9.8/opam +1 -1
  20. binaryen-archive/esy.lock/opam/{ordering.3.20.2 → ordering.3.21.1}/opam +6 -6
  21. binaryen-archive/esy.lock/opam/ppx_yojson_conv_lib.v0.17.0/opam +2 -0
  22. binaryen-archive/esy.lock/opam/sexplib0.v0.17.0/opam +2 -0
  23. binaryen-archive/esy.lock/opam/stdio.v0.17.0/opam +3 -1
  24. binaryen-archive/esy.lock/opam/{stdune.3.20.2 → stdune.3.21.1}/opam +9 -7
  25. binaryen-archive/esy.lock/opam/top-closure.3.21.1/opam +40 -0
  26. binaryen-archive/esy.lock/opam/{xdg.3.20.2 → xdg.3.21.1}/opam +5 -5
  27. binaryen-archive/package.json +2 -2
  28. binaryen-archive/src/dune +2 -0
  29. binaryen-archive/src/export.c +10 -0
  30. binaryen-archive/src/export.js +13 -0
  31. binaryen-archive/src/export.ml +4 -0
  32. binaryen-archive/src/export.mli +1 -0
  33. binaryen-archive/src/expression.c +291 -0
  34. binaryen-archive/src/expression.js +182 -0
  35. binaryen-archive/src/expression.ml +118 -0
  36. binaryen-archive/src/expression.mli +87 -0
  37. binaryen-archive/src/function.c +8 -0
  38. binaryen-archive/src/function.js +5 -0
  39. binaryen-archive/src/function.ml +1 -0
  40. binaryen-archive/src/function.mli +1 -0
  41. binaryen-archive/src/import.c +32 -0
  42. binaryen-archive/src/import.js +47 -0
  43. binaryen-archive/src/import.ml +12 -0
  44. binaryen-archive/src/import.mli +5 -0
  45. binaryen-archive/src/module.js +2 -2
  46. binaryen-archive/src/ocaml_helpers.c +8 -0
  47. binaryen-archive/src/ocaml_helpers.h +4 -0
  48. binaryen-archive/src/passes.ml +95 -21
  49. binaryen-archive/src/passes.mli +91 -21
  50. binaryen-archive/src/tag.c +61 -0
  51. binaryen-archive/src/tag.js +43 -0
  52. binaryen-archive/src/tag.ml +11 -0
  53. binaryen-archive/src/tag.mli +8 -0
  54. binaryen-archive/src/type.js +4 -7
  55. binaryen-archive/test/test.expected +158 -31
  56. binaryen-archive/test/test.ml +95 -2
@@ -350,6 +350,93 @@ module Ref : sig
350
350
  (** Module, left, right *)
351
351
  end
352
352
 
353
+ (** Bindings for `try` instruction. *)
354
+ module Try : sig
355
+ val make :
356
+ Module.t -> string option -> t -> (string * t) list -> t option -> t
357
+ (** Module, name, body, catch clauses, catch all *)
358
+
359
+ val get_name : t -> string option
360
+ (** expr *)
361
+
362
+ val set_name : t -> string -> unit
363
+ (** expr, name *)
364
+
365
+ val get_body : t -> t
366
+ (** expr *)
367
+
368
+ val set_body : t -> t -> unit
369
+ (** expr, bodyExpr *)
370
+
371
+ val get_num_catch_tags : t -> int
372
+ (** expr *)
373
+
374
+ val get_num_catch_bodies : t -> int
375
+ (** expr *)
376
+
377
+ val get_catch_tag_at : t -> int -> string
378
+ (** expr, index *)
379
+
380
+ val set_catch_tag_at : t -> int -> string -> unit
381
+ (** expr, index, catchTag *)
382
+
383
+ val append_catch_tag : t -> string -> int
384
+ (** expr, catchTag *)
385
+
386
+ val insert_catch_tag_at : t -> int -> string -> unit
387
+ (** expr, index, catchTag *)
388
+
389
+ val remove_catch_tag_at : t -> int -> string
390
+ (** expr, index *)
391
+
392
+ val get_catch_body_at : t -> int -> t
393
+ (** expr, index *)
394
+
395
+ val set_catch_body_at : t -> int -> t -> unit
396
+ (** expr, index, catchExpr *)
397
+
398
+ val append_catch_body : t -> t -> int
399
+ (** expr, catchExpr *)
400
+
401
+ val insert_catch_body_at : t -> int -> t -> unit
402
+ (** expr, index, catchExpr *)
403
+
404
+ val remove_catch_body_at : t -> int -> t
405
+ (** expr, index *)
406
+
407
+ val has_catch_all : t -> bool
408
+ (** expr *)
409
+ end
410
+
411
+ module Throw : sig
412
+ val make : Module.t -> string -> t list -> t
413
+ (** Module, tag, operands *)
414
+
415
+ val get_tag : t -> string
416
+ (** expr *)
417
+
418
+ val set_tag : t -> string -> unit
419
+ (** expr, tagName *)
420
+
421
+ val get_num_operands : t -> int
422
+ (** expr *)
423
+
424
+ val get_operand_at : t -> int -> t
425
+ (** expr, index *)
426
+
427
+ val set_operand_at : t -> int -> t -> unit
428
+ (** expr, index, operandExpr *)
429
+
430
+ val append_operand : t -> t -> int
431
+ (** expr, operandExpr *)
432
+
433
+ val insert_operand_at : t -> int -> t -> unit
434
+ (** expr, index, operandExpr *)
435
+
436
+ val remove_operand_at : t -> int -> t
437
+ (** expr, index *)
438
+ end
439
+
353
440
  module Table : sig
354
441
  val get : Module.t -> string -> t -> Type.t -> t
355
442
  (** Module, name, index, type *)
@@ -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
@@ -67,6 +67,24 @@ caml_binaryen_add_global_import__bytecode(value * argv) {
67
67
  return caml_binaryen_add_global_import(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
68
68
  }
69
69
 
70
+ CAMLprim value
71
+ caml_binaryen_add_tag_import(value _module, value _internalName, value _externalModuleName, value _externalBaseName, value _paramsty, value _resultsty) {
72
+ CAMLparam5(_module, _internalName, _externalModuleName, _externalBaseName, _paramsty);
73
+ CAMLxparam1(_resultsty);
74
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
75
+ char* internalName = Safe_String_val(_internalName);
76
+ char* externalModuleName = Safe_String_val(_externalModuleName);
77
+ char* externalBaseName = Safe_String_val(_externalBaseName);
78
+ BinaryenType paramsty = BinaryenType_val(_paramsty);
79
+ BinaryenType resultsty = BinaryenType_val(_resultsty);
80
+ BinaryenAddTagImport(module, internalName, externalModuleName, externalBaseName, paramsty, resultsty);
81
+ CAMLreturn(Val_unit);
82
+ }
83
+ CAMLprim value
84
+ caml_binaryen_add_tag_import__bytecode(value * argv) {
85
+ return caml_binaryen_add_tag_import(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
86
+ }
87
+
70
88
  CAMLprim value
71
89
  caml_binaryen_function_import_get_module(value _fun) {
72
90
  CAMLparam1(_fun);
@@ -89,6 +107,13 @@ caml_binaryen_global_import_get_module(value _global) {
89
107
  CAMLreturn(caml_copy_string(BinaryenGlobalImportGetModule(global)));
90
108
  }
91
109
 
110
+ CAMLprim value
111
+ caml_binaryen_tag_import_get_module(value _tag) {
112
+ CAMLparam1(_tag);
113
+ BinaryenTagRef tag = BinaryenTagRef_val(_tag);
114
+ CAMLreturn(caml_copy_string(BinaryenTagImportGetModule(tag)));
115
+ }
116
+
92
117
  CAMLprim value
93
118
  caml_binaryen_function_import_get_base(value _fun) {
94
119
  CAMLparam1(_fun);
@@ -110,3 +135,10 @@ caml_binaryen_global_import_get_base(value _global) {
110
135
  BinaryenGlobalRef global = BinaryenGlobalRef_val(_global);
111
136
  CAMLreturn(caml_copy_string(BinaryenGlobalImportGetBase(global)));
112
137
  }
138
+
139
+ CAMLprim value
140
+ caml_binaryen_tag_import_get_base(value _tag) {
141
+ CAMLparam1(_tag);
142
+ BinaryenTagRef tag = BinaryenTagRef_val(_tag);
143
+ CAMLreturn(caml_copy_string(BinaryenTagImportGetBase(tag)));
144
+ }
@@ -92,6 +92,37 @@ function caml_binaryen_add_global_import__bytecode() {
92
92
  );
93
93
  }
94
94
 
95
+ //Provides: caml_binaryen_add_tag_import
96
+ //Requires: caml_jsstring_of_string
97
+ function caml_binaryen_add_tag_import(
98
+ wasm_mod,
99
+ internalName,
100
+ externalModuleName,
101
+ externalBaseName,
102
+ paramsty,
103
+ resultsty
104
+ ) {
105
+ return wasm_mod.addTagImport(
106
+ caml_jsstring_of_string(internalName),
107
+ caml_jsstring_of_string(externalModuleName),
108
+ caml_jsstring_of_string(externalBaseName),
109
+ paramsty,
110
+ resultsty
111
+ );
112
+ }
113
+ //Provides: caml_binaryen_add_tag_import__bytecode
114
+ //Requires: caml_binaryen_add_tag_import
115
+ function caml_binaryen_add_tag_import__bytecode() {
116
+ return caml_binaryen_add_tag_import(
117
+ arguments[0],
118
+ arguments[1],
119
+ arguments[2],
120
+ arguments[3],
121
+ arguments[4],
122
+ arguments[5]
123
+ );
124
+ }
125
+
95
126
  //Provides: caml_binaryen_function_import_get_module
96
127
  //Requires: Binaryen
97
128
  //Requires: caml_string_of_jsstring
@@ -115,6 +146,14 @@ function caml_binaryen_global_import_get_module(global) {
115
146
  return caml_string_of_jsstring(global_info.module);
116
147
  }
117
148
 
149
+ //Provides: caml_binaryen_tag_import_get_module
150
+ //Requires: Binaryen
151
+ //Requires: caml_string_of_jsstring
152
+ function caml_binaryen_tag_import_get_module(tag) {
153
+ var tag_info = Binaryen.getTagInfo(tag);
154
+ return caml_string_of_jsstring(tag_info.module);
155
+ }
156
+
118
157
  //Provides: caml_binaryen_function_import_get_base
119
158
  //Requires: Binaryen
120
159
  //Requires: caml_string_of_jsstring
@@ -137,3 +176,11 @@ function caml_binaryen_global_import_get_base(global) {
137
176
  var global_info = Binaryen.getGlobalInfo(global);
138
177
  return caml_string_of_jsstring(global_info.base);
139
178
  }
179
+
180
+ //Provides: caml_binaryen_tag_import_get_base
181
+ //Requires: Binaryen
182
+ //Requires: caml_string_of_jsstring
183
+ function caml_binaryen_tag_import_get_base(tag) {
184
+ var tag_info = Binaryen.getTagInfo(tag);
185
+ return caml_string_of_jsstring(tag_info.base);
186
+ }
@@ -21,6 +21,12 @@ external add_global_import :
21
21
  (** Module, internal name, external module name, external base name, type,
22
22
  mutable. *)
23
23
 
24
+ external add_tag_import :
25
+ Module.t -> string -> string -> string -> Type.t -> Type.t -> unit
26
+ = "caml_binaryen_add_tag_import__bytecode" "caml_binaryen_add_tag_import"
27
+ (** Module, internal name, external module name, external base name, params
28
+ type, results type. *)
29
+
24
30
  external function_import_get_module : Function.t -> string
25
31
  = "caml_binaryen_function_import_get_module"
26
32
 
@@ -30,6 +36,9 @@ external memory_import_get_module : Module.t -> string -> string
30
36
  external global_import_get_module : Global.t -> string
31
37
  = "caml_binaryen_global_import_get_module"
32
38
 
39
+ external tag_import_get_module : Tag.t -> string
40
+ = "caml_binaryen_tag_import_get_module"
41
+
33
42
  external function_import_get_base : Function.t -> string
34
43
  = "caml_binaryen_function_import_get_base"
35
44
 
@@ -38,3 +47,6 @@ external memory_import_get_base : Module.t -> string -> string
38
47
 
39
48
  external global_import_get_base : Global.t -> string
40
49
  = "caml_binaryen_global_import_get_base"
50
+
51
+ external tag_import_get_base : Tag.t -> string
52
+ = "caml_binaryen_tag_import_get_base"
@@ -7,9 +7,14 @@ val add_memory_import : Module.t -> string -> string -> string -> bool -> unit
7
7
  val add_global_import :
8
8
  Module.t -> string -> string -> string -> Type.t -> bool -> unit
9
9
 
10
+ val add_tag_import :
11
+ Module.t -> string -> string -> string -> Type.t -> Type.t -> unit
12
+
10
13
  val function_import_get_module : Function.t -> string
11
14
  val memory_import_get_module : Module.t -> string -> string
12
15
  val global_import_get_module : Global.t -> string
16
+ val tag_import_get_module : Tag.t -> string
13
17
  val function_import_get_base : Function.t -> string
14
18
  val memory_import_get_base : Module.t -> string -> string
15
19
  val global_import_get_base : Global.t -> string
20
+ val tag_import_get_base : Tag.t -> string
@@ -122,11 +122,11 @@ function caml_binaryen_module_get_debug_info_filename(wasm_mod, index) {
122
122
  }
123
123
 
124
124
  //Provides: caml_binaryen_add_custom_section
125
- //Requires: caml_jsstring_of_string, caml_array_of_string
125
+ //Requires: caml_jsstring_of_string, caml_uint8_array_of_string
126
126
  function caml_binaryen_add_custom_section(wasm_mod, name, contents) {
127
127
  return wasm_mod.addCustomSection(
128
128
  caml_jsstring_of_string(name),
129
- caml_array_of_string(contents)
129
+ caml_uint8_array_of_string(contents)
130
130
  );
131
131
  }
132
132
 
@@ -38,6 +38,14 @@ value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp)
38
38
  return v;
39
39
  }
40
40
 
41
+ /* Allocating an OCaml custom block to hold the given BinaryenTagRef */
42
+ value alloc_BinaryenTagRef(BinaryenTagRef exp)
43
+ {
44
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenTagRef), 0, 1);
45
+ BinaryenTagRef_val(v) = exp;
46
+ return v;
47
+ }
48
+
41
49
  /* Allocating an OCaml custom block to hold the given BinaryenExportRef */
42
50
  value alloc_BinaryenExportRef(BinaryenExportRef exp)
43
51
  {
@@ -29,6 +29,7 @@ static struct custom_operations binaryen_ops = {
29
29
  #define BinaryenLiteral_val(v) (*((struct BinaryenLiteral*) Data_custom_val(v)))
30
30
  #define BinaryenFunctionRef_val(v) (*((BinaryenFunctionRef*) Data_custom_val(v)))
31
31
  #define BinaryenGlobalRef_val(v) (*((BinaryenGlobalRef*) Data_custom_val(v)))
32
+ #define BinaryenTagRef_val(v) (*((BinaryenTagRef*) Data_custom_val(v)))
32
33
  #define BinaryenExportRef_val(v) (*((BinaryenExportRef*) Data_custom_val(v)))
33
34
  #define BinaryenTableRef_val(v) (*((BinaryenTableRef*) Data_custom_val(v)))
34
35
  #define BinaryenElementSegmentRef_val(v) (*((BinaryenElementSegmentRef*) Data_custom_val(v)))
@@ -53,6 +54,9 @@ value alloc_BinaryenType(BinaryenType typ);
53
54
  /* Allocating an OCaml custom block to hold the given BinaryenGlobalRef */
54
55
  value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp);
55
56
 
57
+ /* Allocating an OCaml custom block to hold the given BinaryenTagRef */
58
+ value alloc_BinaryenTagRef(BinaryenTagRef exp);
59
+
56
60
  /* Allocating an OCaml custom block to hold the given BinaryenExportRef */
57
61
  value alloc_BinaryenExportRef(BinaryenExportRef exp);
58
62
 
@@ -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,12 +226,8 @@ 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
 
199
- (** apply the assumption that asyncify imports always unwind, and we never
200
- rewind *)
201
- let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind"
202
-
203
- (** apply the assumption that asyncify never unwinds *)
204
- let mod_asyncify_never_unwind = "mod-asyncify-never-unwind"
229
+ (** Split types into minimal recursion groups *)
230
+ let minimize_rec_groups = "minimize-rec-groups"
205
231
 
206
232
  (** creates specialized versions of functions *)
207
233
  let monomorphize = "monomorphize"
@@ -223,6 +249,19 @@ let nm = "nm"
223
249
  (** (re)name all heap types *)
224
250
  let name_types = "name-types"
225
251
 
252
+ (** mark functions as no-inline *)
253
+ let no_inline = "no-inline"
254
+
255
+ (** mark functions as no-inline (for full inlining only) *)
256
+ let no_full_inline = "no-full-inline"
257
+
258
+ (** mark functions as no-inline (for partial inlining only) *)
259
+ let no_partial_inline = "no-partial-inline"
260
+
261
+ (** lower nontrapping float-to-int operations to wasm mvp and disable the
262
+ nontrapping fptoint feature *)
263
+ let llvm_nontrapping_fptoint_lowering = "llvm-nontrapping-fptoint-lowering"
264
+
226
265
  (** reduces calls to code that only runs once *)
227
266
  let once_reduction = "once-reduction"
228
267
 
@@ -239,9 +278,6 @@ let optimize_casts = "optimize-casts"
239
278
  (** optimizes instruction combinations *)
240
279
  let optimize_instructions = "optimize-instructions"
241
280
 
242
- (** optimize Stack IR *)
243
- let optimize_stack_ir = "optimize-stack-ir"
244
-
245
281
  (** pick load signs based on their uses *)
246
282
  let pick_load_signs = "pick-load-signs"
247
283
 
@@ -282,15 +318,15 @@ let print_function_map = "print-function-map"
282
318
  (** alias for print_function_map *)
283
319
  let symbolmap = "symbolmap"
284
320
 
285
- (** print out Stack IR (useful for internal debugging) *)
286
- let print_stack_ir = "print-stack-ir"
287
-
288
321
  (** removes operations incompatible with js *)
289
322
  let remove_non_js_ops = "remove-non-js-ops"
290
323
 
291
324
  (** removes imports and replaces them with nops *)
292
325
  let remove_imports = "remove-imports"
293
326
 
327
+ (** removes memory initialization *)
328
+ let remove_memory_init = "remove-memory-init"
329
+
294
330
  (** removes memory segments *)
295
331
  let remove_memory = "remove-memory"
296
332
 
@@ -310,18 +346,21 @@ let remove_unused_names = "remove-unused-names"
310
346
  (** remove unused private GC types *)
311
347
  let remove_unused_types = "remove-unused-types"
312
348
 
349
+ (** sorts functions by name (useful for debugging) *)
350
+ let reorder_functions_by_name = "reorder-functions-by-name"
351
+
313
352
  (** sorts functions by access frequency *)
314
353
  let reorder_functions = "reorder-functions"
315
354
 
316
355
  (** sorts globals by access frequency *)
317
356
  let reorder_globals = "reorder-globals"
318
357
 
319
- (** sorts globals by access frequency (even if there are few) *)
320
- let reorder_globals_always = "reorder-globals-always"
321
-
322
358
  (** sorts locals by access frequency *)
323
359
  let reorder_locals = "reorder-locals"
324
360
 
361
+ (** sorts private types by access frequency *)
362
+ let reorder_types = "reorder-types"
363
+
325
364
  (** re-optimize control flow using the relooper algorithm *)
326
365
  let rereloop = "rereloop"
327
366
 
@@ -337,6 +376,9 @@ let safe_heap = "safe-heap"
337
376
  (** sets specified globals to specified values *)
338
377
  let set_globals = "set-globals"
339
378
 
379
+ (** write data segments to a file and strip them from the module *)
380
+ let separate_data_segments = "separate-data-segments"
381
+
340
382
  (** remove params from function signature types where possible *)
341
383
  let signature_pruning = "signature-pruning"
342
384
 
@@ -388,6 +430,23 @@ let ssa = "ssa"
388
430
  (** ssa-ify variables so that they have a single assignment, ignoring merges *)
389
431
  let ssa_nomerge = "ssa-nomerge"
390
432
 
433
+ (** gathers wasm strings to globals *)
434
+ let string_gathering = "string-gathering"
435
+
436
+ (** lift string imports to wasm strings *)
437
+ let string_lifting = "string-lifting"
438
+
439
+ (** lowers wasm strings and operations to imports *)
440
+ let string_lowering = "string-lowering"
441
+
442
+ (** same as string-lowering, but encodes well-formed strings as magic imports *)
443
+ let string_lowering_magic_imports = "string-lowering-magic-imports"
444
+
445
+ (** same as string-lowering-magic-imports, but raise a fatal error if there are
446
+ invalid strings *)
447
+ let string_lowering_magic_imports_assert =
448
+ "string-lowering-magic-imports-assert"
449
+
391
450
  (** deprecated; same as strip-debug *)
392
451
  let strip = "strip"
393
452
 
@@ -409,18 +468,33 @@ let strip_eh = "strip-eh"
409
468
  (** strip the wasm target features section *)
410
469
  let strip_target_features = "strip-target-features"
411
470
 
471
+ (** translate old Phase 3 EH instructions to new ones with exnref *)
472
+ let translate_to_exnref = "translate-to-exnref"
473
+
412
474
  (** replace trapping operations with clamping semantics *)
413
475
  let trap_mode_clamp = "trap-mode-clamp"
414
476
 
415
477
  (** replace trapping operations with js semantics *)
416
478
  let trap_mode_js = "trap-mode-js"
417
479
 
480
+ (** optimize trivial tuples away *)
481
+ let tuple_optimization = "tuple-optimization"
482
+
483
+ (** mark all leaf types as final *)
484
+ let type_finalizing = "type-finalizing"
485
+
418
486
  (** merge types to their supertypes where possible *)
419
487
  let type_merging = "type-merging"
420
488
 
421
489
  (** create new nominal types to help other optimizations *)
422
490
  let type_ssa = "type-ssa"
423
491
 
492
+ (** mark all types as non-final (open) *)
493
+ let type_unfinalizing = "type-unfinalizing"
494
+
495
+ (** removes removes unnecessary subtyping relationships *)
496
+ let unsubtyping = "unsubtyping"
497
+
424
498
  (** removes local.tees, replacing them with sets and gets *)
425
499
  let untee = "untee"
426
500