@grain/binaryen.ml 0.20.0 → 0.21.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 (107) hide show
  1. binaryen-archive/CHANGELOG.md +42 -0
  2. binaryen-archive/binaryen.opam +3 -3
  3. binaryen-archive/esy.lock/index.json +491 -426
  4. binaryen-archive/esy.lock/opam/{base.v0.15.1 → base.v0.16.1}/opam +7 -4
  5. binaryen-archive/esy.lock/opam/{chrome-trace.3.6.1 → chrome-trace.3.9.0}/opam +4 -4
  6. binaryen-archive/esy.lock/opam/{cmdliner.1.1.1 → cmdliner.1.2.0}/opam +2 -2
  7. binaryen-archive/esy.lock/opam/{csexp.1.5.1 → csexp.1.5.2}/opam +7 -9
  8. binaryen-archive/esy.lock/opam/{dune-build-info.3.6.1 → dune-build-info.3.9.0}/opam +4 -4
  9. binaryen-archive/esy.lock/opam/{dune-configurator.3.6.1 → dune-configurator.3.9.0}/opam +4 -4
  10. binaryen-archive/esy.lock/opam/{dune-rpc.3.6.1 → dune-rpc.3.9.0}/opam +4 -4
  11. binaryen-archive/esy.lock/opam/{dune.3.6.1 → dune.3.9.0}/opam +5 -5
  12. binaryen-archive/esy.lock/opam/{dyn.3.6.1 → dyn.3.9.0}/opam +4 -4
  13. binaryen-archive/esy.lock/opam/fiber.3.7.0/opam +39 -0
  14. binaryen-archive/esy.lock/opam/{fix.20220121 → fix.20230505}/opam +3 -3
  15. binaryen-archive/esy.lock/opam/gen.1.1/opam +31 -0
  16. binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.4.1.0 → js_of_ocaml-compiler.5.3.0}/opam +10 -10
  17. binaryen-archive/esy.lock/opam/{menhir.20220210 → menhir.20230608}/opam +4 -4
  18. binaryen-archive/esy.lock/opam/{menhirLib.20220210 → menhirLib.20230608}/opam +4 -4
  19. binaryen-archive/esy.lock/opam/{menhirSdk.20220210 → menhirSdk.20230608}/opam +4 -4
  20. binaryen-archive/esy.lock/opam/{ocamlbuild.0.14.2 → ocamlbuild.0.14.2+win}/opam +13 -14
  21. binaryen-archive/esy.lock/opam/ocamlfind.1.9.6/files/0001-Harden-test-for-OCaml-5.patch +12 -0
  22. binaryen-archive/esy.lock/opam/{ocamlfind.1.9.5 → ocamlfind.1.9.6}/opam +8 -7
  23. binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.24.1 → ocamlformat-rpc-lib.0.25.1}/opam +4 -4
  24. binaryen-archive/esy.lock/opam/ocamlformat.0.24.1/opam +1 -1
  25. binaryen-archive/esy.lock/opam/{ordering.3.6.1 → ordering.3.9.0}/opam +4 -4
  26. binaryen-archive/esy.lock/opam/{ppx_yojson_conv_lib.v0.15.0 → ppx_yojson_conv_lib.v0.16.0}/opam +3 -3
  27. binaryen-archive/esy.lock/opam/{ppxlib.0.28.0 → ppxlib.0.29.1}/opam +5 -5
  28. binaryen-archive/esy.lock/opam/sedlex.3.2/opam +48 -0
  29. binaryen-archive/esy.lock/opam/{sexplib0.v0.15.1 → sexplib0.v0.16.0}/opam +3 -3
  30. binaryen-archive/esy.lock/opam/{stdio.v0.15.0 → stdio.v0.16.0}/opam +4 -4
  31. binaryen-archive/esy.lock/opam/{stdune.3.6.1 → stdune.3.9.0}/opam +4 -4
  32. binaryen-archive/esy.lock/opam/{topkg.1.0.6 → topkg.1.0.7}/opam +2 -2
  33. binaryen-archive/esy.lock/opam/{xdg.3.6.1 → xdg.3.9.0}/opam +4 -4
  34. binaryen-archive/esy.lock/opam/{yojson.2.0.2 → yojson.2.1.0}/opam +33 -23
  35. binaryen-archive/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override/files/ocamlbuild-0.14.2.patch +0 -0
  36. binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.6_opam_override/files/findlib.patch +11 -0
  37. binaryen-archive/package.json +3 -3
  38. binaryen-archive/src/array_type.c +29 -0
  39. binaryen-archive/src/array_type.js +17 -0
  40. binaryen-archive/src/array_type.ml +8 -0
  41. binaryen-archive/src/array_type.mli +3 -0
  42. binaryen-archive/src/dune +38 -32
  43. binaryen-archive/src/{binaryen_stubs_exports.c → export.c} +0 -8
  44. binaryen-archive/src/{binaryen_stubs_expressions.c → expression.c} +0 -9
  45. binaryen-archive/src/{binaryen_stubs_expressions.js → expression.js} +18 -8
  46. binaryen-archive/src/{binaryen_stubs_functions.c → function.c} +0 -24
  47. binaryen-archive/src/{binaryen_stubs_globals.c → global.c} +0 -25
  48. binaryen-archive/src/heap_type.c +171 -0
  49. binaryen-archive/src/heap_type.js +131 -0
  50. binaryen-archive/src/heap_type.ml +11 -0
  51. binaryen-archive/src/heap_type.mli +11 -0
  52. binaryen-archive/src/{binaryen_stubs_literals.c → literal.c} +0 -9
  53. binaryen-archive/src/{binaryen_stubs_memory.c → memory.c} +15 -5
  54. binaryen-archive/src/{binaryen_stubs_memory.js → memory.js} +11 -1
  55. binaryen-archive/src/memory.ml +6 -3
  56. binaryen-archive/src/memory.mli +10 -1
  57. binaryen-archive/src/{binaryen_stubs_modules.c → module.c} +0 -9
  58. binaryen-archive/src/module.ml +4 -5
  59. binaryen-archive/src/module.mli +1 -1
  60. binaryen-archive/src/{binaryen_stubs_features.c → module_feature.c} +6 -6
  61. binaryen-archive/src/{binaryen_stubs_features.js → module_feature.js} +6 -6
  62. binaryen-archive/src/ocaml_helpers.c +87 -0
  63. binaryen-archive/src/ocaml_helpers.h +33 -0
  64. binaryen-archive/src/{binaryen_stubs_ops.c → op.c} +582 -325
  65. binaryen-archive/src/op.js +2123 -0
  66. binaryen-archive/src/op.ml +385 -344
  67. binaryen-archive/src/op.mli +38 -0
  68. binaryen-archive/src/passes.ml +38 -2
  69. binaryen-archive/src/passes.mli +38 -2
  70. binaryen-archive/src/signature_type.c +23 -0
  71. binaryen-archive/src/signature_type.js +11 -0
  72. binaryen-archive/src/signature_type.ml +5 -0
  73. binaryen-archive/src/signature_type.mli +2 -0
  74. binaryen-archive/src/struct_type.c +39 -0
  75. binaryen-archive/src/struct_type.js +23 -0
  76. binaryen-archive/src/struct_type.ml +11 -0
  77. binaryen-archive/src/struct_type.mli +4 -0
  78. binaryen-archive/src/{binaryen_stubs_tables.c → table.c} +0 -25
  79. binaryen-archive/src/{binaryen_stubs_types.c → type.c} +28 -10
  80. binaryen-archive/src/{binaryen_stubs_types.js → type.js} +28 -0
  81. binaryen-archive/src/type.ml +16 -0
  82. binaryen-archive/src/type.mli +4 -0
  83. binaryen-archive/test/test.expected +5 -5
  84. binaryen-archive/test/test.ml +20 -5
  85. binaryen-archive/esy.lock/opam/fiber.3.6.1/opam +0 -41
  86. binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/files/0001-Fix-bug-when-installing-with-a-system-compiler.patch +0 -26
  87. binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.5_opam_override/files/findlib.patch +0 -485
  88. binaryen-archive/src/binaryen_stubs_heap_types.c +0 -95
  89. binaryen-archive/src/binaryen_stubs_heap_types.js +0 -65
  90. binaryen-archive/src/binaryen_stubs_ops.js +0 -1895
  91. /binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.2_opam_override → opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override}/files/winpatch.patch +0 -0
  92. /binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.2_opam_override → opam__s__ocamlbuild_opam__c__0.14.2+win_opam_override}/package.json +0 -0
  93. /binaryen-archive/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.9.5_opam_override → opam__s__ocamlfind_opam__c__1.9.6_opam_override}/package.json +0 -0
  94. /binaryen-archive/src/{binaryen_stubs_exports.js → export.js} +0 -0
  95. /binaryen-archive/src/{binaryen_stubs_functions.js → function.js} +0 -0
  96. /binaryen-archive/src/{binaryen_stubs_globals.js → global.js} +0 -0
  97. /binaryen-archive/src/{binaryen_stubs_imports.c → import.c} +0 -0
  98. /binaryen-archive/src/{binaryen_stubs_imports.js → import.js} +0 -0
  99. /binaryen-archive/src/{binaryen_stubs_literals.js → literal.js} +0 -0
  100. /binaryen-archive/src/{binaryen_stubs_modules.js → module.js} +0 -0
  101. /binaryen-archive/src/{binaryen_stubs_packed_types.c → packed_type.c} +0 -0
  102. /binaryen-archive/src/{binaryen_stubs_packed_types.js → packed_type.js} +0 -0
  103. /binaryen-archive/src/{binaryen_stubs_settings.c → settings.c} +0 -0
  104. /binaryen-archive/src/{binaryen_stubs_settings.js → settings.js} +0 -0
  105. /binaryen-archive/src/{binaryen_stubs_tables.js → table.js} +0 -0
  106. /binaryen-archive/src/{binaryen_stubs_type_system.c → type_system.c} +0 -0
  107. /binaryen-archive/src/{binaryen_stubs_type_system.js → type_system.js} +0 -0
@@ -316,3 +316,41 @@ val ref_as_non_null : t
316
316
  val ref_as_func : t
317
317
  val ref_as_data : t
318
318
  val ref_as_i31 : t
319
+ val ref_as_extern_internalize : unit -> t
320
+ val ref_as_extern_externalize : unit -> t
321
+ val br_on_null : unit -> t
322
+ val br_on_non_null : unit -> t
323
+ val br_on_cast : unit -> t
324
+ val br_on_cast_fail : unit -> t
325
+ val br_on_func : unit -> t
326
+ val br_on_non_func : unit -> t
327
+ val br_on_data : unit -> t
328
+ val br_on_non_data : unit -> t
329
+ val br_on_i31 : unit -> t
330
+ val br_on_non_i31 : unit -> t
331
+ val string_new_utf8 : unit -> t
332
+ val string_new_wtf8 : unit -> t
333
+ val string_new_replace : unit -> t
334
+ val string_new_wtf16 : unit -> t
335
+ val string_new_utf8_array : unit -> t
336
+ val string_new_wtf8_array : unit -> t
337
+ val string_new_replace_array : unit -> t
338
+ val string_new_wtf16_array : unit -> t
339
+ val string_measure_utf8 : unit -> t
340
+ val string_measure_wtf8 : unit -> t
341
+ val string_measure_wtf16 : unit -> t
342
+ val string_measure_is_usv : unit -> t
343
+ val string_measure_wtf16_view : unit -> t
344
+ val string_encode_utf8 : unit -> t
345
+ val string_encode_wtf8 : unit -> t
346
+ val string_encode_wtf16 : unit -> t
347
+ val string_encode_utf8_array : unit -> t
348
+ val string_encode_wtf8_array : unit -> t
349
+ val string_encode_wtf16_array : unit -> t
350
+ val string_as_wtf8 : unit -> t
351
+ val string_as_wtf16 : unit -> t
352
+ val string_as_iter : unit -> t
353
+ val string_iter_move_advance : unit -> t
354
+ val string_iter_move_rewind : unit -> t
355
+ val string_slice_wtf8 : unit -> t
356
+ val string_slice_wtf16 : unit -> t
@@ -45,6 +45,9 @@ let denan = "denan"
45
45
  (** turns indirect calls into direct ones *)
46
46
  let directize = "directize"
47
47
 
48
+ (** discards global effect info *)
49
+ let discard_global_effects = "discard-global-effects"
50
+
48
51
  (** optimizes using the DataFlow SSA IR *)
49
52
  let dfo = "dfo"
50
53
 
@@ -81,17 +84,26 @@ let generate_dyncalls = "generate-dyncalls"
81
84
  (** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *)
82
85
  let generate_i64_dyncalls = "generate-i64-dyncalls"
83
86
 
87
+ (** generate global effect info (helps later passes) *)
88
+ let generate_global_effects = "generate-global-effects"
89
+
84
90
  (** generate Stack IR *)
85
91
  let generate_stack_ir = "generate-stack-ir"
86
92
 
87
93
  (** refine the types of globals *)
88
94
  let global_refining = "global-refining"
89
95
 
96
+ (** globally optimize struct values *)
97
+ let gsi = "gsi"
98
+
90
99
  (** globally optimize GC types *)
91
100
  let gto = "gto"
92
101
 
93
- (** globally optimize struct values *)
94
- let gsi = "gsi"
102
+ (** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *)
103
+ let gufa = "gufa"
104
+
105
+ (** GUFA plus local optimizations in functions we modified *)
106
+ let gufa_optimizing = "gufa-optimizing"
95
107
 
96
108
  (** apply more specific subtypes to type fields where possible *)
97
109
  let type_refining = "type-refining"
@@ -111,6 +123,9 @@ let inlining_optimizing = "inlining-optimizing"
111
123
  (** lower away binaryen intrinsics *)
112
124
  let intrinsic_lowering = "intrinsic-lowering"
113
125
 
126
+ (** wrap imports and exports for JavaScript promise integration *)
127
+ let jspi = "jspi"
128
+
114
129
  (** legalizes i64 types on the import/export boundary *)
115
130
  let legalize_js_interface = "legalize-js-interface"
116
131
 
@@ -175,6 +190,15 @@ let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind"
175
190
  (** apply the assumption that asyncify never unwinds *)
176
191
  let mod_asyncify_never_unwind = "mod-asyncify-never-unwind"
177
192
 
193
+ (** creates specialized versions of functions *)
194
+ let monomorphize = "monomorphize"
195
+
196
+ (** creates specialized versions of functions (even if unhelpful) *)
197
+ let monomorphize_always = "monomorphize-always"
198
+
199
+ (** combines multiple memories into a single memory *)
200
+ let multi_memory_lowering = "multi-memory-lowering"
201
+
178
202
  (** name list *)
179
203
  let nm = "nm"
180
204
 
@@ -190,6 +214,9 @@ let optimize_added_constants = "optimize-added-constants"
190
214
  (** optimizes added constants into load/store offsets, propagating them across locals too *)
191
215
  let optimize_added_constants_propagate = "optimize-added-constants-propagate"
192
216
 
217
+ (** eliminate and reuse casts *)
218
+ let optimize_casts = "optimize-casts"
219
+
193
220
  (** optimizes instruction combinations *)
194
221
  let optimize_instructions = "optimize-instructions"
195
222
 
@@ -263,6 +290,12 @@ let remove_unused_names = "remove-unused-names"
263
290
  (** sorts functions by access frequency *)
264
291
  let reorder_functions = "reorder-functions"
265
292
 
293
+ (** sorts globals by access frequency *)
294
+ let reorder_globals = "reorder-globals"
295
+
296
+ (** sorts globals by access frequency (even if there are few) *)
297
+ let reorder_globals_always = "reorder-globals-always"
298
+
266
299
  (** sorts locals by access frequency *)
267
300
  let reorder_locals = "reorder-locals"
268
301
 
@@ -287,6 +320,9 @@ let signature_pruning = "signature-pruning"
287
320
  (** apply more specific subtypes to signature types where possible *)
288
321
  let signature_refining = "signature-refining"
289
322
 
323
+ (** lower sign-ext operations to wasm mvp *)
324
+ let signext_lowering = "signext-lowering"
325
+
290
326
  (** miscellaneous globals-related optimizations *)
291
327
  let simplify_globals = "simplify-globals"
292
328
 
@@ -45,6 +45,9 @@ val denan : t
45
45
  val directize : t
46
46
  (** turns indirect calls into direct ones *)
47
47
 
48
+ val discard_global_effects : t
49
+ (** discards global effect info *)
50
+
48
51
  val dfo : t
49
52
  (** optimizes using the DataFlow SSA IR *)
50
53
 
@@ -81,17 +84,26 @@ val generate_dyncalls : t
81
84
  val generate_i64_dyncalls : t
82
85
  (** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *)
83
86
 
87
+ val generate_global_effects : t
88
+ (** generate global effect info (helps later passes) *)
89
+
84
90
  val generate_stack_ir : t
85
91
  (** generate Stack IR *)
86
92
 
87
93
  val global_refining : t
88
94
  (** refine the types of globals *)
89
95
 
96
+ val gsi : t
97
+ (** globally optimize struct values *)
98
+
90
99
  val gto : t
91
100
  (** globally optimize GC types *)
92
101
 
93
- val gsi : t
94
- (** globally optimize struct values *)
102
+ val gufa : t
103
+ (** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *)
104
+
105
+ val gufa_optimizing : t
106
+ (** GUFA plus local optimizations in functions we modified *)
95
107
 
96
108
  val type_refining : t
97
109
  (** apply more specific subtypes to type fields where possible *)
@@ -111,6 +123,9 @@ val inlining_optimizing : t
111
123
  val intrinsic_lowering : t
112
124
  (** lower away binaryen intrinsics *)
113
125
 
126
+ val jspi : t
127
+ (** wrap imports and exports for JavaScript promise integration *)
128
+
114
129
  val legalize_js_interface : t
115
130
  (** legalizes i64 types on the import/export boundary *)
116
131
 
@@ -174,6 +189,15 @@ val mod_asyncify_always_and_only_unwind : t
174
189
  val mod_asyncify_never_unwind : t
175
190
  (** apply the assumption that asyncify never unwinds *)
176
191
 
192
+ val monomorphize : t
193
+ (** creates specialized versions of functions *)
194
+
195
+ val monomorphize_always : t
196
+ (** creates specialized versions of functions (even if unhelpful) *)
197
+
198
+ val multi_memory_lowering : t
199
+ (** combines multiple memories into a single memory *)
200
+
177
201
  val nm : t
178
202
  (** name list *)
179
203
 
@@ -189,6 +213,9 @@ val optimize_added_constants : t
189
213
  val optimize_added_constants_propagate : t
190
214
  (** optimizes added constants into load/store offsets, propagating them across locals too *)
191
215
 
216
+ val optimize_casts : t
217
+ (** eliminate and reuse casts *)
218
+
192
219
  val optimize_instructions : t
193
220
  (** optimizes instruction combinations *)
194
221
 
@@ -261,6 +288,12 @@ val remove_unused_names : t
261
288
  val reorder_functions : t
262
289
  (** sorts functions by access frequency *)
263
290
 
291
+ val reorder_globals : t
292
+ (** sorts globals by access frequency *)
293
+
294
+ val reorder_globals_always : t
295
+ (** sorts globals by access frequency (even if there are few) *)
296
+
264
297
  val reorder_locals : t
265
298
  (** sorts locals by access frequency *)
266
299
 
@@ -285,6 +318,9 @@ val signature_pruning : t
285
318
  val signature_refining : t
286
319
  (** apply more specific subtypes to signature types where possible *)
287
320
 
321
+ val signext_lowering : t
322
+ (** lower sign-ext operations to wasm mvp *)
323
+
288
324
  val simplify_globals : t
289
325
  (** miscellaneous globals-related optimizations *)
290
326
 
@@ -0,0 +1,23 @@
1
+ #define CAML_NAME_SPACE
2
+ #include <caml/mlvalues.h>
3
+ #include <caml/fail.h>
4
+ #include <caml/memory.h>
5
+
6
+ #include "binaryen-c.h"
7
+ #include "ocaml_helpers.h"
8
+
9
+ CAMLprim value
10
+ caml_binaryen_signature_type_get_params(value _heapType) {
11
+ CAMLparam1(_heapType);
12
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
13
+ BinaryenType ty = BinaryenSignatureTypeGetParams(heapType);
14
+ CAMLreturn(alloc_BinaryenType(ty));
15
+ }
16
+
17
+ CAMLprim value
18
+ caml_binaryen_signature_type_get_results(value _heapType) {
19
+ CAMLparam1(_heapType);
20
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
21
+ BinaryenType ty = BinaryenSignatureTypeGetResults(heapType);
22
+ CAMLreturn(alloc_BinaryenType(ty));
23
+ }
@@ -0,0 +1,11 @@
1
+ //Provides: caml_binaryen_signature_type_get_params
2
+ //Requires: Binaryen
3
+ function caml_binaryen_signature_type_get_params(heapType) {
4
+ return Binaryen._BinaryenSignatureTypeGetParams(heapType);
5
+ }
6
+
7
+ //Provides: caml_binaryen_signature_type_get_results
8
+ //Requires: Binaryen
9
+ function caml_binaryen_signature_type_get_results(heapType) {
10
+ return Binaryen._BinaryenSignatureTypeGetResults(heapType);
11
+ }
@@ -0,0 +1,5 @@
1
+ external get_params : Heap_type.t -> Type.t
2
+ = "caml_binaryen_signature_type_get_params"
3
+
4
+ external get_results : Heap_type.t -> Type.t
5
+ = "caml_binaryen_signature_type_get_results"
@@ -0,0 +1,2 @@
1
+ val get_params : Heap_type.t -> Type.t
2
+ val get_results : Heap_type.t -> Type.t
@@ -0,0 +1,39 @@
1
+ #define CAML_NAME_SPACE
2
+ #include <caml/mlvalues.h>
3
+ #include <caml/fail.h>
4
+ #include <caml/memory.h>
5
+
6
+ #include "binaryen-c.h"
7
+ #include "ocaml_helpers.h"
8
+
9
+ CAMLprim value
10
+ caml_binaryen_struct_type_get_num_fields(value _heapType) {
11
+ CAMLparam1(_heapType);
12
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
13
+ CAMLreturn(Val_int(BinaryenStructTypeGetNumFields(heapType)));
14
+ }
15
+
16
+ CAMLprim value
17
+ caml_binaryen_struct_type_get_field_type(value _heapType, value _index) {
18
+ CAMLparam2(_heapType, _index);
19
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
20
+ BinaryenIndex index = Int_val(_index);
21
+ BinaryenType ty = BinaryenStructTypeGetFieldType(heapType, index);
22
+ CAMLreturn(alloc_BinaryenType(ty));
23
+ }
24
+
25
+ CAMLprim value
26
+ caml_binaryen_struct_type_get_field_packed_type(value _heapType, value _index) {
27
+ CAMLparam2(_heapType, _index);
28
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
29
+ BinaryenIndex index = Int_val(_index);
30
+ CAMLreturn(Val_int(BinaryenStructTypeGetFieldPackedType(heapType, index)));
31
+ }
32
+
33
+ CAMLprim value
34
+ caml_binaryen_struct_type_is_field_mutable(value _heapType, value _index) {
35
+ CAMLparam2(_heapType, _index);
36
+ BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
37
+ BinaryenIndex index = Int_val(_index);
38
+ CAMLreturn(Val_bool(BinaryenStructTypeIsFieldMutable(heapType, index)));
39
+ }
@@ -0,0 +1,23 @@
1
+ //Provides: caml_binaryen_struct_type_get_num_fields
2
+ //Requires: Binaryen
3
+ function caml_binaryen_struct_type_get_num_fields(heapType) {
4
+ return Binaryen._BinaryenStructTypeGetNumFields(heapType);
5
+ }
6
+
7
+ //Provides: caml_binaryen_struct_type_get_field_type
8
+ //Requires: Binaryen
9
+ function caml_binaryen_struct_type_get_field_type(heapType, index) {
10
+ return Binaryen._BinaryenStructTypeGetFieldType(heapType, index);
11
+ }
12
+
13
+ //Provides: caml_binaryen_struct_type_get_field_packed_type
14
+ //Requires: Binaryen
15
+ function caml_binaryen_struct_type_get_field_packed_type(heapType, index) {
16
+ return Binaryen._BinaryenStructTypeGetFieldPackedType(heapType, index);
17
+ }
18
+
19
+ //Provides: caml_binaryen_struct_type_is_field_mutable
20
+ //Requires: Binaryen
21
+ function caml_binaryen_struct_type_is_field_mutable(heapType, index) {
22
+ return Binaryen._BinaryenStructTypeIsFieldMutable(heapType, index);
23
+ }
@@ -0,0 +1,11 @@
1
+ external get_num_fields : Heap_type.t -> int
2
+ = "caml_binaryen_struct_type_get_num_fields"
3
+
4
+ external get_field_type : Heap_type.t -> int -> Type.t
5
+ = "caml_binaryen_struct_type_get_field_type"
6
+
7
+ external get_field_packed_type : Heap_type.t -> int -> Packed_type.t
8
+ = "caml_binaryen_struct_type_get_field_packed_type"
9
+
10
+ external is_field_mutable : Heap_type.t -> int -> bool
11
+ = "caml_binaryen_struct_type_is_field_mutable"
@@ -0,0 +1,4 @@
1
+ val get_num_fields : Heap_type.t -> int
2
+ val get_field_type : Heap_type.t -> int -> Type.t
3
+ val get_field_packed_type : Heap_type.t -> int -> Packed_type.t
4
+ val is_field_mutable : Heap_type.t -> int -> bool
@@ -7,31 +7,6 @@
7
7
  #include "binaryen-c.h"
8
8
  #include "ocaml_helpers.h"
9
9
 
10
-
11
- /* Allocating an OCaml custom block to hold the given BinaryenTableRef */
12
- static value alloc_BinaryenTableRef(BinaryenTableRef table)
13
- {
14
- value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenTableRef), 0, 1);
15
- BinaryenTableRef_val(v) = table;
16
- return v;
17
- }
18
-
19
- /* Allocating an OCaml custom block to hold the given BinaryenElementSegmentRef */
20
- static value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem)
21
- {
22
- value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenElementSegmentRef), 0, 1);
23
- BinaryenElementSegmentRef_val(v) = elem;
24
- return v;
25
- }
26
-
27
- /* Allocating an OCaml custom block to hold the given BinaryenExpressionRef */
28
- static value alloc_BinaryenExpressionRef(BinaryenExpressionRef exp)
29
- {
30
- value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenExpressionRef), 0, 1);
31
- BinaryenExpressionRef_val(v) = exp;
32
- return v;
33
- }
34
-
35
10
  CAMLprim value
36
11
  caml_binaryen_add_table(value _module, value _table, value _initial, value _maximum, value _tableType) {
37
12
  CAMLparam5(_module, _table, _initial, _maximum, _tableType);
@@ -6,16 +6,6 @@
6
6
  #include "binaryen-c.h"
7
7
  #include "ocaml_helpers.h"
8
8
 
9
-
10
- /* Allocating an OCaml custom block to hold the given BinaryenType */
11
- static value alloc_BinaryenType(BinaryenType typ)
12
- {
13
- value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenType), 0, 1);
14
- BinaryenType_val(v) = typ;
15
- return v;
16
- }
17
-
18
-
19
9
  CAMLprim value
20
10
  caml_binaryen_type_none(value unit) {
21
11
  CAMLparam1(unit);
@@ -93,6 +83,13 @@ caml_binaryen_type_dataref(value unit) {
93
83
  CAMLreturn(alloc_BinaryenType(ty));
94
84
  }
95
85
 
86
+ CAMLprim value
87
+ caml_binaryen_type_arrayref(value unit) {
88
+ CAMLparam1(unit);
89
+ BinaryenType ty = BinaryenTypeArrayref();
90
+ CAMLreturn(alloc_BinaryenType(ty));
91
+ }
92
+
96
93
  CAMLprim value
97
94
  caml_binaryen_type_stringref(value unit) {
98
95
  CAMLparam1(unit);
@@ -121,6 +118,27 @@ caml_binaryen_type_stringview_iter(value unit) {
121
118
  CAMLreturn(alloc_BinaryenType(ty));
122
119
  }
123
120
 
121
+ CAMLprim value
122
+ caml_binaryen_type_nullref(value unit) {
123
+ CAMLparam1(unit);
124
+ BinaryenType ty = BinaryenTypeNullref();
125
+ CAMLreturn(alloc_BinaryenType(ty));
126
+ }
127
+
128
+ CAMLprim value
129
+ caml_binaryen_type_null_externref(value unit) {
130
+ CAMLparam1(unit);
131
+ BinaryenType ty = BinaryenTypeNullExternref();
132
+ CAMLreturn(alloc_BinaryenType(ty));
133
+ }
134
+
135
+ CAMLprim value
136
+ caml_binaryen_type_null_funcref(value unit) {
137
+ CAMLparam1(unit);
138
+ BinaryenType ty = BinaryenTypeNullFuncref();
139
+ CAMLreturn(alloc_BinaryenType(ty));
140
+ }
141
+
124
142
  CAMLprim value
125
143
  caml_binaryen_type_unreachable(value unit) {
126
144
  CAMLparam1(unit);
@@ -64,6 +64,13 @@ function caml_binaryen_type_dataref() {
64
64
  return Binaryen.dataref;
65
65
  }
66
66
 
67
+ //Provides: caml_binaryen_type_arrayref
68
+ //Requires: Binaryen
69
+ function caml_binaryen_type_arrayref() {
70
+ // TODO: Binaryen v111 didn't expose this directly
71
+ return Binaryen._BinaryenTypeArrayref();
72
+ }
73
+
67
74
  //Provides: caml_binaryen_type_stringref
68
75
  //Requires: Binaryen
69
76
  function caml_binaryen_type_stringref() {
@@ -88,6 +95,27 @@ function caml_binaryen_type_stringview_iter() {
88
95
  return Binaryen.stringview_iter;
89
96
  }
90
97
 
98
+ //Provides: caml_binaryen_type_nullref
99
+ //Requires: Binaryen
100
+ function caml_binaryen_type_nullref() {
101
+ // TODO: Binaryen v111 didn't expose this directly
102
+ return Binaryen._BinaryenTypeNullref();
103
+ }
104
+
105
+ //Provides: caml_binaryen_type_null_externref
106
+ //Requires: Binaryen
107
+ function caml_binaryen_type_null_externref() {
108
+ // TODO: Binaryen v111 didn't expose this directly
109
+ return Binaryen._BinaryenTypeNullExternref();
110
+ }
111
+
112
+ //Provides: caml_binaryen_type_null_funcref
113
+ //Requires: Binaryen
114
+ function caml_binaryen_type_null_funcref() {
115
+ // TODO: Binaryen v111 didn't expose this directly
116
+ return Binaryen._BinaryenTypeNullFuncref();
117
+ }
118
+
91
119
  //Provides: caml_binaryen_type_unreachable
92
120
  //Requires: Binaryen
93
121
  function caml_binaryen_type_unreachable() {
@@ -44,6 +44,10 @@ external dataref : unit -> t = "caml_binaryen_type_dataref"
44
44
 
45
45
  let dataref = dataref ()
46
46
 
47
+ external arrayref : unit -> t = "caml_binaryen_type_arrayref"
48
+
49
+ let arrayref = arrayref ()
50
+
47
51
  external stringref : unit -> t = "caml_binaryen_type_stringref"
48
52
 
49
53
  let stringref = stringref ()
@@ -60,6 +64,18 @@ external stringview_iter : unit -> t = "caml_binaryen_type_stringview_iter"
60
64
 
61
65
  let stringview_iter = stringview_iter ()
62
66
 
67
+ external nullref : unit -> t = "caml_binaryen_type_nullref"
68
+
69
+ let nullref = nullref ()
70
+
71
+ external null_externref : unit -> t = "caml_binaryen_type_null_externref"
72
+
73
+ let null_externref = null_externref ()
74
+
75
+ external null_funcref : unit -> t = "caml_binaryen_type_null_funcref"
76
+
77
+ let null_funcref = null_funcref ()
78
+
63
79
  external unreachable : unit -> t = "caml_binaryen_type_unreachable"
64
80
 
65
81
  let unreachable = unreachable ()
@@ -11,10 +11,14 @@ val anyref : t
11
11
  val eqref : t
12
12
  val i31ref : t
13
13
  val dataref : t
14
+ val arrayref : t
14
15
  val stringref : t
15
16
  val stringview_wtf8 : t
16
17
  val stringview_wtf16 : t
17
18
  val stringview_iter : t
19
+ val nullref : t
20
+ val null_externref : t
21
+ val null_funcref : t
18
22
  val unreachable : t
19
23
  val auto : t
20
24
  val create : t array -> t
@@ -3,7 +3,7 @@
3
3
  )
4
4
  (table.size $table)
5
5
  (table.grow $table
6
- (ref.null func)
6
+ (ref.null nofunc)
7
7
  (i32.const 0)
8
8
  )
9
9
  (module
@@ -33,7 +33,7 @@
33
33
  (i32.add
34
34
  (select
35
35
  (local.get $0)
36
- (i32.load8_s
36
+ (i32.load
37
37
  (local.get $1)
38
38
  )
39
39
  (i32.const 1)
@@ -85,7 +85,7 @@
85
85
  (i32.add
86
86
  (select
87
87
  (local.get $0)
88
- (i32.load8_s
88
+ (i32.load
89
89
  (local.get $1)
90
90
  )
91
91
  (i32.const 1)
@@ -133,7 +133,7 @@
133
133
  (i32.add
134
134
  (select
135
135
  (local.get $0)
136
- (i32.load8_s
136
+ (i32.load
137
137
  (local.get $1)
138
138
  )
139
139
  (i32.const 1)
@@ -180,7 +180,7 @@
180
180
  (func $0 (param $0 i32) (param $1 i32) (result i32)
181
181
  local.get $0
182
182
  local.get $1
183
- i32.load8_s $0
183
+ i32.load $0
184
184
  i32.const 1
185
185
  select
186
186
  local.get $1
@@ -36,6 +36,7 @@ let _ =
36
36
  = "external_base_name")
37
37
 
38
38
  let _ = assert (Memory.is_shared import_wasm_mod "internal_name" = true)
39
+ let _ = assert (Memory.is_64 import_wasm_mod "internal_name" = false)
39
40
 
40
41
  (* Testing Return.get_value *)
41
42
  let _ =
@@ -58,7 +59,7 @@ let x () = Expression.Local_get.make wasm_mod 0 Type.int32
58
59
  let y () = Expression.Local_get.make wasm_mod 1 Type.int32
59
60
 
60
61
  let load =
61
- Expression.Load.make wasm_mod 1 ~signed:true 0 0 Type.int32 (y ()) "0"
62
+ Expression.Load.make wasm_mod 4 ~signed:false 0 0 Type.int32 (y ()) "0"
62
63
 
63
64
  let select =
64
65
  Expression.Select.make wasm_mod
@@ -169,14 +170,14 @@ let _ = assert (Memory.has_memory wasm_mod = false)
169
170
  let _ =
170
171
  Memory.set_memory wasm_mod 1 Memory.unlimited "memory"
171
172
  [ segment; passive_segment ]
172
- false "0"
173
+ false false "0"
173
174
 
174
175
  let _ = assert (Memory.has_memory wasm_mod = true)
175
176
  let _ = assert (Memory.get_initial wasm_mod "0" = 1)
176
177
  let _ = assert (Memory.has_max wasm_mod "0" = false)
177
178
  let _ = assert (Memory.get_max wasm_mod "0" = Memory.unlimited)
178
179
  let max_memory_wasm_mod = Module.create ()
179
- let _ = Memory.set_memory max_memory_wasm_mod 1 2 "memory" [] false "0"
180
+ let _ = Memory.set_memory max_memory_wasm_mod 1 2 "memory" [] false false "0"
180
181
  let _ = assert (Memory.has_max max_memory_wasm_mod "0" = true)
181
182
  let _ = assert (Memory.get_max max_memory_wasm_mod "0" = 2)
182
183
 
@@ -204,6 +205,7 @@ let _ =
204
205
  Type.int32)
205
206
 
206
207
  let _ = Export.add_function_export wasm_mod "hello" "hello"
208
+ let _ = Module.validate wasm_mod
207
209
 
208
210
  (* Shouldn't actually do anything since we aren't doing function renames *)
209
211
  let _ = Module.update_maps wasm_mod
@@ -233,7 +235,20 @@ let new_mod = Module.read byts
233
235
 
234
236
  let _ =
235
237
  Module.run_passes new_mod
236
- [ Passes.name_types; Passes.merge_similar_functions; Passes.spill_pointers ]
238
+ [
239
+ Passes.generate_global_effects;
240
+ Passes.name_types;
241
+ Passes.merge_similar_functions;
242
+ Passes.spill_pointers;
243
+ Passes.gufa;
244
+ Passes.gufa_optimizing;
245
+ Passes.reorder_globals;
246
+ Passes.optimize_casts;
247
+ Passes.multi_memory_lowering;
248
+ Passes.monomorphize;
249
+ Passes.signext_lowering;
250
+ Passes.discard_global_effects;
251
+ ]
237
252
 
238
253
  let _ =
239
254
  Module.set_features new_mod
@@ -251,10 +266,10 @@ let _ =
251
266
  Module.Feature.multivalue;
252
267
  Module.Feature.gc;
253
268
  Module.Feature.memory64;
254
- Module.Feature.typed_function_references;
255
269
  Module.Feature.relaxed_simd;
256
270
  Module.Feature.extended_const;
257
271
  Module.Feature.strings;
272
+ Module.Feature.multi_memories;
258
273
  Module.Feature.all;
259
274
  ]
260
275