@grain/binaryen.ml 0.16.0 → 0.18.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 (62) hide show
  1. binaryen-archive/CHANGELOG.md +43 -0
  2. binaryen-archive/binaryen.opam +6 -6
  3. binaryen-archive/esy.lock/index.json +509 -308
  4. binaryen-archive/esy.lock/opam/base-bigarray.base/opam +6 -0
  5. binaryen-archive/esy.lock/opam/{cppo.1.6.8 → cppo.1.6.9}/opam +21 -19
  6. binaryen-archive/esy.lock/opam/{dune-build-info.2.9.3 → dune-build-info.3.3.1}/opam +8 -6
  7. binaryen-archive/esy.lock/opam/{dune-configurator.2.9.3 → dune-configurator.3.3.1}/opam +10 -9
  8. binaryen-archive/esy.lock/opam/dune-rpc.3.3.1/opam +43 -0
  9. binaryen-archive/esy.lock/opam/{dune.2.9.3 → dune.3.3.1}/opam +6 -9
  10. binaryen-archive/esy.lock/opam/dyn.3.3.1/opam +40 -0
  11. binaryen-archive/esy.lock/opam/fiber.3.3.1/opam +41 -0
  12. binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.3.11.0 → js_of_ocaml-compiler.4.0.0}/opam +13 -11
  13. binaryen-archive/esy.lock/opam/{menhir.20211128 → menhir.20220210}/opam +4 -4
  14. binaryen-archive/esy.lock/opam/{menhirLib.20211128 → menhirLib.20220210}/opam +3 -3
  15. binaryen-archive/esy.lock/opam/{menhirSdk.20211128 → menhirSdk.20220210}/opam +3 -3
  16. binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.10.3 → ocaml-lsp-server.1.12.2}/opam +16 -8
  17. binaryen-archive/esy.lock/opam/{ocamlfind.1.9.3 → ocamlfind.1.9.5}/opam +4 -3
  18. binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.19.0 → ocamlformat-rpc-lib.0.22.4}/opam +6 -7
  19. binaryen-archive/esy.lock/opam/octavius.1.2.2/opam +33 -0
  20. binaryen-archive/esy.lock/opam/odoc-parser.1.0.0/opam +1 -1
  21. binaryen-archive/esy.lock/opam/omd.1.3.1/opam +39 -0
  22. binaryen-archive/esy.lock/opam/ordering.3.3.1/opam +38 -0
  23. binaryen-archive/esy.lock/opam/{ppxlib.0.26.0 → ppxlib.0.27.0}/opam +6 -6
  24. binaryen-archive/esy.lock/opam/sexplib0.v0.14.0/opam +1 -1
  25. binaryen-archive/esy.lock/opam/stdune.3.3.1/opam +44 -0
  26. binaryen-archive/esy.lock/opam/xdg.3.3.1/opam +39 -0
  27. binaryen-archive/esy.lock/opam/{yojson.1.7.0 → yojson.2.0.0}/opam +13 -13
  28. binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +3 -0
  29. binaryen-archive/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.9.3_opam_override → opam__s__ocamlfind_opam__c__1.9.5_opam_override}/files/findlib.patch +0 -0
  30. binaryen-archive/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.9.3_opam_override → opam__s__ocamlfind_opam__c__1.9.5_opam_override}/package.json +0 -0
  31. binaryen-archive/package.json +6 -6
  32. binaryen-archive/src/binaryen_stubs_exports.js +36 -20
  33. binaryen-archive/src/binaryen_stubs_expressions.c +101 -0
  34. binaryen-archive/src/binaryen_stubs_expressions.js +543 -508
  35. binaryen-archive/src/binaryen_stubs_features.c +6 -0
  36. binaryen-archive/src/binaryen_stubs_features.js +38 -32
  37. binaryen-archive/src/binaryen_stubs_functions.js +45 -19
  38. binaryen-archive/src/binaryen_stubs_globals.js +8 -8
  39. binaryen-archive/src/binaryen_stubs_imports.js +53 -14
  40. binaryen-archive/src/binaryen_stubs_memory.js +4 -2
  41. binaryen-archive/src/binaryen_stubs_modules.js +9 -8
  42. binaryen-archive/src/binaryen_stubs_ops.c +2 -2
  43. binaryen-archive/src/binaryen_stubs_ops.js +632 -632
  44. binaryen-archive/src/binaryen_stubs_settings.js +36 -38
  45. binaryen-archive/src/binaryen_stubs_tables.js +18 -12
  46. binaryen-archive/src/binaryen_stubs_types.c +23 -2
  47. binaryen-archive/src/binaryen_stubs_types.js +44 -26
  48. binaryen-archive/src/expression.ml +27 -0
  49. binaryen-archive/src/expression.mli +18 -0
  50. binaryen-archive/src/memory.ml +15 -12
  51. binaryen-archive/src/memory.mli +2 -6
  52. binaryen-archive/src/module.ml +4 -0
  53. binaryen-archive/src/module.mli +1 -0
  54. binaryen-archive/src/passes.ml +6 -0
  55. binaryen-archive/src/passes.mli +6 -0
  56. binaryen-archive/src/type.ml +14 -2
  57. binaryen-archive/src/type.mli +4 -1
  58. binaryen-archive/test/test.expected +13 -12
  59. binaryen-archive/test/test.ml +26 -11
  60. binaryen-archive/esy.lock/opam/biniou.1.2.1/opam +0 -45
  61. binaryen-archive/esy.lock/opam/easy-format.1.3.3/opam +0 -58
  62. binaryen-archive/esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json +0 -3
@@ -1,120 +1,118 @@
1
1
  //Provides: caml_binaryen_get_optimize_level
2
- //Requires: binaryen
2
+ //Requires: Binaryen
3
3
  function caml_binaryen_get_optimize_level() {
4
- return binaryen.getOptimizeLevel();
4
+ return Binaryen.getOptimizeLevel();
5
5
  }
6
6
 
7
7
  //Provides: caml_binaryen_set_optimize_level
8
- //Requires: binaryen
8
+ //Requires: Binaryen
9
9
  function caml_binaryen_set_optimize_level(level) {
10
- return binaryen.setOptimizeLevel(level);
10
+ return Binaryen.setOptimizeLevel(level);
11
11
  }
12
12
 
13
13
  //Provides: caml_binaryen_get_shrink_level
14
- //Requires: binaryen
14
+ //Requires: Binaryen
15
15
  function caml_binaryen_get_shrink_level() {
16
- return binaryen.getShrinkLevel();
16
+ return Binaryen.getShrinkLevel();
17
17
  }
18
18
 
19
19
  //Provides: caml_binaryen_set_shrink_level
20
- //Requires: binaryen
20
+ //Requires: Binaryen
21
21
  function caml_binaryen_set_shrink_level(level) {
22
- return binaryen.setShrinkLevel(level);
22
+ return Binaryen.setShrinkLevel(level);
23
23
  }
24
24
 
25
25
  //Provides: caml_binaryen_get_debug_info
26
- //Requires: binaryen
26
+ //Requires: Binaryen
27
27
  function caml_binaryen_get_debug_info() {
28
28
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
29
- return binaryen._BinaryenGetDebugInfo();
29
+ return Binaryen._BinaryenGetDebugInfo();
30
30
  }
31
31
 
32
32
  //Provides: caml_binaryen_set_debug_info
33
- //Requires: binaryen
33
+ //Requires: Binaryen
34
34
  function caml_binaryen_set_debug_info(on) {
35
35
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
36
- return binaryen._BinaryenSetDebugInfo(on);
36
+ return Binaryen._BinaryenSetDebugInfo(on);
37
37
  }
38
38
 
39
39
  //Provides: caml_binaryen_get_low_memory_unused
40
- //Requires: binaryen
40
+ //Requires: Binaryen
41
41
  function caml_binaryen_get_low_memory_unused() {
42
42
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
43
- return binaryen._BinaryenGetLowMemoryUnused();
43
+ return Binaryen._BinaryenGetLowMemoryUnused();
44
44
  }
45
45
 
46
46
  //Provides: caml_binaryen_set_low_memory_unused
47
- //Requires: binaryen
47
+ //Requires: Binaryen
48
48
  function caml_binaryen_set_low_memory_unused(on) {
49
49
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
50
- return binaryen._BinaryenSetLowMemoryUnused(on);
50
+ return Binaryen._BinaryenSetLowMemoryUnused(on);
51
51
  }
52
52
 
53
53
  //Provides: caml_binaryen_get_pass_argument
54
- //Requires: binaryen
54
+ //Requires: Binaryen
55
55
  //Requires: caml_jsstring_of_string
56
56
  function caml_binaryen_get_pass_argument(name) {
57
- return binaryen.getPassArgument(
58
- caml_jsstring_of_string(name)
59
- );
57
+ return Binaryen.getPassArgument(caml_jsstring_of_string(name));
60
58
  }
61
59
 
62
60
  //Provides: caml_binaryen_set_pass_argument
63
- //Requires: binaryen
61
+ //Requires: Binaryen
64
62
  //Requires: caml_jsstring_of_string
65
63
  function caml_binaryen_set_pass_argument(name, value) {
66
- return binaryen.setPassArgument(
64
+ return Binaryen.setPassArgument(
67
65
  caml_jsstring_of_string(name),
68
66
  caml_jsstring_of_string(value)
69
67
  );
70
68
  }
71
69
 
72
70
  //Provides: caml_binaryen_get_always_inline_max_size
73
- //Requires: binaryen
71
+ //Requires: Binaryen
74
72
  function caml_binaryen_get_always_inline_max_size() {
75
- return binaryen.getAlwaysInlineMaxSize();
73
+ return Binaryen.getAlwaysInlineMaxSize();
76
74
  }
77
75
 
78
76
  //Provides: caml_binaryen_set_always_inline_max_size
79
- //Requires: binaryen
77
+ //Requires: Binaryen
80
78
  function caml_binaryen_set_always_inline_max_size(size) {
81
- return binaryen.setAlwaysInlineMaxSize(size);
79
+ return Binaryen.setAlwaysInlineMaxSize(size);
82
80
  }
83
81
 
84
82
  //Provides: caml_binaryen_get_flexible_inline_max_size
85
- //Requires: binaryen
83
+ //Requires: Binaryen
86
84
  function caml_binaryen_get_flexible_inline_max_size() {
87
- return binaryen.getFlexibleInlineMaxSize();
85
+ return Binaryen.getFlexibleInlineMaxSize();
88
86
  }
89
87
 
90
88
  //Provides: caml_binaryen_set_flexible_inline_max_size
91
- //Requires: binaryen
89
+ //Requires: Binaryen
92
90
  function caml_binaryen_set_flexible_inline_max_size(size) {
93
- return binaryen.setFlexibleInlineMaxSize(size);
91
+ return Binaryen.setFlexibleInlineMaxSize(size);
94
92
  }
95
93
 
96
94
  //Provides: caml_binaryen_get_one_caller_inline_max_size
97
- //Requires: binaryen
95
+ //Requires: Binaryen
98
96
  function caml_binaryen_get_one_caller_inline_max_size() {
99
- return binaryen.getOneCallerInlineMaxSize();
97
+ return Binaryen.getOneCallerInlineMaxSize();
100
98
  }
101
99
 
102
100
  //Provides: caml_binaryen_set_one_caller_inline_max_size
103
- //Requires: binaryen
101
+ //Requires: Binaryen
104
102
  function caml_binaryen_set_one_caller_inline_max_size(size) {
105
- return binaryen.setOneCallerInlineMaxSize(size);
103
+ return Binaryen.setOneCallerInlineMaxSize(size);
106
104
  }
107
105
 
108
106
  //Provides: caml_binaryen_set_colors_enabled
109
- //Requires: binaryen
107
+ //Requires: Binaryen
110
108
  function caml_binaryen_set_colors_enabled(on) {
111
109
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
112
- return binaryen._BinaryenSetColorsEnabled(on);
110
+ return Binaryen._BinaryenSetColorsEnabled(on);
113
111
  }
114
112
 
115
113
  //Provides: caml_binaryen_are_colors_enabled
116
- //Requires: binaryen
114
+ //Requires: Binaryen
117
115
  function caml_binaryen_are_colors_enabled() {
118
116
  // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
119
- return binaryen._BinaryenAreColorsEnabled();
117
+ return Binaryen._BinaryenAreColorsEnabled();
120
118
  }
@@ -11,7 +11,13 @@ function caml_binaryen_add_table(wasm_mod, table, initial, maximum, tableType) {
11
11
 
12
12
  //Provides: caml_binaryen_add_active_element_segment
13
13
  //Requires: caml_jsstring_of_string, caml_list_to_js_array
14
- function caml_binaryen_add_active_element_segment(wasm_mod, table, name, funcnames, offset) {
14
+ function caml_binaryen_add_active_element_segment(
15
+ wasm_mod,
16
+ table,
17
+ name,
18
+ funcnames,
19
+ offset
20
+ ) {
15
21
  return wasm_mod.addActiveElementSegment(
16
22
  caml_jsstring_of_string(table),
17
23
  caml_jsstring_of_string(name),
@@ -43,42 +49,42 @@ function caml_binaryen_get_element_segment_by_index(wasm_mod, index) {
43
49
  }
44
50
 
45
51
  //Provides: caml_binaryen_element_segment_get_name
46
- //Requires: binaryen
52
+ //Requires: Binaryen
47
53
  //Requires: caml_string_of_jsstring
48
54
  function caml_binaryen_element_segment_get_name(elem) {
49
- var element_segment_info = binaryen.getElementSegmentInfo(elem);
50
- return caml_string_of_jsstring(element_segment_info.name)
55
+ var element_segment_info = Binaryen.getElementSegmentInfo(elem);
56
+ return caml_string_of_jsstring(element_segment_info.name);
51
57
  }
52
58
 
53
59
  // TODO: Implement caml_binaryen_element_segment_set_name
54
60
 
55
61
  //Provides: caml_binaryen_element_segment_get_table
56
- //Requires: binaryen
62
+ //Requires: Binaryen
57
63
  //Requires: caml_string_of_jsstring
58
64
  function caml_binaryen_element_segment_get_table(elem) {
59
- var element_segment_info = binaryen.getElementSegmentInfo(elem);
65
+ var element_segment_info = Binaryen.getElementSegmentInfo(elem);
60
66
  return caml_string_of_jsstring(element_segment_info.table);
61
67
  }
62
68
 
63
69
  // TODO: Implement caml_binaryen_element_segment_set_table
64
70
 
65
71
  //Provides: caml_binaryen_element_segment_get_offset
66
- //Requires: binaryen
72
+ //Requires: Binaryen
67
73
  function caml_binaryen_element_segment_get_offset(elem) {
68
- var element_segment_info = binaryen.getElementSegmentInfo(elem);
74
+ var element_segment_info = Binaryen.getElementSegmentInfo(elem);
69
75
  return element_segment_info.offset;
70
76
  }
71
77
 
72
78
  //Provides: caml_binaryen_element_segment_get_length
73
- //Requires: binaryen
79
+ //Requires: Binaryen
74
80
  function caml_binaryen_element_segment_get_length(elem) {
75
- return binaryen._BinaryenElementSegmentGetLength(elem);
81
+ return Binaryen._BinaryenElementSegmentGetLength(elem);
76
82
  }
77
83
 
78
84
  //Provides: caml_binaryen_element_segment_get_data
79
- //Requires: binaryen
85
+ //Requires: Binaryen
80
86
  //Requires: caml_string_of_jsstring
81
87
  function caml_binaryen_element_segment_get_data(elem, index) {
82
- var element_segment_info = binaryen.getElementSegmentInfo(elem);
88
+ var element_segment_info = Binaryen.getElementSegmentInfo(elem);
83
89
  return caml_string_of_jsstring(element_segment_info.data[index]);
84
90
  }
@@ -66,9 +66,30 @@ caml_binaryen_type_funcref(value unit) {
66
66
  }
67
67
 
68
68
  CAMLprim value
69
- caml_binaryen_type_externref(value unit) {
69
+ caml_binaryen_type_anyref(value unit) {
70
70
  CAMLparam1(unit);
71
- BinaryenType ty = BinaryenTypeExternref();
71
+ BinaryenType ty = BinaryenTypeAnyref();
72
+ CAMLreturn(alloc_BinaryenType(ty));
73
+ }
74
+
75
+ CAMLprim value
76
+ caml_binaryen_type_eqref(value unit) {
77
+ CAMLparam1(unit);
78
+ BinaryenType ty = BinaryenTypeEqref();
79
+ CAMLreturn(alloc_BinaryenType(ty));
80
+ }
81
+
82
+ CAMLprim value
83
+ caml_binaryen_type_i31ref(value unit) {
84
+ CAMLparam1(unit);
85
+ BinaryenType ty = BinaryenTypeI31ref();
86
+ CAMLreturn(alloc_BinaryenType(ty));
87
+ }
88
+
89
+ CAMLprim value
90
+ caml_binaryen_type_dataref(value unit) {
91
+ CAMLparam1(unit);
92
+ BinaryenType ty = BinaryenTypeDataref();
72
93
  CAMLreturn(alloc_BinaryenType(ty));
73
94
  }
74
95
 
@@ -1,73 +1,91 @@
1
1
  //Provides: caml_binaryen_type_none
2
- //Requires: binaryen
2
+ //Requires: Binaryen
3
3
  function caml_binaryen_type_none() {
4
- return binaryen.none;
4
+ return Binaryen.none;
5
5
  }
6
6
 
7
7
  //Provides: caml_binaryen_type_int32
8
- //Requires: binaryen
8
+ //Requires: Binaryen
9
9
  function caml_binaryen_type_int32() {
10
- return binaryen.i32;
10
+ return Binaryen.i32;
11
11
  }
12
12
 
13
13
  //Provides: caml_binaryen_type_int64
14
- //Requires: binaryen
14
+ //Requires: Binaryen
15
15
  function caml_binaryen_type_int64() {
16
- return binaryen.i64;
16
+ return Binaryen.i64;
17
17
  }
18
18
 
19
19
  //Provides: caml_binaryen_type_float32
20
- //Requires: binaryen
20
+ //Requires: Binaryen
21
21
  function caml_binaryen_type_float32() {
22
- return binaryen.f32;
22
+ return Binaryen.f32;
23
23
  }
24
24
 
25
25
  //Provides: caml_binaryen_type_float64
26
- //Requires: binaryen
26
+ //Requires: Binaryen
27
27
  function caml_binaryen_type_float64() {
28
- return binaryen.f64;
28
+ return Binaryen.f64;
29
29
  }
30
30
 
31
31
  //Provides: caml_binaryen_type_vec128
32
- //Requires: binaryen
32
+ //Requires: Binaryen
33
33
  function caml_binaryen_type_vec128() {
34
- return binaryen.v128;
34
+ return Binaryen.v128;
35
35
  }
36
36
 
37
37
  //Provides: caml_binaryen_type_funcref
38
- //Requires: binaryen
38
+ //Requires: Binaryen
39
39
  function caml_binaryen_type_funcref() {
40
- return binaryen.funcref;
40
+ return Binaryen.funcref;
41
41
  }
42
42
 
43
- //Provides: caml_binaryen_type_externref
44
- //Requires: binaryen
45
- function caml_binaryen_type_externref() {
46
- return binaryen.externref;
43
+ //Provides: caml_binaryen_type_anyref
44
+ //Requires: Binaryen
45
+ function caml_binaryen_type_anyref() {
46
+ return Binaryen.anyref;
47
+ }
48
+
49
+ //Provides: caml_binaryen_type_eqref
50
+ //Requires: Binaryen
51
+ function caml_binaryen_type_eqref() {
52
+ return Binaryen.eqref;
53
+ }
54
+
55
+ //Provides: caml_binaryen_type_i31ref
56
+ //Requires: Binaryen
57
+ function caml_binaryen_type_i31ref() {
58
+ return Binaryen.i31ref;
59
+ }
60
+
61
+ //Provides: caml_binaryen_type_dataref
62
+ //Requires: Binaryen
63
+ function caml_binaryen_type_dataref() {
64
+ return Binaryen.dataref;
47
65
  }
48
66
 
49
67
  //Provides: caml_binaryen_type_unreachable
50
- //Requires: binaryen
68
+ //Requires: Binaryen
51
69
  function caml_binaryen_type_unreachable() {
52
- return binaryen.unreachable;
70
+ return Binaryen.unreachable;
53
71
  }
54
72
 
55
73
  //Provides: caml_binaryen_type_auto
56
- //Requires: binaryen
74
+ //Requires: Binaryen
57
75
  function caml_binaryen_type_auto() {
58
- return binaryen.auto;
76
+ return Binaryen.auto;
59
77
  }
60
78
 
61
79
  //Provides: caml_binaryen_type_create
62
- //Requires: binaryen
80
+ //Requires: Binaryen
63
81
  //Requires: caml_js_from_array
64
82
  function caml_binaryen_type_create(typs) {
65
- return binaryen.createType(caml_js_from_array(typs));
83
+ return Binaryen.createType(caml_js_from_array(typs));
66
84
  }
67
85
 
68
86
  //Provides: caml_binaryen_type_expand
69
- //Requires: binaryen
87
+ //Requires: Binaryen
70
88
  //Requires: caml_js_to_array
71
89
  function caml_binaryen_type_expand(typ) {
72
- return caml_js_to_array(binaryen.expandType(typ));
90
+ return caml_js_to_array(Binaryen.expandType(typ));
73
91
  }
@@ -707,6 +707,33 @@ module Memory_grow = struct
707
707
  external set_delta : t -> t -> unit = "caml_binaryen_memory_grow_set_delta"
708
708
  end
709
709
 
710
+ module Memory_init = struct
711
+ external make : Module.t -> int -> t -> t -> t = "caml_binaryen_memory_init"
712
+ (** Module, segment, destination, offset, size. *)
713
+
714
+ external get_segment : t -> int = "caml_binaryen_memory_init_get_segment"
715
+
716
+ external set_segment : t -> int -> unit
717
+ = "caml_binaryen_memory_init_set_segment"
718
+
719
+ external get_dest : t -> t = "caml_binaryen_memory_init_get_dest"
720
+ external set_dest : t -> t -> unit = "caml_binaryen_memory_init_set_dest"
721
+ external get_offset : t -> t = "caml_binaryen_memory_init_get_offset"
722
+ external set_offset : t -> t -> unit = "caml_binaryen_memory_init_set_offset"
723
+ external get_size : t -> t = "caml_binaryen_memory_init_get_size"
724
+ external set_size : t -> t -> unit = "caml_binaryen_memory_init_set_size"
725
+ end
726
+
727
+ module Data_drop = struct
728
+ external make : Module.t -> int -> t = "caml_binaryen_data_drop"
729
+ (** Module, segment. *)
730
+
731
+ external get_segment : t -> int = "caml_binaryen_data_drop_get_segment"
732
+
733
+ external set_segment : t -> int -> unit
734
+ = "caml_binaryen_data_drop_set_segment"
735
+ end
736
+
710
737
  module Memory_copy = struct
711
738
  external make : Module.t -> t -> t -> t -> t = "caml_binaryen_memory_copy"
712
739
  (** Module, destination, source, size. *)
@@ -255,6 +255,24 @@ module Memory_grow : sig
255
255
  val set_delta : t -> t -> unit
256
256
  end
257
257
 
258
+ module Memory_init : sig
259
+ val make : Module.t -> int -> t -> t -> t
260
+ val get_segment : t -> int
261
+ val set_segment : t -> int -> unit
262
+ val get_dest : t -> t
263
+ val set_dest : t -> t -> unit
264
+ val get_offset : t -> t
265
+ val set_offset : t -> t -> unit
266
+ val get_size : t -> t
267
+ val set_size : t -> t -> unit
268
+ end
269
+
270
+ module Data_drop : sig
271
+ val make : Module.t -> int -> t
272
+ val get_segment : t -> int
273
+ val set_segment : t -> int -> unit
274
+ end
275
+
258
276
  module Memory_copy : sig
259
277
  val make : Module.t -> t -> t -> t -> t
260
278
  val get_dest : t -> t
@@ -3,31 +3,34 @@ external set_memory :
3
3
  int ->
4
4
  int ->
5
5
  string ->
6
- string list ->
6
+ bytes list ->
7
7
  bool list ->
8
8
  Expression.t list ->
9
9
  int list ->
10
10
  bool ->
11
11
  unit = "caml_binaryen_set_memory__bytecode" "caml_binaryen_set_memory"
12
12
 
13
- type segment = {
14
- data : string;
15
- passive : bool;
16
- offset : Expression.t;
17
- size : int;
18
- }
13
+ type segment = { data : bytes; kind : segment_kind; size : int }
14
+ and segment_kind = Passive | Active of { offset : Expression.t }
19
15
 
20
16
  (** Module, initial size, maximum size, export name, segments, shared. *)
21
17
  let set_memory wasm_mod initial maximum export_name (segments : segment list)
22
18
  shared =
23
19
  let split_segments segments =
24
20
  List.fold_right
25
- (fun { data; passive; offset; size }
21
+ (fun { data; kind; size }
26
22
  (segment_data, segment_passive, segment_offsets, segment_sizes) ->
27
- ( data :: segment_data,
28
- passive :: segment_passive,
29
- offset :: segment_offsets,
30
- size :: segment_sizes ))
23
+ match kind with
24
+ | Active { offset } ->
25
+ ( data :: segment_data,
26
+ false :: segment_passive,
27
+ offset :: segment_offsets,
28
+ size :: segment_sizes )
29
+ | Passive ->
30
+ ( data :: segment_data,
31
+ true :: segment_passive,
32
+ Expression.Null.make () :: segment_offsets,
33
+ size :: segment_sizes ))
31
34
  segments ([], [], [], [])
32
35
  in
33
36
  let segment_data, segment_passive, segment_offsets, segment_sizes =
@@ -1,9 +1,5 @@
1
- type segment = {
2
- data : string;
3
- passive : bool;
4
- offset : Expression.t;
5
- size : int;
6
- }
1
+ type segment = { data : bytes; kind : segment_kind; size : int }
2
+ and segment_kind = Passive | Active of { offset : Expression.t }
7
3
 
8
4
  val set_memory :
9
5
  Module.t -> int -> int -> string -> segment list -> bool -> unit
@@ -69,6 +69,10 @@ module Feature = struct
69
69
 
70
70
  let relaxed_simd = relaxed_simd ()
71
71
 
72
+ external extended_const : unit -> t = "caml_binaryen_feature_extended_const"
73
+
74
+ let extended_const = extended_const ()
75
+
72
76
  external all : unit -> t = "caml_binaryen_feature_all"
73
77
 
74
78
  let all = all ()
@@ -18,6 +18,7 @@ module Feature : sig
18
18
  val memory64 : t
19
19
  val typed_function_references : t
20
20
  val relaxed_simd : t
21
+ val extended_const : t
21
22
  val all : t
22
23
  end
23
24
 
@@ -147,6 +147,9 @@ let memory_packing = "memory-packing"
147
147
  (** merges blocks to their parents *)
148
148
  let merge_blocks = "merge-blocks"
149
149
 
150
+ (** merges similar functions when benefical *)
151
+ let merge_similar_functions = "merge-similar-functions"
152
+
150
153
  (** merges locals when beneficial *)
151
154
  let merge_locals = "merge-locals"
152
155
 
@@ -275,6 +278,9 @@ let safe_heap = "safe-heap"
275
278
  (** sets specified globals to specified values *)
276
279
  let set_globals = "set-globals"
277
280
 
281
+ (** remove params from function signature types where possible *)
282
+ let signature_pruning = "signature-pruning"
283
+
278
284
  (** apply more specific subtypes to signature types where possible *)
279
285
  let signature_refining = "signature-refining"
280
286
 
@@ -147,6 +147,9 @@ val memory_packing : t
147
147
  val merge_blocks : t
148
148
  (** merges blocks to their parents *)
149
149
 
150
+ val merge_similar_functions : t
151
+ (** merges similar functions when benefical *)
152
+
150
153
  val merge_locals : t
151
154
  (** merges locals when beneficial *)
152
155
 
@@ -273,6 +276,9 @@ val safe_heap : t
273
276
  val set_globals : t
274
277
  (** sets specified globals to specified values *)
275
278
 
279
+ val signature_pruning : t
280
+ (** remove params from function signature types where possible *)
281
+
276
282
  val signature_refining : t
277
283
  (** apply more specific subtypes to signature types where possible *)
278
284
 
@@ -28,9 +28,21 @@ external funcref : unit -> t = "caml_binaryen_type_funcref"
28
28
 
29
29
  let funcref = funcref ()
30
30
 
31
- external externref : unit -> t = "caml_binaryen_type_externref"
31
+ external anyref : unit -> t = "caml_binaryen_type_anyref"
32
32
 
33
- let externref = externref ()
33
+ let anyref = anyref ()
34
+
35
+ external eqref : unit -> t = "caml_binaryen_type_eqref"
36
+
37
+ let eqref = eqref ()
38
+
39
+ external i31ref : unit -> t = "caml_binaryen_type_i31ref"
40
+
41
+ let i31ref = i31ref ()
42
+
43
+ external dataref : unit -> t = "caml_binaryen_type_dataref"
44
+
45
+ let dataref = dataref ()
34
46
 
35
47
  external unreachable : unit -> t = "caml_binaryen_type_unreachable"
36
48
 
@@ -7,7 +7,10 @@ val float32 : t
7
7
  val float64 : t
8
8
  val vec128 : t
9
9
  val funcref : t
10
- val externref : t
10
+ val anyref : t
11
+ val eqref : t
12
+ val i31ref : t
13
+ val dataref : t
11
14
  val unreachable : t
12
15
  val auto : t
13
16
  val create : t array -> t
@@ -9,14 +9,15 @@
9
9
  (module
10
10
  (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
11
11
  (type $none_=>_none (func))
12
- (type $externref_i32_i32_=>_i32 (func (param externref i32 i32) (result i32)))
13
- (type $externref_=>_i32 (func (param externref) (result i32)))
14
- (import "future-wasi" "write" (func $write (param externref i32 i32) (result i32)))
12
+ (type $anyref_i32_i32_=>_i32 (func (param anyref i32 i32) (result i32)))
13
+ (type $anyref_=>_i32 (func (param anyref) (result i32)))
14
+ (import "future-wasi" "write" (func $write (param anyref i32 i32) (result i32)))
15
15
  (global $max_int64 i64 (i64.const 9223372036854775807))
16
16
  (global $max_int64_mut (mut i64) (i64.const 9223372036854775807))
17
17
  (global $test_float64_bits f64 (f64.const 1.23))
18
18
  (memory $0 1)
19
19
  (data (i32.const 0) "hello")
20
+ (data "world")
20
21
  (table $table 1 1 funcref)
21
22
  (elem $elem (i32.const 0) $adder)
22
23
  (export "adder" (func $adder))
@@ -50,7 +51,7 @@
50
51
  )
51
52
  )
52
53
  )
53
- (func $hello (param $0 externref) (result i32)
54
+ (func $hello (param $0 anyref) (result i32)
54
55
  (call $write
55
56
  (local.get $0)
56
57
  (i32.const 0)
@@ -61,9 +62,9 @@
61
62
  (module
62
63
  (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
63
64
  (type $none_=>_none (func))
64
- (type $externref_i32_i32_=>_i32 (func (param externref i32 i32) (result i32)))
65
- (type $externref_=>_i32 (func (param externref) (result i32)))
66
- (import "future-wasi" "write" (func $write (param externref i32 i32) (result i32)))
65
+ (type $anyref_i32_i32_=>_i32 (func (param anyref i32 i32) (result i32)))
66
+ (type $anyref_=>_i32 (func (param anyref) (result i32)))
67
+ (import "future-wasi" "write" (func $write (param anyref i32 i32) (result i32)))
67
68
  (memory $0 1)
68
69
  (data (i32.const 0) "hello")
69
70
  (table $table 1 1 funcref)
@@ -92,7 +93,7 @@
92
93
  )
93
94
  )
94
95
  )
95
- (func $hello (; has Stack IR ;) (param $0 externref) (result i32)
96
+ (func $hello (; has Stack IR ;) (param $0 anyref) (result i32)
96
97
  (call $write
97
98
  (local.get $0)
98
99
  (i32.const 0)
@@ -101,11 +102,11 @@
101
102
  )
102
103
  )
103
104
  (module
104
- (type $type$0 (func (param externref i32 i32) (result i32)))
105
+ (type $type$0 (func (param anyref i32 i32) (result i32)))
105
106
  (type $type$1 (func (param i32 i32) (result i32)))
106
107
  (type $type$2 (func))
107
- (type $type$3 (func (param externref) (result i32)))
108
- (import "future-wasi" "write" (func $fimport$0 (param externref i32 i32) (result i32)))
108
+ (type $type$3 (func (param anyref) (result i32)))
109
+ (import "future-wasi" "write" (func $fimport$0 (param anyref i32 i32) (result i32)))
109
110
  (memory $0 1)
110
111
  (data (i32.const 0) "hello")
111
112
  (table $0 1 1 funcref)
@@ -134,7 +135,7 @@
134
135
  )
135
136
  )
136
137
  )
137
- (func $2 (param $0 externref) (result i32)
138
+ (func $2 (param $0 anyref) (result i32)
138
139
  (call $fimport$0
139
140
  (local.get $0)
140
141
  (i32.const 0)