@grain/binaryen.ml 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,34 @@ function caml_binaryen_set_debug_info(on) {
36
36
  return Binaryen._BinaryenSetDebugInfo(on);
37
37
  }
38
38
 
39
+ //Provides: caml_binaryen_get_traps_never_happen
40
+ //Requires: Binaryen
41
+ function caml_binaryen_get_traps_never_happen() {
42
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
43
+ return Binaryen._BinaryenGetTrapsNeverHappen();
44
+ }
45
+
46
+ //Provides: caml_binaryen_set_traps_never_happen
47
+ //Requires: Binaryen
48
+ function caml_binaryen_set_traps_never_happen(on) {
49
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
50
+ return Binaryen._BinaryenSetTrapsNeverHappen(on);
51
+ }
52
+
53
+ //Provides: caml_binaryen_get_closed_world
54
+ //Requires: Binaryen
55
+ function caml_binaryen_get_closed_world() {
56
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
57
+ return Binaryen._BinaryenGetClosedWorld();
58
+ }
59
+
60
+ //Provides: caml_binaryen_set_closed_world
61
+ //Requires: Binaryen
62
+ function caml_binaryen_set_closed_world(on) {
63
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
64
+ return Binaryen._BinaryenSetClosedWorld(on);
65
+ }
66
+
39
67
  //Provides: caml_binaryen_get_low_memory_unused
40
68
  //Requires: Binaryen
41
69
  function caml_binaryen_get_low_memory_unused() {
@@ -50,6 +78,62 @@ function caml_binaryen_set_low_memory_unused(on) {
50
78
  return Binaryen._BinaryenSetLowMemoryUnused(on);
51
79
  }
52
80
 
81
+ //Provides: caml_binaryen_get_zero_filled_memory
82
+ //Requires: Binaryen
83
+ function caml_binaryen_get_zero_filled_memory() {
84
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
85
+ return Binaryen._BinaryenGetZeroFilledMemory();
86
+ }
87
+
88
+ //Provides: caml_binaryen_set_zero_filled_memory
89
+ //Requires: Binaryen
90
+ function caml_binaryen_set_zero_filled_memory(on) {
91
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
92
+ return Binaryen._BinaryenSetZeroFilledMemory(on);
93
+ }
94
+
95
+ //Provides: caml_binaryen_get_fast_math
96
+ //Requires: Binaryen
97
+ function caml_binaryen_get_fast_math() {
98
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
99
+ return Binaryen._BinaryenGetFastMath();
100
+ }
101
+
102
+ //Provides: caml_binaryen_set_fast_math
103
+ //Requires: Binaryen
104
+ function caml_binaryen_set_fast_math(on) {
105
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
106
+ return Binaryen._BinaryenSetFastMath(on);
107
+ }
108
+
109
+ //Provides: caml_binaryen_get_generate_stack_ir
110
+ //Requires: Binaryen
111
+ function caml_binaryen_get_generate_stack_ir() {
112
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
113
+ return Binaryen._BinaryenGetGenerateStackIR();
114
+ }
115
+
116
+ //Provides: caml_binaryen_set_generate_stack_ir
117
+ //Requires: Binaryen
118
+ function caml_binaryen_set_generate_stack_ir(on) {
119
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
120
+ return Binaryen._BinaryenSetGenerateStackIR(on);
121
+ }
122
+
123
+ //Provides: caml_binaryen_get_optimize_stack_ir
124
+ //Requires: Binaryen
125
+ function caml_binaryen_get_optimize_stack_ir() {
126
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
127
+ return Binaryen._BinaryenGetOptimizeStackIR();
128
+ }
129
+
130
+ //Provides: caml_binaryen_set_optimize_stack_ir
131
+ //Requires: Binaryen
132
+ function caml_binaryen_set_optimize_stack_ir(on) {
133
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
134
+ return Binaryen._BinaryenSetOptimizeStackIR(on);
135
+ }
136
+
53
137
  //Provides: caml_binaryen_get_pass_argument
54
138
  //Requires: Binaryen
55
139
  //Requires: caml_jsstring_of_string
@@ -70,6 +154,39 @@ function caml_binaryen_set_pass_argument(name, value) {
70
154
  );
71
155
  }
72
156
 
157
+ //Provides: caml_binaryen_clear_pass_arguments
158
+ //Requires: Binaryen
159
+ function caml_binaryen_clear_pass_arguments() {
160
+ return Binaryen.clearPassArguments();
161
+ }
162
+
163
+ //Provides: caml_binaryen_has_pass_to_skip
164
+ //Requires: Binaryen
165
+ //Requires: caml_jsstring_of_string
166
+ //Requires: caml_js_to_bool
167
+ function caml_binaryen_has_pass_to_skip(pass) {
168
+ return caml_js_to_bool(
169
+ Binaryen.hasPassToSkip(
170
+ caml_jsstring_of_string(pass)
171
+ )
172
+ );
173
+ }
174
+
175
+ //Provides: caml_binaryen_add_pass_to_skip
176
+ //Requires: Binaryen
177
+ //Requires: caml_jsstring_of_string
178
+ function caml_binaryen_add_pass_to_skip(pass) {
179
+ return Binaryen.addPassToSkip(
180
+ caml_jsstring_of_string(pass)
181
+ );
182
+ }
183
+
184
+ //Provides: caml_binaryen_clear_passes_to_skip
185
+ //Requires: Binaryen
186
+ function caml_binaryen_clear_passes_to_skip(pass) {
187
+ return Binaryen.clearPassesToSkip();
188
+ }
189
+
73
190
  //Provides: caml_binaryen_get_always_inline_max_size
74
191
  //Requires: Binaryen
75
192
  function caml_binaryen_get_always_inline_max_size() {
@@ -106,6 +223,20 @@ function caml_binaryen_set_one_caller_inline_max_size(size) {
106
223
  return Binaryen.setOneCallerInlineMaxSize(size);
107
224
  }
108
225
 
226
+ //Provides: caml_binaryen_get_allow_inlining_functions_with_loops
227
+ //Requires: Binaryen
228
+ function caml_binaryen_get_allow_inlining_functions_with_loops() {
229
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
230
+ return Binaryen._BinaryenGetAllowInliningFunctionsWithLoops();
231
+ }
232
+
233
+ //Provides: caml_binaryen_set_allow_inlining_functions_with_loops
234
+ //Requires: Binaryen
235
+ function caml_binaryen_set_allow_inlining_functions_with_loops(on) {
236
+ // Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO
237
+ return Binaryen._BinaryenSetAllowInliningFunctionsWithLoops(on);
238
+ }
239
+
109
240
  //Provides: caml_binaryen_set_colors_enabled
110
241
  //Requires: Binaryen
111
242
  function caml_binaryen_set_colors_enabled(on) {
@@ -5,18 +5,57 @@ external set_shrink_level : int -> unit = "caml_binaryen_set_shrink_level"
5
5
  external get_debug_info : unit -> bool = "caml_binaryen_get_debug_info"
6
6
  external set_debug_info : bool -> unit = "caml_binaryen_set_debug_info"
7
7
 
8
+ external get_traps_never_happen : unit -> bool
9
+ = "caml_binaryen_get_traps_never_happen"
10
+
11
+ external set_traps_never_happen : bool -> unit
12
+ = "caml_binaryen_set_traps_never_happen"
13
+
14
+ external get_closed_world : unit -> bool = "caml_binaryen_get_closed_world"
15
+ external set_closed_world : bool -> unit = "caml_binaryen_set_closed_world"
16
+
8
17
  external get_low_memory_unused : unit -> bool
9
18
  = "caml_binaryen_get_low_memory_unused"
10
19
 
11
20
  external set_low_memory_unused : bool -> unit
12
21
  = "caml_binaryen_set_low_memory_unused"
13
22
 
23
+ external get_zero_filled_memory : unit -> bool
24
+ = "caml_binaryen_get_zero_filled_memory"
25
+
26
+ external set_zero_filled_memory : bool -> unit
27
+ = "caml_binaryen_set_zero_filled_memory"
28
+
29
+ external get_fast_math : unit -> bool = "caml_binaryen_get_fast_math"
30
+ external set_fast_math : bool -> unit = "caml_binaryen_set_fast_math"
31
+
32
+ external get_generate_stack_ir : unit -> bool
33
+ = "caml_binaryen_get_generate_stack_ir"
34
+
35
+ external set_generate_stack_ir : bool -> unit
36
+ = "caml_binaryen_set_generate_stack_ir"
37
+
38
+ external get_optimize_stack_ir : unit -> bool
39
+ = "caml_binaryen_get_optimize_stack_ir"
40
+
41
+ external set_optimize_stack_ir : bool -> unit
42
+ = "caml_binaryen_set_optimize_stack_ir"
43
+
14
44
  external get_pass_argument : string -> string option
15
45
  = "caml_binaryen_get_pass_argument"
16
46
 
17
47
  external set_pass_argument : string -> string -> unit
18
48
  = "caml_binaryen_set_pass_argument"
19
49
 
50
+ external clear_pass_arguments : unit -> unit
51
+ = "caml_binaryen_clear_pass_arguments"
52
+
53
+ external has_pass_to_skip : string -> bool = "caml_binaryen_has_pass_to_skip"
54
+ external add_pass_to_skip : string -> unit = "caml_binaryen_add_pass_to_skip"
55
+
56
+ external clear_passes_to_skip : unit -> unit
57
+ = "caml_binaryen_clear_passes_to_skip"
58
+
20
59
  external get_always_inline_max_size : unit -> int
21
60
  = "caml_binaryen_get_always_inline_max_size"
22
61
 
@@ -35,5 +74,11 @@ external get_one_caller_inline_max_size : unit -> int
35
74
  external set_one_caller_inline_max_size : int -> unit
36
75
  = "caml_binaryen_set_one_caller_inline_max_size"
37
76
 
77
+ external get_allow_inlining_functions_with_loops : unit -> bool
78
+ = "caml_binaryen_get_allow_inlining_functions_with_loops"
79
+
80
+ external set_allow_inlining_functions_with_loops : bool -> unit
81
+ = "caml_binaryen_set_allow_inlining_functions_with_loops"
82
+
38
83
  external set_colors_enabled : bool -> unit = "caml_binaryen_set_colors_enabled"
39
84
  external are_colors_enabled : unit -> bool = "caml_binaryen_are_colors_enabled"
@@ -4,15 +4,33 @@ val get_shrink_level : unit -> int
4
4
  val set_shrink_level : int -> unit
5
5
  val get_debug_info : unit -> bool
6
6
  val set_debug_info : bool -> unit
7
+ val get_traps_never_happen : unit -> bool
8
+ val set_traps_never_happen : bool -> unit
9
+ val get_closed_world : unit -> bool
10
+ val set_closed_world : bool -> unit
7
11
  val get_low_memory_unused : unit -> bool
8
12
  val set_low_memory_unused : bool -> unit
13
+ val get_zero_filled_memory : unit -> bool
14
+ val set_zero_filled_memory : bool -> unit
15
+ val get_fast_math : unit -> bool
16
+ val set_fast_math : bool -> unit
17
+ val get_generate_stack_ir : unit -> bool
18
+ val set_generate_stack_ir : bool -> unit
19
+ val get_optimize_stack_ir : unit -> bool
20
+ val set_optimize_stack_ir : bool -> unit
9
21
  val get_pass_argument : string -> string option
10
22
  val set_pass_argument : string -> string -> unit
23
+ val clear_pass_arguments : unit -> unit
24
+ val has_pass_to_skip : string -> bool
25
+ val add_pass_to_skip : string -> unit
26
+ val clear_passes_to_skip : unit -> unit
11
27
  val get_always_inline_max_size : unit -> int
12
28
  val set_always_inline_max_size : int -> unit
13
29
  val get_flexible_inline_max_size : unit -> int
14
30
  val set_flexible_inline_max_size : int -> unit
15
31
  val get_one_caller_inline_max_size : unit -> int
16
32
  val set_one_caller_inline_max_size : int -> unit
33
+ val get_allow_inlining_functions_with_loops : unit -> bool
34
+ val set_allow_inlining_functions_with_loops : bool -> unit
17
35
  val set_colors_enabled : bool -> unit
18
36
  val are_colors_enabled : unit -> bool
@@ -12,11 +12,67 @@ let _ = Settings.set_debug_info true
12
12
  let _ = assert (Settings.get_debug_info () == true)
13
13
  let _ = Settings.set_debug_info false
14
14
 
15
+ (* Testing traps_never_happen enable *)
16
+ let _ = assert (Settings.get_traps_never_happen () == false)
17
+ let _ = Settings.set_traps_never_happen true
18
+ let _ = assert (Settings.get_traps_never_happen () == true)
19
+ let _ = Settings.set_traps_never_happen false
20
+
21
+ (* Testing closed_world enable *)
22
+ let _ = assert (Settings.get_closed_world () == false)
23
+ let _ = Settings.set_closed_world true
24
+ let _ = assert (Settings.get_closed_world () == true)
25
+ let _ = Settings.set_closed_world false
26
+
15
27
  (* Testing low_memory_unused enable *)
16
28
  let _ = assert (Settings.get_low_memory_unused () == false)
17
29
  let _ = Settings.set_low_memory_unused true
18
30
  let _ = assert (Settings.get_low_memory_unused () == true)
19
31
  let _ = Settings.set_low_memory_unused false
32
+
33
+ (* Testing zero_filled_memory enable *)
34
+ let _ = assert (Settings.get_zero_filled_memory () == false)
35
+ let _ = Settings.set_zero_filled_memory true
36
+ let _ = assert (Settings.get_zero_filled_memory () == true)
37
+ let _ = Settings.set_zero_filled_memory false
38
+
39
+ (* Testing fast_math enable *)
40
+ let _ = assert (Settings.get_fast_math () == false)
41
+ let _ = Settings.set_fast_math true
42
+ let _ = assert (Settings.get_fast_math () == true)
43
+ let _ = Settings.set_fast_math false
44
+
45
+ (* Testing generate_stack_ir enable *)
46
+ let _ = assert (Settings.get_generate_stack_ir () == false)
47
+ let _ = Settings.set_generate_stack_ir true
48
+ let _ = assert (Settings.get_generate_stack_ir () == true)
49
+ let _ = Settings.set_generate_stack_ir false
50
+
51
+ (* Testing optimize_stack_ir enable *)
52
+ let _ = assert (Settings.get_optimize_stack_ir () == false)
53
+ let _ = Settings.set_optimize_stack_ir true
54
+ let _ = assert (Settings.get_optimize_stack_ir () == true)
55
+ let _ = Settings.set_optimize_stack_ir false
56
+
57
+ (* Testing pass_argument *)
58
+ let _ = assert (Settings.get_pass_argument "theKey" = None)
59
+ let _ = Settings.set_pass_argument "theKey" "theValue"
60
+ let _ = assert (Settings.get_pass_argument "theKey" = Some "theValue")
61
+ let _ = Settings.clear_pass_arguments ()
62
+ let _ = assert (Settings.get_pass_argument "theKey" = None)
63
+
64
+ (* Testing skip_pass *)
65
+ let _ = assert (Settings.has_pass_to_skip "thePass" == false)
66
+ let _ = Settings.add_pass_to_skip "thePass"
67
+ let _ = assert (Settings.has_pass_to_skip "thePass" == true)
68
+ let _ = Settings.clear_passes_to_skip ()
69
+ let _ = assert (Settings.has_pass_to_skip "thePass" == false)
70
+
71
+ (* Testing allow_inlining_functions_with_loops enable *)
72
+ let _ = assert (Settings.get_allow_inlining_functions_with_loops () == false)
73
+ let _ = Settings.set_allow_inlining_functions_with_loops true
74
+ let _ = assert (Settings.get_allow_inlining_functions_with_loops () == true)
75
+ let _ = Settings.set_allow_inlining_functions_with_loops false
20
76
  let wasm_mod = Module.create ()
21
77
  let _ = Module.set_features wasm_mod [ Module.Feature.all ]
22
78
  let import_wasm_mod = Module.create ()
@@ -114,12 +170,14 @@ let start =
114
170
 
115
171
  let _ = Export.add_function_export wasm_mod "adder" "adder"
116
172
  let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
117
- let funcref_expr1 = Expression.Ref.func wasm_mod "adder" Type.funcref
173
+
174
+ (* TODO(#240): Re-enable after type-builder api is merged *)
175
+ (* let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
118
176
 
119
177
  let _ =
120
178
  Expression.Table.set wasm_mod "table"
121
179
  (Expression.Const.make wasm_mod (Literal.int32 0l))
122
- funcref_expr1
180
+ funcref_expr1 *)
123
181
 
124
182
  let funcref_expr2 =
125
183
  Expression.Table.get wasm_mod "table"
@@ -156,6 +214,8 @@ let _ =
156
214
  (Expression.Const.make wasm_mod (Literal.int32 0l))
157
215
 
158
216
  let _ = Function.set_start wasm_mod start
217
+ let start_func = Function.get_start wasm_mod
218
+ let _ = assert (Function.get_name start_func = "start")
159
219
 
160
220
  let segment : Binaryen.Memory.segment =
161
221
  let data = Bytes.of_string "hello" in
@@ -265,11 +325,11 @@ let _ =
265
325
  [
266
326
  Module.Feature.mvp;
267
327
  Module.Feature.atomics;
268
- Module.Feature.bulk_memory;
269
328
  Module.Feature.mutable_globals;
270
329
  Module.Feature.nontrapping_fp_to_int;
271
- Module.Feature.sign_ext;
272
330
  Module.Feature.simd128;
331
+ Module.Feature.bulk_memory;
332
+ Module.Feature.sign_ext;
273
333
  Module.Feature.exception_handling;
274
334
  Module.Feature.tail_call;
275
335
  Module.Feature.reference_types;
@@ -280,6 +340,11 @@ let _ =
280
340
  Module.Feature.extended_const;
281
341
  Module.Feature.strings;
282
342
  Module.Feature.multi_memory;
343
+ Module.Feature.stack_switching;
344
+ Module.Feature.shared_everything;
345
+ Module.Feature.fp16;
346
+ Module.Feature.bulk_memory_opt;
347
+ Module.Feature.call_indirect_overlong;
283
348
  Module.Feature.all;
284
349
  ]
285
350