@grain/binaryen.ml 0.18.0 → 0.20.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 (85) hide show
  1. binaryen-archive/CHANGELOG.md +54 -0
  2. binaryen-archive/README.md +0 -16
  3. binaryen-archive/binaryen.opam +5 -5
  4. binaryen-archive/dune-project +1 -1
  5. binaryen-archive/dune-workspace +1 -1
  6. binaryen-archive/esy.lock/index.json +422 -372
  7. binaryen-archive/esy.lock/opam/{base.v0.14.3 → base.v0.15.1}/opam +4 -4
  8. binaryen-archive/esy.lock/opam/camlp-streams.5.0.1/opam +59 -0
  9. binaryen-archive/esy.lock/opam/chrome-trace.3.6.1/opam +39 -0
  10. binaryen-archive/esy.lock/opam/{dune-build-info.3.3.1 → dune-build-info.3.6.1}/opam +6 -6
  11. binaryen-archive/esy.lock/opam/{dune-configurator.3.3.1 → dune-configurator.3.6.1}/opam +5 -5
  12. binaryen-archive/esy.lock/opam/{dune-rpc.3.3.1 → dune-rpc.3.6.1}/opam +5 -5
  13. binaryen-archive/esy.lock/opam/{dune.3.3.1 → dune.3.6.1}/opam +6 -6
  14. binaryen-archive/esy.lock/opam/{dyn.3.3.1 → dyn.3.6.1}/opam +5 -5
  15. binaryen-archive/esy.lock/opam/{fiber.3.3.1 → fiber.3.6.1}/opam +5 -5
  16. binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.4.0.0 → js_of_ocaml-compiler.4.1.0}/opam +9 -10
  17. binaryen-archive/esy.lock/opam/menhir.20220210/opam +1 -1
  18. binaryen-archive/esy.lock/opam/menhirLib.20220210/opam +1 -1
  19. binaryen-archive/esy.lock/opam/menhirSdk.20220210/opam +1 -1
  20. binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.12.2 → ocaml-lsp-server.1.12.4}/opam +7 -6
  21. binaryen-archive/esy.lock/opam/{ocaml-version.3.4.0 → ocaml-version.3.5.0}/opam +4 -4
  22. binaryen-archive/esy.lock/opam/{ocamlbuild.0.14.1 → ocamlbuild.0.14.2}/opam +3 -3
  23. binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/files/0001-Fix-bug-when-installing-with-a-system-compiler.patch +26 -0
  24. binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/opam +2 -0
  25. binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.22.4 → ocamlformat-rpc-lib.0.24.1}/opam +4 -4
  26. binaryen-archive/esy.lock/opam/{ocamlformat.0.20.1 → ocamlformat.0.24.1}/opam +12 -12
  27. binaryen-archive/esy.lock/opam/{odoc-parser.1.0.0 → odoc-parser.2.0.0}/opam +6 -5
  28. binaryen-archive/esy.lock/opam/omd.1.3.2/opam +50 -0
  29. binaryen-archive/esy.lock/opam/{ordering.3.3.1 → ordering.3.6.1}/opam +5 -5
  30. binaryen-archive/esy.lock/opam/{ppxlib.0.27.0 → ppxlib.0.28.0}/opam +5 -5
  31. binaryen-archive/esy.lock/opam/{sexplib0.v0.14.0 → sexplib0.v0.15.1}/opam +3 -3
  32. binaryen-archive/esy.lock/opam/{stdio.v0.14.0 → stdio.v0.15.0}/opam +4 -4
  33. binaryen-archive/esy.lock/opam/{stdune.3.3.1 → stdune.3.6.1}/opam +5 -5
  34. binaryen-archive/esy.lock/opam/{topkg.1.0.5 → topkg.1.0.6}/opam +22 -19
  35. binaryen-archive/esy.lock/opam/uucp.15.0.0/opam +55 -0
  36. binaryen-archive/esy.lock/opam/{uuseg.14.0.0 → uuseg.15.0.0}/opam +39 -25
  37. binaryen-archive/esy.lock/opam/{xdg.3.3.1 → xdg.3.6.1}/opam +5 -5
  38. binaryen-archive/esy.lock/opam/{yojson.2.0.0 → yojson.2.0.2}/opam +5 -5
  39. binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.1_opam_override → opam__s__ocamlbuild_opam__c__0.14.2_opam_override}/files/winpatch.patch +0 -0
  40. binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.1_opam_override → opam__s__ocamlbuild_opam__c__0.14.2_opam_override}/package.json +0 -0
  41. binaryen-archive/package.json +8 -8
  42. binaryen-archive/src/binaryen_stubs_expressions.c +43 -33
  43. binaryen-archive/src/binaryen_stubs_expressions.js +221 -42
  44. binaryen-archive/src/binaryen_stubs_features.c +6 -0
  45. binaryen-archive/src/binaryen_stubs_features.js +6 -0
  46. binaryen-archive/src/binaryen_stubs_heap_types.c +95 -0
  47. binaryen-archive/src/binaryen_stubs_heap_types.js +65 -0
  48. binaryen-archive/src/binaryen_stubs_imports.c +16 -0
  49. binaryen-archive/src/binaryen_stubs_imports.js +14 -0
  50. binaryen-archive/src/binaryen_stubs_memory.c +83 -4
  51. binaryen-archive/src/binaryen_stubs_memory.js +95 -5
  52. binaryen-archive/src/binaryen_stubs_modules.c +22 -0
  53. binaryen-archive/src/binaryen_stubs_modules.js +17 -0
  54. binaryen-archive/src/binaryen_stubs_packed_types.c +26 -0
  55. binaryen-archive/src/binaryen_stubs_packed_types.js +17 -0
  56. binaryen-archive/src/binaryen_stubs_type_system.c +40 -0
  57. binaryen-archive/src/binaryen_stubs_type_system.js +29 -0
  58. binaryen-archive/src/binaryen_stubs_types.c +44 -0
  59. binaryen-archive/src/binaryen_stubs_types.js +36 -0
  60. binaryen-archive/src/dune +35 -12
  61. binaryen-archive/src/expression.ml +21 -24
  62. binaryen-archive/src/expression.mli +9 -9
  63. binaryen-archive/src/heap_type.ml +15 -0
  64. binaryen-archive/src/heap_type.mli +12 -0
  65. binaryen-archive/src/import.ml +6 -0
  66. binaryen-archive/src/import.mli +2 -0
  67. binaryen-archive/src/memory.ml +24 -0
  68. binaryen-archive/src/memory.mli +10 -1
  69. binaryen-archive/src/module.ml +12 -0
  70. binaryen-archive/src/module.mli +3 -0
  71. binaryen-archive/src/ocaml_helpers.h +1 -0
  72. binaryen-archive/src/packed_type.ml +13 -0
  73. binaryen-archive/src/packed_type.mli +5 -0
  74. binaryen-archive/src/passes.ml +6 -0
  75. binaryen-archive/src/passes.mli +6 -0
  76. binaryen-archive/src/type.ml +19 -0
  77. binaryen-archive/src/type.mli +7 -0
  78. binaryen-archive/src/type_system.ml +7 -0
  79. binaryen-archive/src/type_system.mli +7 -0
  80. binaryen-archive/test/dune +19 -20
  81. binaryen-archive/test/test.expected +64 -4
  82. binaryen-archive/test/test.ml +49 -5
  83. binaryen-archive/esy.lock/opam/omd.1.3.1/opam +0 -39
  84. binaryen-archive/esy.lock/opam/uucp.14.0.0/opam +0 -41
  85. binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
@@ -8,6 +8,8 @@ val add_global_import :
8
8
  Module.t -> string -> string -> string -> Type.t -> bool -> unit
9
9
 
10
10
  val function_import_get_module : Function.t -> string
11
+ val memory_import_get_module : Module.t -> string -> string
11
12
  val global_import_get_module : Global.t -> string
12
13
  val function_import_get_base : Function.t -> string
14
+ val memory_import_get_base : Module.t -> string -> string
13
15
  val global_import_get_base : Global.t -> string
@@ -8,6 +8,7 @@ external set_memory :
8
8
  Expression.t list ->
9
9
  int list ->
10
10
  bool ->
11
+ string ->
11
12
  unit = "caml_binaryen_set_memory__bytecode" "caml_binaryen_set_memory"
12
13
 
13
14
  type segment = { data : bytes; kind : segment_kind; size : int }
@@ -39,4 +40,27 @@ let set_memory wasm_mod initial maximum export_name (segments : segment list)
39
40
  set_memory wasm_mod initial maximum export_name segment_data segment_passive
40
41
  segment_offsets segment_sizes shared
41
42
 
43
+ external has_memory : Module.t -> bool = "caml_binaryen_has_memory"
44
+
45
+ external get_initial : Module.t -> string -> int
46
+ = "caml_binaryen_memory_get_initial"
47
+
48
+ external has_max : Module.t -> string -> bool = "caml_binaryen_memory_has_max"
49
+ external get_max : Module.t -> string -> int = "caml_binaryen_memory_get_max"
50
+
51
+ external is_shared : Module.t -> string -> bool
52
+ = "caml_binaryen_memory_is_shared"
53
+
42
54
  let unlimited = -1
55
+
56
+ external get_num_segments : Module.t -> int
57
+ = "caml_binaryen_get_num_memory_segments"
58
+
59
+ external get_segment_byte_offset : Module.t -> int -> int
60
+ = "caml_binaryen_get_memory_segment_byte_offset"
61
+
62
+ external get_segment_passive : Module.t -> int -> bool
63
+ = "caml_binaryen_get_memory_segment_passive"
64
+
65
+ external get_segment_data : Module.t -> int -> bytes
66
+ = "caml_binaryen_get_memory_segment_data"
@@ -2,6 +2,15 @@ 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 -> unit
5
+ Module.t -> int -> int -> string -> segment list -> bool -> string -> unit
6
6
 
7
+ val has_memory : Module.t -> bool
8
+ val get_initial : Module.t -> string -> int
9
+ val has_max : Module.t -> string -> bool
10
+ val get_max : Module.t -> string -> int
11
+ val is_shared : Module.t -> string -> bool
7
12
  val unlimited : int
13
+ val get_num_segments : Module.t -> int
14
+ val get_segment_byte_offset : Module.t -> int -> int
15
+ val get_segment_passive : Module.t -> int -> bool
16
+ val get_segment_data : Module.t -> int -> bytes
@@ -73,6 +73,10 @@ module Feature = struct
73
73
 
74
74
  let extended_const = extended_const ()
75
75
 
76
+ external strings : unit -> t = "caml_binaryen_feature_strings"
77
+
78
+ let strings = strings ()
79
+
76
80
  external all : unit -> t = "caml_binaryen_feature_all"
77
81
 
78
82
  let all = all ()
@@ -87,6 +91,10 @@ external add_custom_section : t -> string -> string -> unit
87
91
  external parse : string -> t = "caml_binaryen_module_parse"
88
92
  external print : t -> unit = "caml_binaryen_module_print"
89
93
  external print_asmjs : t -> unit = "caml_binaryen_module_print_asmjs"
94
+
95
+ external print_stack_ir : t -> bool -> unit
96
+ = "caml_binaryen_module_print_stack_ir"
97
+
90
98
  external validate : t -> int = "caml_binaryen_module_validate"
91
99
  external optimize : t -> unit = "caml_binaryen_module_optimize"
92
100
  external get_features : t -> int = "caml_binaryen_module_get_features"
@@ -117,6 +125,10 @@ external write : t -> string option -> bytes * string option
117
125
  = "caml_binaryen_module_write"
118
126
 
119
127
  external write_text : t -> string = "caml_binaryen_module_write_text"
128
+
129
+ external write_stack_ir : t -> bool -> string
130
+ = "caml_binaryen_module_write_stack_ir"
131
+
120
132
  external read : bytes -> t = "caml_binaryen_module_read"
121
133
  external interpret : t -> unit = "caml_binaryen_module_interpret"
122
134
 
@@ -19,6 +19,7 @@ module Feature : sig
19
19
  val typed_function_references : t
20
20
  val relaxed_simd : t
21
21
  val extended_const : t
22
+ val strings : t
22
23
  val all : t
23
24
  end
24
25
 
@@ -28,6 +29,7 @@ val add_custom_section : t -> string -> string -> unit
28
29
  val parse : string -> t
29
30
  val print : t -> unit
30
31
  val print_asmjs : t -> unit
32
+ val print_stack_ir : t -> bool -> unit
31
33
  val validate : t -> int
32
34
  val optimize : t -> unit
33
35
  val get_features : t -> Feature.t list
@@ -36,6 +38,7 @@ val run_passes : t -> Passes.t list -> unit
36
38
  val auto_drop : t -> unit
37
39
  val write : t -> string option -> bytes * string option
38
40
  val write_text : t -> string
41
+ val write_stack_ir : t -> bool -> string
39
42
  val read : bytes -> t
40
43
  val interpret : t -> unit
41
44
  val add_debug_info_filename : t -> string -> int
@@ -23,6 +23,7 @@ static struct custom_operations binaryen_ops = {
23
23
 
24
24
  #define BinaryenModuleRef_val(v) (*((BinaryenModuleRef*) Data_custom_val(v)))
25
25
  #define BinaryenType_val(v) (*((BinaryenType*) Data_custom_val(v)))
26
+ #define BinaryenHeapType_val(v) (*((BinaryenHeapType*) Data_custom_val(v)))
26
27
  #define BinaryenExpressionRef_val(v) (*((BinaryenExpressionRef*) Data_custom_val(v)))
27
28
  #define BinaryenOp_val(v) (*((BinaryenOp*) Data_custom_val(v)))
28
29
  #define BinaryenLiteral_val(v) (*((struct BinaryenLiteral*) Data_custom_val(v)))
@@ -0,0 +1,13 @@
1
+ type t = int
2
+
3
+ external not_packed : unit -> t = "caml_binaryen_packed_type_not_packed"
4
+
5
+ let not_packed = not_packed ()
6
+
7
+ external int8 : unit -> t = "caml_binaryen_packed_type_int8"
8
+
9
+ let int8 = int8 ()
10
+
11
+ external int16 : unit -> t = "caml_binaryen_packed_type_int16"
12
+
13
+ let int16 = int16 ()
@@ -0,0 +1,5 @@
1
+ type t
2
+
3
+ val not_packed : t
4
+ val int8 : t
5
+ val int16 : t
@@ -90,6 +90,9 @@ let global_refining = "global-refining"
90
90
  (** globally optimize GC types *)
91
91
  let gto = "gto"
92
92
 
93
+ (** globally optimize struct values *)
94
+ let gsi = "gsi"
95
+
93
96
  (** apply more specific subtypes to type fields where possible *)
94
97
  let type_refining = "type-refining"
95
98
 
@@ -311,6 +314,9 @@ let souperify = "souperify"
311
314
  (** emit Souper IR in text form (single-use nodes only) *)
312
315
  let souperify_single_use = "souperify-single-use"
313
316
 
317
+ (** spill pointers to the C stack (useful for Boehm-style GC) *)
318
+ let spill_pointers = "spill-pointers"
319
+
314
320
  (** stub out unsupported JS operations *)
315
321
  let stub_unsupported_js = "stub-unsupported-js"
316
322
 
@@ -90,6 +90,9 @@ val global_refining : t
90
90
  val gto : t
91
91
  (** globally optimize GC types *)
92
92
 
93
+ val gsi : t
94
+ (** globally optimize struct values *)
95
+
93
96
  val type_refining : t
94
97
  (** apply more specific subtypes to type fields where possible *)
95
98
 
@@ -309,6 +312,9 @@ val souperify : t
309
312
  val souperify_single_use : t
310
313
  (** emit Souper IR in text form (single-use nodes only) *)
311
314
 
315
+ val spill_pointers : t
316
+ (** spill pointers to the C stack (useful for Boehm-style GC) *)
317
+
312
318
  val stub_unsupported_js : t
313
319
  (** stub out unsupported JS operations *)
314
320
 
@@ -44,6 +44,22 @@ external dataref : unit -> t = "caml_binaryen_type_dataref"
44
44
 
45
45
  let dataref = dataref ()
46
46
 
47
+ external stringref : unit -> t = "caml_binaryen_type_stringref"
48
+
49
+ let stringref = stringref ()
50
+
51
+ external stringview_wtf8 : unit -> t = "caml_binaryen_type_stringview_wtf8"
52
+
53
+ let stringview_wtf8 = stringview_wtf8 ()
54
+
55
+ external stringview_wtf16 : unit -> t = "caml_binaryen_type_stringview_wtf16"
56
+
57
+ let stringview_wtf16 = stringview_wtf16 ()
58
+
59
+ external stringview_iter : unit -> t = "caml_binaryen_type_stringview_iter"
60
+
61
+ let stringview_iter = stringview_iter ()
62
+
47
63
  external unreachable : unit -> t = "caml_binaryen_type_unreachable"
48
64
 
49
65
  let unreachable = unreachable ()
@@ -54,3 +70,6 @@ let auto = auto ()
54
70
 
55
71
  external create : t array -> t = "caml_binaryen_type_create"
56
72
  external expand : t -> t array = "caml_binaryen_type_expand"
73
+ external is_nullable : t -> bool = "caml_binaryen_type_is_nullable"
74
+ external from_heap_type : Heap_type.t -> t = "caml_binaryen_type_from_heap_type"
75
+ external get_heap_type : t -> Heap_type.t = "caml_binaryen_type_get_heap_type"
@@ -11,7 +11,14 @@ val anyref : t
11
11
  val eqref : t
12
12
  val i31ref : t
13
13
  val dataref : t
14
+ val stringref : t
15
+ val stringview_wtf8 : t
16
+ val stringview_wtf16 : t
17
+ val stringview_iter : t
14
18
  val unreachable : t
15
19
  val auto : t
16
20
  val create : t array -> t
17
21
  val expand : t -> t array
22
+ val is_nullable : t -> bool
23
+ val from_heap_type : Heap_type.t -> t
24
+ val get_heap_type : t -> Heap_type.t
@@ -0,0 +1,7 @@
1
+ type t = int
2
+
3
+ external equirecursive : unit -> t = "caml_binaryen_type_system_equirecursive"
4
+ external nominal : unit -> t = "caml_binaryen_type_system_nominal"
5
+ external isorecursive : unit -> t = "caml_binaryen_type_system_isorecursive"
6
+ external get_type_system : unit -> t = "caml_binaryen_get_type_system"
7
+ external set_type_system : t -> unit = "caml_binaryen_set_type_system"
@@ -0,0 +1,7 @@
1
+ type t
2
+
3
+ val equirecursive : unit -> t
4
+ val nominal : unit -> t
5
+ val isorecursive : unit -> t
6
+ val get_type_system : unit -> t
7
+ val set_type_system : t -> unit
@@ -1,30 +1,29 @@
1
- (test
1
+ (executable
2
2
  (name test)
3
- (modules test)
4
3
  (libraries binaryen)
5
- (ocamlopt_flags
4
+ (modes exe js)
5
+ (flags
6
+ :standard
6
7
  (:include ./config/ocamlopt_flags.sexp))
7
- (action
8
- (run %{test})))
9
-
10
- ; Tests for binaryen.js implementation
8
+ (js_of_ocaml
9
+ (flags --no-sourcemap)))
11
10
 
12
11
  (rule
13
- (target test_js.ml)
12
+ (alias runtest)
14
13
  (action
15
14
  (progn
16
- (copy %{dep:test.ml} %{target})
17
- (copy test.expected test_js.expected))))
15
+ (with-stdout-to
16
+ test.out
17
+ (run %{exe:test.exe}))
18
+ (diff test.out test.expected))))
18
19
 
19
- (test
20
- (name test_js)
20
+ (rule
21
+ (alias runtest)
21
22
  (enabled_if
22
- (<> %{system} mingw64))
23
- (modules test_js)
24
- (modes
25
- (byte js))
26
- (libraries binaryen)
23
+ (= %{bin-available:node} true))
27
24
  (action
28
- (run node %{dep:test_js.bc.js}))
29
- (js_of_ocaml
30
- (flags --no-sourcemap --disable share)))
25
+ (progn
26
+ (with-stdout-to
27
+ test_js.out
28
+ (run node %{dep:test.bc.js}))
29
+ (diff test_js.out test.expected))))
@@ -43,11 +43,18 @@
43
43
  )
44
44
  )
45
45
  (func $start
46
- (drop
47
- (call_indirect $table (type $i32_i32_=>_i32)
48
- (i32.const 3)
49
- (i32.const 5)
46
+ (block $start
47
+ (memory.init 1
48
+ (i32.const 2048)
50
49
  (i32.const 0)
50
+ (i32.const 5)
51
+ )
52
+ (drop
53
+ (call_indirect $table (type $i32_i32_=>_i32)
54
+ (i32.const 3)
55
+ (i32.const 5)
56
+ (i32.const 0)
57
+ )
51
58
  )
52
59
  )
53
60
  )
@@ -67,6 +74,7 @@
67
74
  (import "future-wasi" "write" (func $write (param anyref i32 i32) (result i32)))
68
75
  (memory $0 1)
69
76
  (data (i32.const 0) "hello")
77
+ (data "world")
70
78
  (table $table 1 1 funcref)
71
79
  (elem $elem (i32.const 0) $adder)
72
80
  (export "adder" (func $adder))
@@ -86,6 +94,11 @@
86
94
  )
87
95
  )
88
96
  (func $start (; has Stack IR ;)
97
+ (memory.init 1
98
+ (i32.const 2048)
99
+ (i32.const 0)
100
+ (i32.const 5)
101
+ )
89
102
  (drop
90
103
  (call $adder
91
104
  (i32.const 3)
@@ -109,6 +122,7 @@
109
122
  (import "future-wasi" "write" (func $fimport$0 (param anyref i32 i32) (result i32)))
110
123
  (memory $0 1)
111
124
  (data (i32.const 0) "hello")
125
+ (data "world")
112
126
  (table $0 1 1 funcref)
113
127
  (elem (i32.const 0) $0)
114
128
  (export "adder" (func $0))
@@ -128,6 +142,11 @@
128
142
  )
129
143
  )
130
144
  (func $1
145
+ (memory.init 1
146
+ (i32.const 2048)
147
+ (i32.const 0)
148
+ (i32.const 5)
149
+ )
131
150
  (drop
132
151
  (call $0
133
152
  (i32.const 3)
@@ -143,3 +162,44 @@
143
162
  )
144
163
  )
145
164
  )
165
+ (module
166
+ (type $type$0 (func (param anyref i32 i32) (result i32)))
167
+ (type $type$1 (func (param i32 i32) (result i32)))
168
+ (type $type$2 (func))
169
+ (type $type$3 (func (param anyref) (result i32)))
170
+ (import "future-wasi" "write" (func $fimport$0 (param anyref i32 i32) (result i32)))
171
+ (memory $0 1)
172
+ (data (i32.const 0) "hello")
173
+ (data "world")
174
+ (table $0 1 1 funcref)
175
+ (elem (i32.const 0) $0)
176
+ (export "adder" (func $0))
177
+ (export "memory" (memory $0))
178
+ (export "hello" (func $2))
179
+ (start $1)
180
+ (func $0 (param $0 i32) (param $1 i32) (result i32)
181
+ local.get $0
182
+ local.get $1
183
+ i32.load8_s $0
184
+ i32.const 1
185
+ select
186
+ local.get $1
187
+ i32.add
188
+ )
189
+ (func $1
190
+ i32.const 2048
191
+ i32.const 0
192
+ i32.const 5
193
+ memory.init $0 1
194
+ i32.const 3
195
+ i32.const 5
196
+ call $0
197
+ drop
198
+ )
199
+ (func $2 (param $0 anyref) (result i32)
200
+ local.get $0
201
+ i32.const 0
202
+ i32.const 1
203
+ call $fimport$0
204
+ )
205
+ )
@@ -19,6 +19,23 @@ let _ = assert (Settings.get_low_memory_unused () == true)
19
19
  let _ = Settings.set_low_memory_unused false
20
20
  let wasm_mod = Module.create ()
21
21
  let _ = Module.set_features wasm_mod [ Module.Feature.all ]
22
+ let import_wasm_mod = Module.create ()
23
+
24
+ let _ =
25
+ Import.add_memory_import import_wasm_mod "internal_name" "external_name"
26
+ "external_base_name" true
27
+
28
+ let _ =
29
+ assert (
30
+ Import.memory_import_get_module import_wasm_mod "internal_name"
31
+ = "external_name")
32
+
33
+ let _ =
34
+ assert (
35
+ Import.memory_import_get_base import_wasm_mod "internal_name"
36
+ = "external_base_name")
37
+
38
+ let _ = assert (Memory.is_shared import_wasm_mod "internal_name" = true)
22
39
 
23
40
  (* Testing Return.get_value *)
24
41
  let _ =
@@ -39,7 +56,9 @@ let params () = Type.create [| Type.int32; Type.int32 |]
39
56
  let results = Type.int32
40
57
  let x () = Expression.Local_get.make wasm_mod 0 Type.int32
41
58
  let y () = Expression.Local_get.make wasm_mod 1 Type.int32
42
- let load = Expression.Load.make wasm_mod 1 ~signed:true 0 0 Type.int32 (y ())
59
+
60
+ let load =
61
+ Expression.Load.make wasm_mod 1 ~signed:true 0 0 Type.int32 (y ()) "0"
43
62
 
44
63
  let select =
45
64
  Expression.Select.make wasm_mod
@@ -75,7 +94,15 @@ let call_adder =
75
94
 
76
95
  let start =
77
96
  Function.add_function wasm_mod "start" Type.none Type.none [||]
78
- (Expression.Drop.make wasm_mod call_adder)
97
+ (Expression.Block.make wasm_mod ~return_type:Type.none "start"
98
+ [
99
+ Expression.Memory_init.make wasm_mod 1
100
+ (Expression.Const.make wasm_mod (Literal.int32 2048l))
101
+ (Expression.Const.make wasm_mod (Literal.int32 0l))
102
+ (Expression.Const.make wasm_mod (Literal.int32 5l))
103
+ "0";
104
+ Expression.Drop.make wasm_mod call_adder;
105
+ ])
79
106
 
80
107
  let _ = Export.add_function_export wasm_mod "adder" "adder"
81
108
  let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
@@ -137,12 +164,27 @@ let passive_segment : Binaryen.Memory.segment =
137
164
  let size = Bytes.length data in
138
165
  { data; kind; size }
139
166
 
167
+ let _ = assert (Memory.has_memory wasm_mod = false)
168
+
140
169
  let _ =
141
170
  Memory.set_memory wasm_mod 1 Memory.unlimited "memory"
142
171
  [ segment; passive_segment ]
143
- false
172
+ false "0"
173
+
174
+ let _ = assert (Memory.has_memory wasm_mod = true)
175
+ let _ = assert (Memory.get_initial wasm_mod "0" = 1)
176
+ let _ = assert (Memory.has_max wasm_mod "0" = false)
177
+ let _ = assert (Memory.get_max wasm_mod "0" = Memory.unlimited)
178
+ let max_memory_wasm_mod = Module.create ()
179
+ let _ = Memory.set_memory max_memory_wasm_mod 1 2 "memory" [] false "0"
180
+ let _ = assert (Memory.has_max max_memory_wasm_mod "0" = true)
181
+ let _ = assert (Memory.get_max max_memory_wasm_mod "0" = 2)
182
+
183
+ let _ =
184
+ assert (
185
+ Bytes.equal (Memory.get_segment_data wasm_mod 1) (Bytes.of_string "world"))
144
186
 
145
- (* Create an imported "write" function i32 (anyref, i32, i32) *)
187
+ (* Create an imported "write" function i32 (externref, i32, i32) *)
146
188
  (* Similar to the example here: https://bytecodealliance.org/articles/reference-types-in-wasmtime *)
147
189
 
148
190
  let _ =
@@ -191,7 +233,7 @@ let new_mod = Module.read byts
191
233
 
192
234
  let _ =
193
235
  Module.run_passes new_mod
194
- [ Passes.name_types; Passes.merge_similar_functions ]
236
+ [ Passes.name_types; Passes.merge_similar_functions; Passes.spill_pointers ]
195
237
 
196
238
  let _ =
197
239
  Module.set_features new_mod
@@ -212,11 +254,13 @@ let _ =
212
254
  Module.Feature.typed_function_references;
213
255
  Module.Feature.relaxed_simd;
214
256
  Module.Feature.extended_const;
257
+ Module.Feature.strings;
215
258
  Module.Feature.all;
216
259
  ]
217
260
 
218
261
  let _ = Module.validate new_mod
219
262
  let _ = Module.print new_mod
263
+ let _ = Module.print_stack_ir new_mod false
220
264
 
221
265
  (* Dispose the modules 👋 *)
222
266
 
@@ -1,39 +0,0 @@
1
- opam-version: "2.0"
2
- maintainer: "Philippe Wang <philippe.wang@gmail.com>"
3
- authors: [ "Philippe Wang <philippe.wang@gmail.com>" ]
4
- license: "ISC"
5
- homepage: "https://github.com/ocaml/omd"
6
- dev-repo: "git+https://github.com/ocaml/omd.git"
7
- bug-reports: "https://github.com/ocaml/omd/issues"
8
- tags: [ "org:ocamllabs" "org:mirage" ]
9
- build: [
10
- ["ocaml" "setup.ml" "-configure" "--prefix" prefix]
11
- ["ocaml" "setup.ml" "-build"]
12
- ["ocaml" "setup.ml" "-configure" "--enable-tests"] {with-test}
13
- ["ocaml" "setup.ml" "-build"] {with-test}
14
- ["ocaml" "setup.ml" "-test"] {with-test}
15
- ]
16
- install: ["ocaml" "setup.ml" "-install"]
17
- remove: [
18
- ["ocaml" "%{etc}%/omd/setup.ml" "-C" "%{etc}%/omd" "-uninstall"]
19
- ]
20
- depends: [
21
- "ocaml" {>= "4.01"}
22
- "base-bigarray"
23
- "base-bytes"
24
- "ocamlbuild" {build}
25
- "ocamlfind" {build & >= "1.5"}
26
- ]
27
- synopsis: "A Markdown frontend in pure OCaml."
28
- description: """
29
- This Markdown library is implemented using only pure OCaml (including
30
- I/O operations provided by the standard OCaml compiler distribution).
31
- OMD is meant to be as faithful as possible to the original Markdown.
32
- Additionally, OMD implements a few Github markdown features, an
33
- extension mechanism, and some other features. Note that the opam
34
- package installs both the OMD library and the command line tool `omd`."""
35
- url {
36
- src:
37
- "https://github.com/Chris00/omd/releases/download/1.3.1/omd-1.3.1.tar.gz"
38
- checksum: "md5=845fc38e86ec0e85721130f2dd044d00"
39
- }
@@ -1,41 +0,0 @@
1
- opam-version: "2.0"
2
- synopsis: """Unicode character properties for OCaml"""
3
- maintainer: ["Daniel Bünzli <daniel.buenzl i@erratique.ch>"]
4
- authors: ["The uucp programmers"]
5
- homepage: "https://erratique.ch/software/uucp"
6
- doc: "https://erratique.ch/software/uucp/doc/"
7
- dev-repo: "git+https://erratique.ch/repos/uucp.git"
8
- bug-reports: "https://github.com/dbuenzli/uucp/issues"
9
- license: ["ISC"]
10
- tags: ["unicode" "text" "character" "org:erratique"]
11
- depends: ["ocaml" {>= "4.03.0"}
12
- "ocamlfind" {build}
13
- "ocamlbuild" {build}
14
- "topkg" {build & >= "1.0.3"}
15
- "uucd" {with-test}
16
- "uunf" {with-test}
17
- "uutf" {with-test}]
18
- depopts: ["uutf"
19
- "uunf"
20
- "cmdliner"]
21
- conflicts: ["uutf" {< "1.0.1"}
22
- "cmdliner" {< "1.0.0"}]
23
- build: [["ocaml" "pkg/pkg.ml" "build" "--dev-pkg" "%{dev}%"
24
- "--with-uutf" "%{uutf:installed}%"
25
- "--with-uunf" "%{uunf:installed}%"
26
- "--with-cmdliner" "%{cmdliner:installed}%" ]]
27
- description: """
28
- Uucp is an OCaml library providing efficient access to a selection of
29
- character properties of the [Unicode character database][1].
30
-
31
- Uucp is independent from any Unicode text data structure and has no
32
- dependencies. It is distributed under the ISC license.
33
-
34
- [1]: http://www.unicode.org/reports/tr44/
35
-
36
- Home page: http://erratique.ch/software/uucp"""
37
- url {
38
- src: "https://erratique.ch/software/uucp/releases/uucp-14.0.0.tbz"
39
- checksum: "sha512=2d0224aed5d5accbb121624898f08598e8c74a2415942f159a54221c0cdac62ed64fc70a039c833e50110cefce77754ada9ac2d58f79a6fc9331135326fe6899"}
40
- post-messages: ["If the build fails with \"ocamlopt.opt got signal and exited\", issue 'ulimit -s unlimited' and retry."
41
- {failure & (arch = "ppc64" | arch = "arm64")}]
@@ -1,3 +0,0 @@
1
- {
2
- "build": "dune build -p js_of_ocaml-compiler"
3
- }