@grain/binaryen.ml 0.20.1 → 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 +30 -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_functions.c → function.c} +0 -24
  46. binaryen-archive/src/{binaryen_stubs_globals.c → global.c} +0 -25
  47. binaryen-archive/src/heap_type.c +171 -0
  48. binaryen-archive/src/heap_type.js +131 -0
  49. binaryen-archive/src/heap_type.ml +11 -0
  50. binaryen-archive/src/heap_type.mli +11 -0
  51. binaryen-archive/src/{binaryen_stubs_literals.c → literal.c} +0 -9
  52. binaryen-archive/src/{binaryen_stubs_memory.c → memory.c} +15 -5
  53. binaryen-archive/src/{binaryen_stubs_memory.js → memory.js} +11 -1
  54. binaryen-archive/src/memory.ml +6 -3
  55. binaryen-archive/src/memory.mli +10 -1
  56. binaryen-archive/src/{binaryen_stubs_modules.c → module.c} +0 -9
  57. binaryen-archive/src/module.ml +4 -5
  58. binaryen-archive/src/module.mli +1 -1
  59. binaryen-archive/src/{binaryen_stubs_features.c → module_feature.c} +6 -6
  60. binaryen-archive/src/{binaryen_stubs_features.js → module_feature.js} +6 -6
  61. binaryen-archive/src/ocaml_helpers.c +87 -0
  62. binaryen-archive/src/ocaml_helpers.h +33 -0
  63. binaryen-archive/src/{binaryen_stubs_ops.c → op.c} +582 -325
  64. binaryen-archive/src/op.js +2123 -0
  65. binaryen-archive/src/op.ml +385 -344
  66. binaryen-archive/src/op.mli +38 -0
  67. binaryen-archive/src/passes.ml +30 -0
  68. binaryen-archive/src/passes.mli +30 -0
  69. binaryen-archive/src/signature_type.c +23 -0
  70. binaryen-archive/src/signature_type.js +11 -0
  71. binaryen-archive/src/signature_type.ml +5 -0
  72. binaryen-archive/src/signature_type.mli +2 -0
  73. binaryen-archive/src/struct_type.c +39 -0
  74. binaryen-archive/src/struct_type.js +23 -0
  75. binaryen-archive/src/struct_type.ml +11 -0
  76. binaryen-archive/src/struct_type.mli +4 -0
  77. binaryen-archive/src/{binaryen_stubs_tables.c → table.c} +0 -25
  78. binaryen-archive/src/{binaryen_stubs_types.c → type.c} +28 -10
  79. binaryen-archive/src/{binaryen_stubs_types.js → type.js} +28 -0
  80. binaryen-archive/src/type.ml +16 -0
  81. binaryen-archive/src/type.mli +4 -0
  82. binaryen-archive/test/test.expected +1 -1
  83. binaryen-archive/test/test.ml +11 -3
  84. binaryen-archive/esy.lock/opam/fiber.3.6.1/opam +0 -41
  85. binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/files/0001-Fix-bug-when-installing-with-a-system-compiler.patch +0 -26
  86. binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.5_opam_override/files/findlib.patch +0 -485
  87. binaryen-archive/src/binaryen_stubs_heap_types.c +0 -95
  88. binaryen-archive/src/binaryen_stubs_heap_types.js +0 -65
  89. binaryen-archive/src/binaryen_stubs_ops.js +0 -1895
  90. /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
  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}/package.json +0 -0
  92. /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
  93. /binaryen-archive/src/{binaryen_stubs_exports.js → export.js} +0 -0
  94. /binaryen-archive/src/{binaryen_stubs_expressions.js → expression.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
@@ -0,0 +1,131 @@
1
+ //Provides: caml_binaryen_heap_type_ext
2
+ //Requires: Binaryen
3
+ function caml_binaryen_heap_type_ext() {
4
+ return Binaryen._BinaryenHeapTypeExt();
5
+ }
6
+
7
+ //Provides: caml_binaryen_heap_type_func
8
+ //Requires: Binaryen
9
+ function caml_binaryen_heap_type_func() {
10
+ return Binaryen._BinaryenHeapTypeFunc();
11
+ }
12
+
13
+ //Provides: caml_binaryen_heap_type_any
14
+ //Requires: Binaryen
15
+ function caml_binaryen_heap_type_any() {
16
+ return Binaryen._BinaryenHeapTypeAny();
17
+ }
18
+
19
+ //Provides: caml_binaryen_heap_type_eq
20
+ //Requires: Binaryen
21
+ function caml_binaryen_heap_type_eq() {
22
+ return Binaryen._BinaryenHeapTypeEq();
23
+ }
24
+
25
+ //Provides: caml_binaryen_heap_type_i31
26
+ //Requires: Binaryen
27
+ function caml_binaryen_heap_type_i31() {
28
+ return Binaryen._BinaryenHeapTypeI31();
29
+ }
30
+
31
+ //Provides: caml_binaryen_heap_type_data
32
+ //Requires: Binaryen
33
+ function caml_binaryen_heap_type_data() {
34
+ return Binaryen._BinaryenHeapTypeData();
35
+ }
36
+
37
+ //Provides: caml_binaryen_heap_type_array
38
+ //Requires: Binaryen
39
+ function caml_binaryen_heap_type_array() {
40
+ return Binaryen._BinaryenHeapTypeArray();
41
+ }
42
+
43
+ //Provides: caml_binaryen_heap_type_string
44
+ //Requires: Binaryen
45
+ function caml_binaryen_heap_type_string() {
46
+ return Binaryen._BinaryenHeapTypeString();
47
+ }
48
+
49
+ //Provides: caml_binaryen_heap_type_stringview_wtf8
50
+ //Requires: Binaryen
51
+ function caml_binaryen_heap_type_stringview_wtf8() {
52
+ return Binaryen._BinaryenHeapTypeStringviewWTF8();
53
+ }
54
+
55
+ //Provides: caml_binaryen_heap_type_stringview_wtf16
56
+ //Requires: Binaryen
57
+ function caml_binaryen_heap_type_stringview_wtf16() {
58
+ return Binaryen._BinaryenHeapTypeStringviewWTF16();
59
+ }
60
+
61
+ //Provides: caml_binaryen_heap_type_stringview_iter
62
+ //Requires: Binaryen
63
+ function caml_binaryen_heap_type_stringview_iter() {
64
+ return Binaryen._BinaryenHeapTypeStringviewIter();
65
+ }
66
+
67
+ //Provides: caml_binaryen_heap_type_none
68
+ //Requires: Binaryen
69
+ function caml_binaryen_heap_type_none() {
70
+ return Binaryen._BinaryenHeapTypeNone();
71
+ }
72
+
73
+ //Provides: caml_binaryen_heap_type_noext
74
+ //Requires: Binaryen
75
+ function caml_binaryen_heap_type_noext() {
76
+ return Binaryen._BinaryenHeapTypeNoext();
77
+ }
78
+
79
+ //Provides: caml_binaryen_heap_type_nofunc
80
+ //Requires: Binaryen
81
+ function caml_binaryen_heap_type_nofunc() {
82
+ return Binaryen._BinaryenHeapTypeNofunc();
83
+ }
84
+
85
+ //Provides: caml_binaryen_heap_type_is_basic
86
+ //Requires: Binaryen
87
+ function caml_binaryen_heap_type_is_basic(ty) {
88
+ return Binaryen._BinaryenHeapTypeIsBasic(ty);
89
+ }
90
+
91
+ //Provides: caml_binaryen_heap_type_is_signature
92
+ //Requires: Binaryen
93
+ function caml_binaryen_heap_type_is_signature(ty) {
94
+ return Binaryen._BinaryenHeapTypeIsSignature(ty);
95
+ }
96
+
97
+ //Provides: caml_binaryen_heap_type_is_struct
98
+ //Requires: Binaryen
99
+ function caml_binaryen_heap_type_is_struct(ty) {
100
+ return Binaryen._BinaryenHeapTypeIsStruct(ty);
101
+ }
102
+
103
+ //Provides: caml_binaryen_heap_type_is_array
104
+ //Requires: Binaryen
105
+ function caml_binaryen_heap_type_is_array(ty) {
106
+ return Binaryen._BinaryenHeapTypeIsArray(ty);
107
+ }
108
+
109
+ //Provides: caml_binaryen_heap_type_is_bottom
110
+ //Requires: Binaryen
111
+ function caml_binaryen_heap_type_is_bottom(ty) {
112
+ return Binaryen._BinaryenHeapTypeIsBottom(ty);
113
+ }
114
+
115
+ //Provides: caml_binaryen_heap_type_get_bottom
116
+ //Requires: Binaryen
117
+ function caml_binaryen_heap_type_get_bottom(ty) {
118
+ return Binaryen._BinaryenHeapTypeGetBottom(ty);
119
+ }
120
+
121
+ //Provides: caml_binaryen_heap_type_is_sub_type
122
+ //Requires: Binaryen
123
+ function caml_binaryen_heap_type_is_sub_type(left, right) {
124
+ return Binaryen._BinaryenHeapTypeIsSubType(left, right);
125
+ }
126
+
127
+ //Provides: caml_binaryen_type_get_heap_type
128
+ //Requires: Binaryen
129
+ function caml_binaryen_type_get_heap_type(typ) {
130
+ return Binaryen._BinaryenTypeGetHeapType(typ);
131
+ }
@@ -6,6 +6,7 @@ external any : unit -> t = "caml_binaryen_heap_type_any"
6
6
  external eq : unit -> t = "caml_binaryen_heap_type_eq"
7
7
  external i31 : unit -> t = "caml_binaryen_heap_type_i31"
8
8
  external data : unit -> t = "caml_binaryen_heap_type_data"
9
+ external array : unit -> t = "caml_binaryen_heap_type_array"
9
10
  external string : unit -> t = "caml_binaryen_heap_type_string"
10
11
  external stringview_wtf8 : unit -> t = "caml_binaryen_heap_type_stringview_wtf8"
11
12
 
@@ -13,3 +14,13 @@ external stringview_wtf16 : unit -> t
13
14
  = "caml_binaryen_heap_type_stringview_wtf16"
14
15
 
15
16
  external stringview_iter : unit -> t = "caml_binaryen_heap_type_stringview_iter"
17
+ external none : unit -> t = "caml_binaryen_heap_type_none"
18
+ external noext : unit -> t = "caml_binaryen_heap_type_noext"
19
+ external nofunc : unit -> t = "caml_binaryen_heap_type_nofunc"
20
+ external is_basic : t -> bool = "caml_binaryen_heap_type_is_basic"
21
+ external is_signature : t -> bool = "caml_binaryen_heap_type_is_signature"
22
+ external is_struct : t -> bool = "caml_binaryen_heap_type_is_struct"
23
+ external is_array : t -> bool = "caml_binaryen_heap_type_is_array"
24
+ external is_bottom : t -> bool = "caml_binaryen_heap_type_is_bottom"
25
+ external get_bottom : t -> t = "caml_binaryen_heap_type_get_bottom"
26
+ external is_sub_type : t -> bool = "caml_binaryen_heap_type_is_sub_type"
@@ -6,7 +6,18 @@ val any : unit -> t
6
6
  val eq : unit -> t
7
7
  val i31 : unit -> t
8
8
  val data : unit -> t
9
+ val array : unit -> t
9
10
  val string : unit -> t
10
11
  val stringview_wtf8 : unit -> t
11
12
  val stringview_wtf16 : unit -> t
12
13
  val stringview_iter : unit -> t
14
+ val none : unit -> t
15
+ val noext : unit -> t
16
+ val nofunc : unit -> t
17
+ val is_basic : t -> bool
18
+ val is_signature : t -> bool
19
+ val is_struct : t -> bool
20
+ val is_array : t -> bool
21
+ val is_bottom : t -> bool
22
+ val get_bottom : t -> t
23
+ val is_sub_type : t -> bool
@@ -6,15 +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 BinaryenLiteral */
11
- static value alloc_BinaryenLiteral(struct BinaryenLiteral op)
12
- {
13
- value v = caml_alloc_custom(&binaryen_ops, sizeof(struct BinaryenLiteral), 0, 1);
14
- BinaryenLiteral_val(v) = op;
15
- return v;
16
- }
17
-
18
9
  CAMLprim value
19
10
  caml_binaryen_literal_int32(value _i32) {
20
11
  CAMLparam1(_i32);
@@ -8,9 +8,10 @@
8
8
 
9
9
 
10
10
  CAMLprim value
11
- caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value _segments, value _segmentPassive, value _segmentOffsets, value _segmentSizes, value _shared, value _memoryName) {
11
+ caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value _segments, value _segmentPassive, value _segmentOffsets, value _segmentSizes, value _shared, value _memory64, value _memoryName) {
12
12
  CAMLparam5(_module, _initial, _maximum, _exportName, _segments);
13
- CAMLxparam5(_segmentPassive, _segmentOffsets, _segmentSizes, _shared, _memoryName);
13
+ CAMLxparam5(_segmentPassive, _segmentOffsets, _segmentSizes, _shared, _memory64);
14
+ CAMLxparam1(_memoryName);
14
15
  BinaryenModuleRef module = BinaryenModuleRef_val(_module);
15
16
  BinaryenIndex initial = Int_val(_initial);
16
17
  BinaryenIndex maximum = Int_val(_maximum);
@@ -39,14 +40,15 @@ caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _e
39
40
  for (int i = 0; i < segmentSizesLen; i++) {
40
41
  segmentSizes[i] = Int_val(Field(_segmentSizes, i));
41
42
  }
42
- uint8_t shared = Bool_val(_shared);
43
+ bool shared = Bool_val(_shared);
44
+ bool memory64 = Bool_val(_memory64);
43
45
  char* memoryName = Safe_String_val(_memoryName);
44
- BinaryenSetMemory(module, initial, maximum, exportName, segments, segmentPassive, segmentOffsets, segmentSizes, segmentsLen, shared, memoryName);
46
+ BinaryenSetMemory(module, initial, maximum, exportName, segments, segmentPassive, segmentOffsets, segmentSizes, segmentsLen, shared, memory64, memoryName);
45
47
  CAMLreturn(Val_unit);
46
48
  }
47
49
  CAMLprim value
48
50
  caml_binaryen_set_memory__bytecode(value * argv) {
49
- return caml_binaryen_set_memory(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
51
+ return caml_binaryen_set_memory(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
50
52
  }
51
53
 
52
54
  CAMLprim value
@@ -93,6 +95,14 @@ caml_binaryen_memory_is_shared(value _module, value _memoryName) {
93
95
  CAMLreturn(Val_bool(BinaryenMemoryIsShared(module, memoryName)));
94
96
  }
95
97
 
98
+ CAMLprim value
99
+ caml_binaryen_memory_is_64(value _module, value _memoryName) {
100
+ CAMLparam2(_module, _memoryName);
101
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
102
+ char* memoryName = Safe_String_val(_memoryName);
103
+ CAMLreturn(Val_bool(BinaryenMemoryIs64(module, memoryName)));
104
+ }
105
+
96
106
  CAMLprim value
97
107
  caml_binaryen_get_num_memory_segments(value _module) {
98
108
  CAMLparam1(_module);
@@ -11,6 +11,7 @@ function caml_binaryen_set_memory(
11
11
  segmentOffsets,
12
12
  segmentSizes,
13
13
  shared,
14
+ memory64,
14
15
  memoryName
15
16
  ) {
16
17
  var passives = caml_list_to_js_array(segmentPassives);
@@ -29,6 +30,7 @@ function caml_binaryen_set_memory(
29
30
  caml_jsstring_of_string(exportName),
30
31
  segs,
31
32
  caml_js_from_bool(shared),
33
+ caml_js_from_bool(memory64),
32
34
  caml_jsstring_of_string(memoryName)
33
35
  );
34
36
  }
@@ -45,7 +47,8 @@ function caml_binaryen_set_memory__bytecode() {
45
47
  arguments[6],
46
48
  arguments[7],
47
49
  arguments[8],
48
- arguments[9]
50
+ arguments[9],
51
+ arguments[10]
49
52
  );
50
53
  }
51
54
 
@@ -92,6 +95,13 @@ function caml_binaryen_memory_is_shared(mod, memoryName) {
92
95
  return caml_js_to_bool(memory_info.shared);
93
96
  }
94
97
 
98
+ //Provides: caml_binaryen_memory_is_64
99
+ //Requires: caml_js_to_bool, caml_jsstring_of_string
100
+ function caml_binaryen_memory_is_64(mod, memoryName) {
101
+ var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
102
+ return caml_js_to_bool(memory_info.is64);
103
+ }
104
+
95
105
  //Provides: caml_binaryen_get_num_memory_segments
96
106
  function caml_binaryen_get_num_memory_segments(wasm_mod) {
97
107
  return wasm_mod.getNumMemorySegments();
@@ -8,15 +8,16 @@ external set_memory :
8
8
  Expression.t list ->
9
9
  int list ->
10
10
  bool ->
11
+ bool ->
11
12
  string ->
12
13
  unit = "caml_binaryen_set_memory__bytecode" "caml_binaryen_set_memory"
13
14
 
14
15
  type segment = { data : bytes; kind : segment_kind; size : int }
15
16
  and segment_kind = Passive | Active of { offset : Expression.t }
16
17
 
17
- (** Module, initial size, maximum size, export name, segments, shared. *)
18
+ (** Module, initial size, maximum size, export name, segments, shared, memory64, moduleName . *)
18
19
  let set_memory wasm_mod initial maximum export_name (segments : segment list)
19
- shared =
20
+ shared memory64 moduleName =
20
21
  let split_segments segments =
21
22
  List.fold_right
22
23
  (fun { data; kind; size }
@@ -38,7 +39,7 @@ let set_memory wasm_mod initial maximum export_name (segments : segment list)
38
39
  split_segments segments
39
40
  in
40
41
  set_memory wasm_mod initial maximum export_name segment_data segment_passive
41
- segment_offsets segment_sizes shared
42
+ segment_offsets segment_sizes shared memory64 moduleName
42
43
 
43
44
  external has_memory : Module.t -> bool = "caml_binaryen_has_memory"
44
45
 
@@ -51,6 +52,8 @@ external get_max : Module.t -> string -> int = "caml_binaryen_memory_get_max"
51
52
  external is_shared : Module.t -> string -> bool
52
53
  = "caml_binaryen_memory_is_shared"
53
54
 
55
+ external is_64 : Module.t -> string -> bool = "caml_binaryen_memory_is_64"
56
+
54
57
  let unlimited = -1
55
58
 
56
59
  external get_num_segments : Module.t -> int
@@ -2,13 +2,22 @@ type segment = { data : bytes; kind : segment_kind; size : int }
2
2
  and segment_kind = Passive | Active of { offset : Expression.t }
3
3
 
4
4
  val set_memory :
5
- Module.t -> int -> int -> string -> segment list -> bool -> string -> unit
5
+ Module.t ->
6
+ int ->
7
+ int ->
8
+ string ->
9
+ segment list ->
10
+ bool ->
11
+ bool ->
12
+ string ->
13
+ unit
6
14
 
7
15
  val has_memory : Module.t -> bool
8
16
  val get_initial : Module.t -> string -> int
9
17
  val has_max : Module.t -> string -> bool
10
18
  val get_max : Module.t -> string -> int
11
19
  val is_shared : Module.t -> string -> bool
20
+ val is_64 : Module.t -> string -> bool
12
21
  val unlimited : int
13
22
  val get_num_segments : Module.t -> int
14
23
  val get_segment_byte_offset : Module.t -> int -> int
@@ -7,15 +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 BinaryenModuleRef */
12
- static value alloc_BinaryenModuleRef(BinaryenModuleRef typ)
13
- {
14
- value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenModuleRef), 0, 1);
15
- BinaryenModuleRef_val(v) = typ;
16
- return v;
17
- }
18
-
19
10
  CAMLprim value
20
11
  caml_binaryen_module_create(value unit) {
21
12
  CAMLparam1(unit);
@@ -60,11 +60,6 @@ module Feature = struct
60
60
 
61
61
  let memory64 = memory64 ()
62
62
 
63
- external typed_function_references : unit -> t
64
- = "caml_binaryen_feature_typed_function_references"
65
-
66
- let typed_function_references = typed_function_references ()
67
-
68
63
  external relaxed_simd : unit -> t = "caml_binaryen_feature_relaxed_simd"
69
64
 
70
65
  let relaxed_simd = relaxed_simd ()
@@ -77,6 +72,10 @@ module Feature = struct
77
72
 
78
73
  let strings = strings ()
79
74
 
75
+ external multi_memories : unit -> t = "caml_binaryen_feature_multi_memories"
76
+
77
+ let multi_memories = multi_memories ()
78
+
80
79
  external all : unit -> t = "caml_binaryen_feature_all"
81
80
 
82
81
  let all = all ()
@@ -16,10 +16,10 @@ module Feature : sig
16
16
  val multivalue : t
17
17
  val gc : t
18
18
  val memory64 : t
19
- val typed_function_references : t
20
19
  val relaxed_simd : t
21
20
  val extended_const : t
22
21
  val strings : t
22
+ val multi_memories : t
23
23
  val all : t
24
24
  end
25
25
 
@@ -101,12 +101,6 @@ caml_binaryen_feature_memory64(value unit) {
101
101
  CAMLreturn(Val_int(BinaryenFeatureMemory64()));
102
102
  }
103
103
 
104
- CAMLprim value
105
- caml_binaryen_feature_typed_function_references(value unit) {
106
- CAMLparam1(unit);
107
- CAMLreturn(Val_int(BinaryenFeatureTypedFunctionReferences()));
108
- }
109
-
110
104
  CAMLprim value
111
105
  caml_binaryen_feature_relaxed_simd(value unit) {
112
106
  CAMLparam1(unit);
@@ -125,6 +119,12 @@ caml_binaryen_feature_strings(value unit) {
125
119
  CAMLreturn(Val_int(BinaryenFeatureStrings()));
126
120
  }
127
121
 
122
+ CAMLprim value
123
+ caml_binaryen_feature_multi_memories(value unit) {
124
+ CAMLparam1(unit);
125
+ CAMLreturn(Val_int(BinaryenFeatureMultiMemories()));
126
+ }
127
+
128
128
  CAMLprim value
129
129
  caml_binaryen_feature_all(value unit) {
130
130
  CAMLparam1(unit);
@@ -86,12 +86,6 @@ function caml_binaryen_feature_memory64() {
86
86
  return Binaryen.Features.Memory64;
87
87
  }
88
88
 
89
- //Provides: caml_binaryen_feature_typed_function_references
90
- //Requires: Binaryen
91
- function caml_binaryen_feature_typed_function_references() {
92
- return Binaryen.Features.TypedFunctionReferences;
93
- }
94
-
95
89
  //Provides: caml_binaryen_feature_relaxed_simd
96
90
  //Requires: Binaryen
97
91
  function caml_binaryen_feature_relaxed_simd() {
@@ -110,6 +104,12 @@ function caml_binaryen_feature_strings() {
110
104
  return Binaryen.Features.Strings;
111
105
  }
112
106
 
107
+ //Provides: caml_binaryen_feature_multi_memories
108
+ //Requires: Binaryen
109
+ function caml_binaryen_feature_multi_memories() {
110
+ return Binaryen.Features.MultiMemories;
111
+ }
112
+
113
113
  //Provides: caml_binaryen_feature_all
114
114
  //Requires: Binaryen
115
115
  function caml_binaryen_feature_all() {
@@ -6,6 +6,93 @@
6
6
 
7
7
  #include "ocaml_helpers.h"
8
8
 
9
+ /* Allocating an OCaml custom block to hold the given BinaryenFunctionRef */
10
+ value alloc_BinaryenFunctionRef(BinaryenFunctionRef fun)
11
+ {
12
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenFunctionRef), 0, 1);
13
+ BinaryenFunctionRef_val(v) = fun;
14
+ return v;
15
+ }
16
+
17
+ /* Allocating an OCaml custom block to hold the given BinaryenExpressionRef */
18
+ value alloc_BinaryenExpressionRef(BinaryenExpressionRef exp)
19
+ {
20
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenExpressionRef), 0, 1);
21
+ BinaryenExpressionRef_val(v) = exp;
22
+ return v;
23
+ }
24
+
25
+ /* Allocating an OCaml custom block to hold the given BinaryenType */
26
+ value alloc_BinaryenType(BinaryenType typ)
27
+ {
28
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenType), 0, 1);
29
+ BinaryenType_val(v) = typ;
30
+ return v;
31
+ }
32
+
33
+ /* Allocating an OCaml custom block to hold the given BinaryenGlobalRef */
34
+ value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp)
35
+ {
36
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenGlobalRef), 0, 1);
37
+ BinaryenGlobalRef_val(v) = exp;
38
+ return v;
39
+ }
40
+
41
+ /* Allocating an OCaml custom block to hold the given BinaryenExportRef */
42
+ value alloc_BinaryenExportRef(BinaryenExportRef exp)
43
+ {
44
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenExportRef), 0, 1);
45
+ BinaryenExportRef_val(v) = exp;
46
+ return v;
47
+ }
48
+
49
+ /* Allocating an OCaml custom block to hold the given BinaryenHeapType */
50
+ value alloc_BinaryenHeapType(BinaryenHeapType typ)
51
+ {
52
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenHeapType), 0, 1);
53
+ BinaryenHeapType_val(v) = typ;
54
+ return v;
55
+ }
56
+
57
+ /* Allocating an OCaml custom block to hold the given BinaryenLiteral */
58
+ value alloc_BinaryenLiteral(struct BinaryenLiteral op)
59
+ {
60
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(struct BinaryenLiteral), 0, 1);
61
+ BinaryenLiteral_val(v) = op;
62
+ return v;
63
+ }
64
+
65
+ /* Allocating an OCaml custom block to hold the given BinaryenModuleRef */
66
+ value alloc_BinaryenModuleRef(BinaryenModuleRef typ)
67
+ {
68
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenModuleRef), 0, 1);
69
+ BinaryenModuleRef_val(v) = typ;
70
+ return v;
71
+ }
72
+
73
+ /* Allocating an OCaml custom block to hold the given BinaryenOp */
74
+ value alloc_BinaryenOp(BinaryenOp op)
75
+ {
76
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenOp), 0, 1);
77
+ BinaryenOp_val(v) = op;
78
+ return v;
79
+ }
80
+
81
+ /* Allocating an OCaml custom block to hold the given BinaryenTableRef */
82
+ value alloc_BinaryenTableRef(BinaryenTableRef table)
83
+ {
84
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenTableRef), 0, 1);
85
+ BinaryenTableRef_val(v) = table;
86
+ return v;
87
+ }
88
+
89
+ /* Allocating an OCaml custom block to hold the given BinaryenElementSegmentRef */
90
+ value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem)
91
+ {
92
+ value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenElementSegmentRef), 0, 1);
93
+ BinaryenElementSegmentRef_val(v) = elem;
94
+ return v;
95
+ }
9
96
 
10
97
  CAMLprim value
11
98
  array_of_list(value list) {
@@ -41,6 +41,39 @@ static struct custom_operations binaryen_ops = {
41
41
 
42
42
  #define Safe_String_val(v) ((char *)memcpy(malloc(caml_string_length(v) + 1), String_val(v), caml_string_length(v) + 1))
43
43
 
44
+ /* Allocating an OCaml custom block to hold the given BinaryenFunctionRef */
45
+ value alloc_BinaryenFunctionRef(BinaryenFunctionRef fun);
46
+
47
+ /* Allocating an OCaml custom block to hold the given BinaryenExpressionRef */
48
+ value alloc_BinaryenExpressionRef(BinaryenExpressionRef exp);
49
+
50
+ /* Allocating an OCaml custom block to hold the given BinaryenType */
51
+ value alloc_BinaryenType(BinaryenType typ);
52
+
53
+ /* Allocating an OCaml custom block to hold the given BinaryenGlobalRef */
54
+ value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp);
55
+
56
+ /* Allocating an OCaml custom block to hold the given BinaryenExportRef */
57
+ value alloc_BinaryenExportRef(BinaryenExportRef exp);
58
+
59
+ /* Allocating an OCaml custom block to hold the given BinaryenHeapType */
60
+ value alloc_BinaryenHeapType(BinaryenHeapType typ);
61
+
62
+ /* Allocating an OCaml custom block to hold the given BinaryenLiteral */
63
+ value alloc_BinaryenLiteral(struct BinaryenLiteral op);
64
+
65
+ /* Allocating an OCaml custom block to hold the given BinaryenModuleRef */
66
+ value alloc_BinaryenModuleRef(BinaryenModuleRef typ);
67
+
68
+ /* Allocating an OCaml custom block to hold the given BinaryenOp */
69
+ value alloc_BinaryenOp(BinaryenOp op);
70
+
71
+ /* Allocating an OCaml custom block to hold the given BinaryenTableRef */
72
+ value alloc_BinaryenTableRef(BinaryenTableRef table);
73
+
74
+ /* Allocating an OCaml custom block to hold the given BinaryenElementSegmentRef */
75
+ value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem);
76
+
44
77
  CAMLprim value
45
78
  array_of_list(value list);
46
79