@grain/binaryen.ml 0.26.0 → 0.28.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.
- binaryen-archive/CHANGELOG.md +30 -0
- binaryen-archive/README.md +3 -2
- binaryen-archive/binaryen.opam +4 -3
- binaryen-archive/dune +2 -0
- binaryen-archive/esy.lock/index.json +638 -584
- binaryen-archive/esy.lock/opam/{base.v0.16.4 → base.v0.17.3}/opam +8 -6
- binaryen-archive/esy.lock/opam/{chrome-trace.3.18.2 → chrome-trace.3.20.2}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-build-info.3.18.2 → dune-build-info.3.20.2}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-configurator.3.18.2 → dune-configurator.3.20.2}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-rpc.3.18.2 → dune-rpc.3.20.2}/opam +6 -5
- binaryen-archive/esy.lock/opam/{dune.3.18.2 → dune.3.20.2}/opam +8 -7
- binaryen-archive/esy.lock/opam/{dyn.3.18.2 → dyn.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/{fix.20250428 → fix.20250919}/opam +3 -3
- binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.5.9.1 → js_of_ocaml-compiler.6.2.0}/opam +10 -10
- binaryen-archive/esy.lock/opam/jsonrpc.1.23.1/opam +50 -0
- binaryen-archive/esy.lock/opam/lsp.1.23.1/opam +60 -0
- binaryen-archive/esy.lock/opam/{menhir.20240715 → menhir.20250912}/opam +3 -3
- binaryen-archive/esy.lock/opam/{menhirCST.20240715 → menhirCST.20250912}/opam +4 -4
- binaryen-archive/esy.lock/opam/{menhirLib.20240715 → menhirLib.20250912}/opam +3 -3
- binaryen-archive/esy.lock/opam/{menhirSdk.20240715 → menhirSdk.20250912}/opam +3 -3
- binaryen-archive/esy.lock/opam/merlin-lib.5.6-503/opam +36 -0
- binaryen-archive/esy.lock/opam/ocaml-compiler-libs.v0.17.0/opam +28 -0
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.12.4 → ocaml-lsp-server.1.23.1}/opam +24 -12
- binaryen-archive/esy.lock/opam/{ocaml-version.3.5.0 → ocaml-version.4.0.3}/opam +33 -28
- binaryen-archive/esy.lock/opam/ocaml_intrinsics_kernel.v0.17.1/opam +30 -0
- binaryen-archive/esy.lock/opam/ocamlc-loc.3.20.2/opam +45 -0
- binaryen-archive/esy.lock/opam/ocamlformat-lib.0.27.0/opam +68 -0
- binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.27.0 → ocamlformat-rpc-lib.0.28.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/ocamlformat.0.27.0/opam +59 -0
- binaryen-archive/esy.lock/opam/{ordering.3.18.2 → ordering.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/{ppx_yojson_conv_lib.v0.16.0 → ppx_yojson_conv_lib.v0.17.0}/opam +5 -4
- binaryen-archive/esy.lock/opam/{ppxlib.0.35.0 → ppxlib.0.37.0}/opam +5 -5
- binaryen-archive/esy.lock/opam/{re.1.12.0 → re.1.14.0}/opam +35 -27
- binaryen-archive/esy.lock/opam/{sedlex.3.4 → sedlex.3.7}/opam +3 -3
- binaryen-archive/esy.lock/opam/{sexplib0.v0.16.0 → sexplib0.v0.17.0}/opam +9 -4
- binaryen-archive/esy.lock/opam/{stdio.v0.16.0 → stdio.v0.17.0}/opam +6 -5
- binaryen-archive/esy.lock/opam/{stdune.3.18.2 → stdune.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/{topkg.1.0.8 → topkg.1.1.0}/opam +2 -2
- binaryen-archive/esy.lock/opam/{uucp.16.0.0 → uucp.17.0.0}/opam +5 -5
- binaryen-archive/esy.lock/opam/{uuseg.16.0.0 → uuseg.17.0.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{xdg.3.18.2 → xdg.3.20.2}/opam +6 -5
- binaryen-archive/esy.lock/opam/{yojson.2.2.2 → yojson.3.0.0}/opam +5 -6
- binaryen-archive/package.json +6 -6
- binaryen-archive/src/expression.js +2 -1
- binaryen-archive/src/expression.ml +0 -24
- binaryen-archive/src/expression.mli +6 -6
- binaryen-archive/src/heap_type.c +0 -21
- binaryen-archive/src/heap_type.js +0 -18
- binaryen-archive/src/heap_type.ml +0 -6
- binaryen-archive/src/heap_type.mli +0 -3
- binaryen-archive/src/memory.c +30 -24
- binaryen-archive/src/memory.js +17 -11
- binaryen-archive/src/memory.ml +23 -12
- binaryen-archive/src/memory.mli +4 -4
- binaryen-archive/src/module.c +6 -8
- binaryen-archive/src/module.js +12 -9
- binaryen-archive/src/module.ml +2 -8
- binaryen-archive/src/module.mli +2 -2
- binaryen-archive/src/op.c +0 -154
- binaryen-archive/src/op.js +0 -132
- binaryen-archive/src/op.ml +0 -98
- binaryen-archive/src/op.mli +0 -22
- binaryen-archive/src/type.c +0 -21
- binaryen-archive/src/type.js +0 -18
- binaryen-archive/src/type.ml +0 -12
- binaryen-archive/src/type.mli +0 -3
- binaryen-archive/test/dune +1 -2
- binaryen-archive/test/test.expected +28 -26
- binaryen-archive/test/test.ml +8 -6
- binaryen-archive/esy.lock/opam/base-bigarray.base/opam +0 -6
- binaryen-archive/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +0 -39
- binaryen-archive/esy.lock/opam/ocamlformat.0.24.1/opam +0 -57
- binaryen-archive/esy.lock/opam/octavius.1.2.2/opam +0 -36
- binaryen-archive/esy.lock/opam/odoc-parser.2.0.0/opam +0 -47
- binaryen-archive/esy.lock/opam/omd.1.3.2/opam +0 -50
- binaryen-archive/esy.lock/opam/result.1.5/opam +0 -25
|
@@ -9,11 +9,12 @@ homepage: "https://github.com/ocaml/dune"
|
|
|
9
9
|
doc: "https://dune.readthedocs.io/"
|
|
10
10
|
bug-reports: "https://github.com/ocaml/dune/issues"
|
|
11
11
|
depends: [
|
|
12
|
-
"dune" {>= "3.
|
|
12
|
+
"dune" {>= "3.20"}
|
|
13
13
|
"ocaml" {>= "4.08"}
|
|
14
14
|
"odoc" {with-doc}
|
|
15
15
|
]
|
|
16
16
|
dev-repo: "git+https://github.com/ocaml/dune.git"
|
|
17
|
+
x-maintenance-intent: ["(latest)"]
|
|
17
18
|
build: [
|
|
18
19
|
["dune" "subst"] {dev}
|
|
19
20
|
["rm" "-rf" "vendor/csexp"]
|
|
@@ -31,10 +32,10 @@ build: [
|
|
|
31
32
|
]
|
|
32
33
|
url {
|
|
33
34
|
src:
|
|
34
|
-
"https://github.com/ocaml/dune/releases/download/3.
|
|
35
|
+
"https://github.com/ocaml/dune/releases/download/3.20.2/dune-3.20.2.tbz"
|
|
35
36
|
checksum: [
|
|
36
|
-
"sha256=
|
|
37
|
-
"sha512=
|
|
37
|
+
"sha256=b1a86b2d60bdb4a8b9bb6861bdf2f9f28a6e7cb5d833ce81afecceb9ef9ca549"
|
|
38
|
+
"sha512=ed14df9163e487d4ae7d0a2427eaab7823ef1f0ef2d93f0b783e6f163bbd5b44ba73f055d60b84e76f476fe11d38e794013628a1da776d9ec13cca9666e7b7ff"
|
|
38
39
|
]
|
|
39
40
|
}
|
|
40
|
-
x-commit-hash: "
|
|
41
|
+
x-commit-hash: "1e54fd3f450aae7fb41ffb6b7c8b7a5aed754777"
|
|
@@ -16,9 +16,8 @@ doc: "https://ocaml.org/p/yojson/latest"
|
|
|
16
16
|
bug-reports: "https://github.com/ocaml-community/yojson/issues"
|
|
17
17
|
depends: [
|
|
18
18
|
"dune" {>= "2.7"}
|
|
19
|
-
"ocaml" {>= "4.
|
|
19
|
+
"ocaml" {>= "4.08"}
|
|
20
20
|
"alcotest" {with-test & >= "0.8.5"}
|
|
21
|
-
"seq" {>= "0.2.2"}
|
|
22
21
|
"odoc" {with-doc}
|
|
23
22
|
]
|
|
24
23
|
build: [
|
|
@@ -38,10 +37,10 @@ build: [
|
|
|
38
37
|
dev-repo: "git+https://github.com/ocaml-community/yojson.git"
|
|
39
38
|
url {
|
|
40
39
|
src:
|
|
41
|
-
"https://github.com/ocaml-community/yojson/releases/download/
|
|
40
|
+
"https://github.com/ocaml-community/yojson/releases/download/3.0.0/yojson-3.0.0.tbz"
|
|
42
41
|
checksum: [
|
|
43
|
-
"sha256=
|
|
44
|
-
"sha512=
|
|
42
|
+
"sha256=99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610"
|
|
43
|
+
"sha512=896d0ea829a36ccadba6628800369c1a3ab9e7c64dbda8b76331889c9db481cd64e137f467481ae80a8dd5fca45d748bfa71f58641806cc1bb1a007f8291789f"
|
|
45
44
|
]
|
|
46
45
|
}
|
|
47
|
-
x-commit-hash: "
|
|
46
|
+
x-commit-hash: "b2193e8e0c88c6501710d08b836b3219673383f3"
|
binaryen-archive/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grain/binaryen.ml",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "OCaml bindings for Binaryen.",
|
|
5
5
|
"author": "Oscar Spencer <oscar@grain-lang.org>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"ocaml": ">= 4.13.0 < 5.
|
|
9
|
-
"@grain/libbinaryen": "
|
|
8
|
+
"ocaml": ">= 4.13.0 < 5.4.0",
|
|
9
|
+
"@grain/libbinaryen": "118.0.0-b",
|
|
10
10
|
"@opam/dune": ">= 3.0.0",
|
|
11
11
|
"@opam/dune-configurator": ">= 3.0.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@opam/js_of_ocaml-compiler": ">=
|
|
15
|
-
"@opam/ocamlformat": "0.
|
|
16
|
-
"@opam/ocaml-lsp-server": ">= 1.9.1 <
|
|
14
|
+
"@opam/js_of_ocaml-compiler": ">= 6.0.0 < 7.0.0",
|
|
15
|
+
"@opam/ocamlformat": "0.27.0",
|
|
16
|
+
"@opam/ocaml-lsp-server": ">= 1.9.1 < 2.0.0"
|
|
17
17
|
},
|
|
18
18
|
"resolutions": {
|
|
19
19
|
"@opam/ocp-indent": "1.7.0"
|
|
@@ -882,11 +882,12 @@ function caml_binaryen_expression_id_array_len() {
|
|
|
882
882
|
|
|
883
883
|
//Provides: caml_binaryen_expression_print
|
|
884
884
|
//Requires: Binaryen
|
|
885
|
+
//Requires: caml_sys_fds
|
|
885
886
|
//Requires: caml_string_of_jsstring
|
|
886
887
|
//Requires: caml_ml_output, caml_ml_string_length
|
|
887
888
|
function caml_binaryen_expression_print(expr) {
|
|
888
889
|
var text = Binaryen.emitText(expr);
|
|
889
|
-
var chanid = 1; // stdout
|
|
890
|
+
var chanid = caml_sys_fds[1].chanid; // stdout
|
|
890
891
|
var s = caml_string_of_jsstring(text);
|
|
891
892
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
892
893
|
}
|
|
@@ -706,22 +706,9 @@ module Memory_init = struct
|
|
|
706
706
|
external make : Module.t -> string -> t -> t -> t -> string -> t
|
|
707
707
|
= "caml_binaryen_memory_init__bytecode" "caml_binaryen_memory_init"
|
|
708
708
|
(** Module, segment, destination, offset, size, memory_name *)
|
|
709
|
-
|
|
710
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
711
|
-
let make wasm_mod segment dest offset size memory_name =
|
|
712
|
-
make wasm_mod (string_of_int segment) dest offset size memory_name
|
|
713
|
-
|
|
714
709
|
external get_segment : t -> string = "caml_binaryen_memory_init_get_segment"
|
|
715
|
-
|
|
716
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
717
|
-
let get_segment expr = int_of_string (get_segment expr)
|
|
718
|
-
|
|
719
710
|
external set_segment : t -> string -> unit
|
|
720
711
|
= "caml_binaryen_memory_init_set_segment"
|
|
721
|
-
|
|
722
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
723
|
-
let set_segment expr segment = set_segment expr (string_of_int segment)
|
|
724
|
-
|
|
725
712
|
external get_dest : t -> t = "caml_binaryen_memory_init_get_dest"
|
|
726
713
|
external set_dest : t -> t -> unit = "caml_binaryen_memory_init_set_dest"
|
|
727
714
|
external get_offset : t -> t = "caml_binaryen_memory_init_get_offset"
|
|
@@ -733,20 +720,9 @@ end
|
|
|
733
720
|
module Data_drop = struct
|
|
734
721
|
external make : Module.t -> string -> t = "caml_binaryen_data_drop"
|
|
735
722
|
(** Module, segment. *)
|
|
736
|
-
|
|
737
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
738
|
-
let make wasm_mod segment = make wasm_mod (string_of_int segment)
|
|
739
|
-
|
|
740
723
|
external get_segment : t -> string = "caml_binaryen_data_drop_get_segment"
|
|
741
|
-
|
|
742
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
743
|
-
let get_segment expr = int_of_string (get_segment expr)
|
|
744
|
-
|
|
745
724
|
external set_segment : t -> string -> unit
|
|
746
725
|
= "caml_binaryen_data_drop_set_segment"
|
|
747
|
-
|
|
748
|
-
(* Binaryen v113 still uses indexes for data segements, so we only want to change the binding itself, not our interface *)
|
|
749
|
-
let set_segment expr segment = set_segment expr (string_of_int segment)
|
|
750
726
|
end
|
|
751
727
|
|
|
752
728
|
module Memory_copy = struct
|
|
@@ -256,9 +256,9 @@ module Memory_grow : sig
|
|
|
256
256
|
end
|
|
257
257
|
|
|
258
258
|
module Memory_init : sig
|
|
259
|
-
val make : Module.t ->
|
|
260
|
-
val get_segment : t ->
|
|
261
|
-
val set_segment : t ->
|
|
259
|
+
val make : Module.t -> string -> t -> t -> t -> string -> t
|
|
260
|
+
val get_segment : t -> string
|
|
261
|
+
val set_segment : t -> string -> unit
|
|
262
262
|
val get_dest : t -> t
|
|
263
263
|
val set_dest : t -> t -> unit
|
|
264
264
|
val get_offset : t -> t
|
|
@@ -268,9 +268,9 @@ module Memory_init : sig
|
|
|
268
268
|
end
|
|
269
269
|
|
|
270
270
|
module Data_drop : sig
|
|
271
|
-
val make : Module.t ->
|
|
272
|
-
val get_segment : t ->
|
|
273
|
-
val set_segment : t ->
|
|
271
|
+
val make : Module.t -> string -> t
|
|
272
|
+
val get_segment : t -> string
|
|
273
|
+
val set_segment : t -> string -> unit
|
|
274
274
|
end
|
|
275
275
|
|
|
276
276
|
module Memory_copy : sig
|
binaryen-archive/src/heap_type.c
CHANGED
|
@@ -63,27 +63,6 @@ caml_binaryen_heap_type_string(value unit) {
|
|
|
63
63
|
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
CAMLprim value
|
|
67
|
-
caml_binaryen_heap_type_stringview_wtf8(value unit) {
|
|
68
|
-
CAMLparam1(unit);
|
|
69
|
-
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF8();
|
|
70
|
-
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
CAMLprim value
|
|
74
|
-
caml_binaryen_heap_type_stringview_wtf16(value unit) {
|
|
75
|
-
CAMLparam1(unit);
|
|
76
|
-
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF16();
|
|
77
|
-
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
CAMLprim value
|
|
81
|
-
caml_binaryen_heap_type_stringview_iter(value unit) {
|
|
82
|
-
CAMLparam1(unit);
|
|
83
|
-
BinaryenHeapType ty = BinaryenHeapTypeStringviewIter();
|
|
84
|
-
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
66
|
CAMLprim value
|
|
88
67
|
caml_binaryen_heap_type_none(value unit) {
|
|
89
68
|
CAMLparam1(unit);
|
|
@@ -46,24 +46,6 @@ function caml_binaryen_heap_type_string() {
|
|
|
46
46
|
return Binaryen._BinaryenHeapTypeString();
|
|
47
47
|
}
|
|
48
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
49
|
//Provides: caml_binaryen_heap_type_none
|
|
68
50
|
//Requires: Binaryen
|
|
69
51
|
function caml_binaryen_heap_type_none() {
|
|
@@ -8,12 +8,6 @@ external i31 : unit -> t = "caml_binaryen_heap_type_i31"
|
|
|
8
8
|
external struct_ : unit -> t = "caml_binaryen_heap_type_struct"
|
|
9
9
|
external array : unit -> t = "caml_binaryen_heap_type_array"
|
|
10
10
|
external string : unit -> t = "caml_binaryen_heap_type_string"
|
|
11
|
-
external stringview_wtf8 : unit -> t = "caml_binaryen_heap_type_stringview_wtf8"
|
|
12
|
-
|
|
13
|
-
external stringview_wtf16 : unit -> t
|
|
14
|
-
= "caml_binaryen_heap_type_stringview_wtf16"
|
|
15
|
-
|
|
16
|
-
external stringview_iter : unit -> t = "caml_binaryen_heap_type_stringview_iter"
|
|
17
11
|
external none : unit -> t = "caml_binaryen_heap_type_none"
|
|
18
12
|
external noext : unit -> t = "caml_binaryen_heap_type_noext"
|
|
19
13
|
external nofunc : unit -> t = "caml_binaryen_heap_type_nofunc"
|
|
@@ -8,9 +8,6 @@ val i31 : unit -> t
|
|
|
8
8
|
val struct_ : unit -> t
|
|
9
9
|
val array : unit -> t
|
|
10
10
|
val string : unit -> t
|
|
11
|
-
val stringview_wtf8 : unit -> t
|
|
12
|
-
val stringview_wtf16 : unit -> t
|
|
13
|
-
val stringview_iter : unit -> t
|
|
14
11
|
val none : unit -> t
|
|
15
12
|
val noext : unit -> t
|
|
16
13
|
val nofunc : unit -> t
|
binaryen-archive/src/memory.c
CHANGED
|
@@ -8,19 +8,25 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
CAMLprim value
|
|
11
|
-
caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value
|
|
12
|
-
CAMLparam5(_module, _initial, _maximum, _exportName,
|
|
13
|
-
CAMLxparam5(_segmentPassive, _segmentOffsets, _segmentSizes, _shared
|
|
14
|
-
|
|
11
|
+
caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value _segment_names, value _segment_data, value _segmentPassive, value _segmentOffsets, value _segmentSizes, value _shared, value _memory64, value _memoryName) {
|
|
12
|
+
CAMLparam5(_module, _initial, _maximum, _exportName, _segment_names);
|
|
13
|
+
CAMLxparam5(_segment_data, _segmentPassive, _segmentOffsets, _segmentSizes, _shared);
|
|
14
|
+
CAMLxparam2(_memory64, _memoryName);
|
|
15
15
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
16
16
|
BinaryenIndex initial = Int_val(_initial);
|
|
17
17
|
BinaryenIndex maximum = Int_val(_maximum);
|
|
18
18
|
char* exportName = Safe_String_val(_exportName);
|
|
19
|
-
|
|
20
|
-
int
|
|
21
|
-
const char*
|
|
22
|
-
for (int i = 0; i <
|
|
23
|
-
|
|
19
|
+
_segment_names = array_of_list(_segment_names);
|
|
20
|
+
int segmentNamesLen = array_length(_segment_names);
|
|
21
|
+
const char* segment_names[segmentNamesLen];
|
|
22
|
+
for (int i = 0; i < segmentNamesLen; i++) {
|
|
23
|
+
segment_names[i] = Safe_String_val(Field(_segment_names, i));
|
|
24
|
+
}
|
|
25
|
+
_segment_data = array_of_list(_segment_data);
|
|
26
|
+
int segmentDataLen = array_length(_segment_data);
|
|
27
|
+
const char* segment_data[segmentDataLen];
|
|
28
|
+
for (int i = 0; i < segmentDataLen; i++) {
|
|
29
|
+
segment_data[i] = Safe_String_val(Field(_segment_data, i));
|
|
24
30
|
}
|
|
25
31
|
_segmentPassive = array_of_list(_segmentPassive);
|
|
26
32
|
int segmentPassiveLen = array_length(_segmentPassive);
|
|
@@ -43,12 +49,12 @@ caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _e
|
|
|
43
49
|
bool shared = Bool_val(_shared);
|
|
44
50
|
bool memory64 = Bool_val(_memory64);
|
|
45
51
|
char* memoryName = Safe_String_val(_memoryName);
|
|
46
|
-
BinaryenSetMemory(module, initial, maximum, exportName,
|
|
52
|
+
BinaryenSetMemory(module, initial, maximum, exportName, segment_names, segment_data, segmentPassive, segmentOffsets, segmentSizes, segmentNamesLen, shared, memory64, memoryName);
|
|
47
53
|
CAMLreturn(Val_unit);
|
|
48
54
|
}
|
|
49
55
|
CAMLprim value
|
|
50
56
|
caml_binaryen_set_memory__bytecode(value * argv) {
|
|
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]);
|
|
57
|
+
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], argv[11]);
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
CAMLprim value
|
|
@@ -111,28 +117,28 @@ caml_binaryen_get_num_memory_segments(value _module) {
|
|
|
111
117
|
}
|
|
112
118
|
|
|
113
119
|
CAMLprim value
|
|
114
|
-
caml_binaryen_get_memory_segment_byte_offset(value _module, value
|
|
115
|
-
CAMLparam2(_module,
|
|
120
|
+
caml_binaryen_get_memory_segment_byte_offset(value _module, value _name) {
|
|
121
|
+
CAMLparam2(_module, _name);
|
|
116
122
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
117
|
-
|
|
118
|
-
CAMLreturn(Val_int(BinaryenGetMemorySegmentByteOffset(module,
|
|
123
|
+
char* name = Safe_String_val(_name);
|
|
124
|
+
CAMLreturn(Val_int(BinaryenGetMemorySegmentByteOffset(module, name)));
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
CAMLprim value
|
|
122
|
-
caml_binaryen_get_memory_segment_passive(value _module, value
|
|
123
|
-
CAMLparam2(_module,
|
|
128
|
+
caml_binaryen_get_memory_segment_passive(value _module, value _name) {
|
|
129
|
+
CAMLparam2(_module, _name);
|
|
124
130
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
125
|
-
|
|
126
|
-
CAMLreturn(Val_bool(BinaryenGetMemorySegmentPassive(module,
|
|
131
|
+
char* name = Safe_String_val(_name);
|
|
132
|
+
CAMLreturn(Val_bool(BinaryenGetMemorySegmentPassive(module, name)));
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
CAMLprim value
|
|
130
|
-
caml_binaryen_get_memory_segment_data(value _module, value
|
|
131
|
-
CAMLparam2(_module,
|
|
136
|
+
caml_binaryen_get_memory_segment_data(value _module, value _name) {
|
|
137
|
+
CAMLparam2(_module, _name);
|
|
132
138
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
133
|
-
|
|
134
|
-
size_t size = BinaryenGetMemorySegmentByteLength(module,
|
|
139
|
+
char* name = Safe_String_val(_name);
|
|
140
|
+
size_t size = BinaryenGetMemorySegmentByteLength(module, name);
|
|
135
141
|
CAMLprim value bytes = caml_alloc_string(size);
|
|
136
|
-
BinaryenCopyMemorySegmentData(module,
|
|
142
|
+
BinaryenCopyMemorySegmentData(module, name, (char*)Bytes_val(bytes));
|
|
137
143
|
CAMLreturn(bytes);
|
|
138
144
|
}
|
binaryen-archive/src/memory.js
CHANGED
|
@@ -6,7 +6,8 @@ function caml_binaryen_set_memory(
|
|
|
6
6
|
initial,
|
|
7
7
|
maximum,
|
|
8
8
|
exportName,
|
|
9
|
-
|
|
9
|
+
segmentNames,
|
|
10
|
+
segmentData,
|
|
10
11
|
segmentPassives,
|
|
11
12
|
segmentOffsets,
|
|
12
13
|
segmentSizes,
|
|
@@ -14,11 +15,13 @@ function caml_binaryen_set_memory(
|
|
|
14
15
|
memory64,
|
|
15
16
|
memoryName
|
|
16
17
|
) {
|
|
18
|
+
var datas = caml_list_to_js_array(segmentData);
|
|
17
19
|
var passives = caml_list_to_js_array(segmentPassives);
|
|
18
20
|
var offsets = caml_list_to_js_array(segmentOffsets);
|
|
19
|
-
var segs = caml_list_to_js_array(
|
|
21
|
+
var segs = caml_list_to_js_array(segmentNames).map(function (name, idx) {
|
|
20
22
|
return {
|
|
21
|
-
|
|
23
|
+
name: caml_jsstring_of_string(name),
|
|
24
|
+
data: caml_convert_bytes_to_array(datas[idx]),
|
|
22
25
|
passive: caml_js_from_bool(passives[idx]),
|
|
23
26
|
offset: offsets[idx],
|
|
24
27
|
};
|
|
@@ -48,7 +51,8 @@ function caml_binaryen_set_memory__bytecode() {
|
|
|
48
51
|
arguments[7],
|
|
49
52
|
arguments[8],
|
|
50
53
|
arguments[9],
|
|
51
|
-
arguments[10]
|
|
54
|
+
arguments[10],
|
|
55
|
+
arguments[11]
|
|
52
56
|
);
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -108,20 +112,22 @@ function caml_binaryen_get_num_memory_segments(wasm_mod) {
|
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
//Provides: caml_binaryen_get_memory_segment_byte_offset
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
//Requires: caml_jsstring_of_string
|
|
116
|
+
function caml_binaryen_get_memory_segment_byte_offset(wasm_mod, name) {
|
|
117
|
+
var info = wasm_mod.getMemorySegmentInfo(caml_jsstring_of_string(name));
|
|
113
118
|
return info.offset;
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
//Provides: caml_binaryen_get_memory_segment_passive
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
//Requires: caml_jsstring_of_string
|
|
123
|
+
function caml_binaryen_get_memory_segment_passive(wasm_mod, name) {
|
|
124
|
+
var info = wasm_mod.getMemorySegmentInfo(caml_jsstring_of_string(name));
|
|
119
125
|
return info.passive;
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
//Provides: caml_binaryen_get_memory_segment_data
|
|
123
|
-
//Requires: caml_bytes_of_array
|
|
124
|
-
function caml_binaryen_get_memory_segment_data(wasm_mod,
|
|
125
|
-
var info = wasm_mod.
|
|
129
|
+
//Requires: caml_bytes_of_array, caml_jsstring_of_string
|
|
130
|
+
function caml_binaryen_get_memory_segment_data(wasm_mod, name) {
|
|
131
|
+
var info = wasm_mod.getMemorySegmentInfo(caml_jsstring_of_string(name));
|
|
126
132
|
return caml_bytes_of_array(info.data);
|
|
127
133
|
}
|
binaryen-archive/src/memory.ml
CHANGED
|
@@ -3,6 +3,7 @@ external set_memory :
|
|
|
3
3
|
int ->
|
|
4
4
|
int ->
|
|
5
5
|
string ->
|
|
6
|
+
string list ->
|
|
6
7
|
bytes list ->
|
|
7
8
|
bool list ->
|
|
8
9
|
Expression.t list ->
|
|
@@ -12,7 +13,7 @@ external set_memory :
|
|
|
12
13
|
string ->
|
|
13
14
|
unit = "caml_binaryen_set_memory__bytecode" "caml_binaryen_set_memory"
|
|
14
15
|
|
|
15
|
-
type segment = { data : bytes; kind : segment_kind; size : int }
|
|
16
|
+
type segment = { name : string; data : bytes; kind : segment_kind; size : int }
|
|
16
17
|
and segment_kind = Passive | Active of { offset : Expression.t }
|
|
17
18
|
|
|
18
19
|
(** Module, initial size, maximum size, export name, segments, shared, memory64, moduleName . *)
|
|
@@ -20,26 +21,36 @@ let set_memory wasm_mod initial maximum export_name (segments : segment list)
|
|
|
20
21
|
shared memory64 moduleName =
|
|
21
22
|
let split_segments segments =
|
|
22
23
|
List.fold_right
|
|
23
|
-
(fun { data; kind; size }
|
|
24
|
-
(
|
|
24
|
+
(fun { name; data; kind; size }
|
|
25
|
+
( segment_name,
|
|
26
|
+
segment_data,
|
|
27
|
+
segment_passive,
|
|
28
|
+
segment_offsets,
|
|
29
|
+
segment_sizes ) ->
|
|
25
30
|
match kind with
|
|
26
31
|
| Active { offset } ->
|
|
27
|
-
(
|
|
32
|
+
( name :: segment_name,
|
|
33
|
+
data :: segment_data,
|
|
28
34
|
false :: segment_passive,
|
|
29
35
|
offset :: segment_offsets,
|
|
30
36
|
size :: segment_sizes )
|
|
31
37
|
| Passive ->
|
|
32
|
-
(
|
|
38
|
+
( name :: segment_name,
|
|
39
|
+
data :: segment_data,
|
|
33
40
|
true :: segment_passive,
|
|
34
41
|
Expression.Null.make () :: segment_offsets,
|
|
35
42
|
size :: segment_sizes ))
|
|
36
|
-
segments ([], [], [], [])
|
|
43
|
+
segments ([], [], [], [], [])
|
|
37
44
|
in
|
|
38
|
-
let
|
|
45
|
+
let ( segment_name,
|
|
46
|
+
segment_data,
|
|
47
|
+
segment_passive,
|
|
48
|
+
segment_offsets,
|
|
49
|
+
segment_sizes ) =
|
|
39
50
|
split_segments segments
|
|
40
51
|
in
|
|
41
|
-
set_memory wasm_mod initial maximum export_name segment_data
|
|
42
|
-
segment_offsets segment_sizes shared memory64 moduleName
|
|
52
|
+
set_memory wasm_mod initial maximum export_name segment_name segment_data
|
|
53
|
+
segment_passive segment_offsets segment_sizes shared memory64 moduleName
|
|
43
54
|
|
|
44
55
|
external has_memory : Module.t -> bool = "caml_binaryen_has_memory"
|
|
45
56
|
|
|
@@ -59,11 +70,11 @@ let unlimited = -1
|
|
|
59
70
|
external get_num_segments : Module.t -> int
|
|
60
71
|
= "caml_binaryen_get_num_memory_segments"
|
|
61
72
|
|
|
62
|
-
external get_segment_byte_offset : Module.t ->
|
|
73
|
+
external get_segment_byte_offset : Module.t -> string -> int
|
|
63
74
|
= "caml_binaryen_get_memory_segment_byte_offset"
|
|
64
75
|
|
|
65
|
-
external get_segment_passive : Module.t ->
|
|
76
|
+
external get_segment_passive : Module.t -> string -> bool
|
|
66
77
|
= "caml_binaryen_get_memory_segment_passive"
|
|
67
78
|
|
|
68
|
-
external get_segment_data : Module.t ->
|
|
79
|
+
external get_segment_data : Module.t -> string -> bytes
|
|
69
80
|
= "caml_binaryen_get_memory_segment_data"
|
binaryen-archive/src/memory.mli
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type segment = { data : bytes; kind : segment_kind; size : int }
|
|
1
|
+
type segment = { name : string; 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 :
|
|
@@ -20,6 +20,6 @@ val is_shared : Module.t -> string -> bool
|
|
|
20
20
|
val is_64 : Module.t -> string -> bool
|
|
21
21
|
val unlimited : int
|
|
22
22
|
val get_num_segments : Module.t -> int
|
|
23
|
-
val get_segment_byte_offset : Module.t ->
|
|
24
|
-
val get_segment_passive : Module.t ->
|
|
25
|
-
val get_segment_data : Module.t ->
|
|
23
|
+
val get_segment_byte_offset : Module.t -> string -> int
|
|
24
|
+
val get_segment_passive : Module.t -> string -> bool
|
|
25
|
+
val get_segment_data : Module.t -> string -> bytes
|
binaryen-archive/src/module.c
CHANGED
|
@@ -44,10 +44,9 @@ caml_binaryen_module_print_asmjs(value module) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
CAMLprim value
|
|
47
|
-
caml_binaryen_module_print_stack_ir(value module
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module), optimize);
|
|
47
|
+
caml_binaryen_module_print_stack_ir(value module) {
|
|
48
|
+
CAMLparam1(module);
|
|
49
|
+
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module));
|
|
51
50
|
CAMLreturn(Val_unit);
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -127,11 +126,10 @@ caml_binaryen_module_write_text(value _module) {
|
|
|
127
126
|
// There is something weird with this function that causes a bunch of newlines to
|
|
128
127
|
// be printed on stdout when calling it. Not sure if that's a bug in Binaryen.
|
|
129
128
|
CAMLprim value
|
|
130
|
-
caml_binaryen_module_write_stack_ir(value _module
|
|
131
|
-
|
|
129
|
+
caml_binaryen_module_write_stack_ir(value _module) {
|
|
130
|
+
CAMLparam1(_module);
|
|
132
131
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
133
|
-
|
|
134
|
-
char* result = BinaryenModuleAllocateAndWriteStackIR(module, optimize);
|
|
132
|
+
char* result = BinaryenModuleAllocateAndWriteStackIR(module);
|
|
135
133
|
CAMLlocal1(text);
|
|
136
134
|
text = caml_copy_string(result);
|
|
137
135
|
free(result);
|
binaryen-archive/src/module.js
CHANGED
|
@@ -17,31 +17,34 @@ function caml_binaryen_module_parse(text) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//Provides: caml_binaryen_module_print
|
|
20
|
+
//Requires: caml_sys_fds
|
|
20
21
|
//Requires: caml_string_of_jsstring
|
|
21
22
|
//Requires: caml_ml_output, caml_ml_string_length
|
|
22
23
|
function caml_binaryen_module_print(wasm_mod) {
|
|
23
24
|
var text = wasm_mod.emitText();
|
|
24
|
-
var chanid = 1; // stdout
|
|
25
|
+
var chanid = caml_sys_fds[1].chanid; // stdout
|
|
25
26
|
var s = caml_string_of_jsstring(text);
|
|
26
27
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
//Provides: caml_binaryen_module_print_asmjs
|
|
31
|
+
//Requires: caml_sys_fds
|
|
30
32
|
//Requires: caml_string_of_jsstring
|
|
31
33
|
//Requires: caml_ml_output, caml_ml_string_length
|
|
32
34
|
function caml_binaryen_module_print_asmjs(wasm_mod) {
|
|
33
35
|
var asm = wasm_mod.emitAsmjs();
|
|
34
|
-
var chanid = 1; // stdout
|
|
36
|
+
var chanid = caml_sys_fds[1].chanid; // stdout
|
|
35
37
|
var s = caml_string_of_jsstring(asm);
|
|
36
38
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
//Provides: caml_binaryen_module_print_stack_ir
|
|
40
|
-
//Requires:
|
|
42
|
+
//Requires: caml_sys_fds
|
|
43
|
+
//Requires: caml_string_of_jsstring
|
|
41
44
|
//Requires: caml_ml_output, caml_ml_string_length
|
|
42
|
-
function caml_binaryen_module_print_stack_ir(wasm_mod
|
|
43
|
-
var stackir = wasm_mod.emitStackIR(
|
|
44
|
-
var chanid = 1; // stdout
|
|
45
|
+
function caml_binaryen_module_print_stack_ir(wasm_mod) {
|
|
46
|
+
var stackir = wasm_mod.emitStackIR();
|
|
47
|
+
var chanid = caml_sys_fds[1].chanid; // stdout
|
|
45
48
|
var s = caml_string_of_jsstring(stackir);
|
|
46
49
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
47
50
|
}
|
|
@@ -93,9 +96,9 @@ function caml_binaryen_module_write_text(wasm_mod) {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
//Provides: caml_binaryen_module_write_stack_ir
|
|
96
|
-
//Requires: caml_string_of_jsstring
|
|
97
|
-
function caml_binaryen_module_write_stack_ir(wasm_mod
|
|
98
|
-
var text = wasm_mod.emitStackIR(
|
|
99
|
+
//Requires: caml_string_of_jsstring
|
|
100
|
+
function caml_binaryen_module_write_stack_ir(wasm_mod) {
|
|
101
|
+
var text = wasm_mod.emitStackIR();
|
|
99
102
|
return caml_string_of_jsstring(text);
|
|
100
103
|
}
|
|
101
104
|
|
binaryen-archive/src/module.ml
CHANGED
|
@@ -90,10 +90,7 @@ external add_custom_section : t -> string -> string -> unit
|
|
|
90
90
|
external parse : string -> t = "caml_binaryen_module_parse"
|
|
91
91
|
external print : t -> unit = "caml_binaryen_module_print"
|
|
92
92
|
external print_asmjs : t -> unit = "caml_binaryen_module_print_asmjs"
|
|
93
|
-
|
|
94
|
-
external print_stack_ir : t -> bool -> unit
|
|
95
|
-
= "caml_binaryen_module_print_stack_ir"
|
|
96
|
-
|
|
93
|
+
external print_stack_ir : t -> unit = "caml_binaryen_module_print_stack_ir"
|
|
97
94
|
external validate : t -> int = "caml_binaryen_module_validate"
|
|
98
95
|
external optimize : t -> unit = "caml_binaryen_module_optimize"
|
|
99
96
|
external get_features : t -> int = "caml_binaryen_module_get_features"
|
|
@@ -124,10 +121,7 @@ external write : t -> string option -> bytes * string option
|
|
|
124
121
|
= "caml_binaryen_module_write"
|
|
125
122
|
|
|
126
123
|
external write_text : t -> string = "caml_binaryen_module_write_text"
|
|
127
|
-
|
|
128
|
-
external write_stack_ir : t -> bool -> string
|
|
129
|
-
= "caml_binaryen_module_write_stack_ir"
|
|
130
|
-
|
|
124
|
+
external write_stack_ir : t -> string = "caml_binaryen_module_write_stack_ir"
|
|
131
125
|
external read : bytes -> t = "caml_binaryen_module_read"
|
|
132
126
|
external interpret : t -> unit = "caml_binaryen_module_interpret"
|
|
133
127
|
|
binaryen-archive/src/module.mli
CHANGED
|
@@ -29,7 +29,7 @@ val add_custom_section : t -> string -> string -> unit
|
|
|
29
29
|
val parse : string -> t
|
|
30
30
|
val print : t -> unit
|
|
31
31
|
val print_asmjs : t -> unit
|
|
32
|
-
val print_stack_ir : t ->
|
|
32
|
+
val print_stack_ir : t -> unit
|
|
33
33
|
val validate : t -> int
|
|
34
34
|
val optimize : t -> unit
|
|
35
35
|
val get_features : t -> Feature.t list
|
|
@@ -38,7 +38,7 @@ val run_passes : t -> Passes.t list -> unit
|
|
|
38
38
|
val auto_drop : t -> unit
|
|
39
39
|
val write : t -> string option -> bytes * string option
|
|
40
40
|
val write_text : t -> string
|
|
41
|
-
val write_stack_ir : t ->
|
|
41
|
+
val write_stack_ir : t -> string
|
|
42
42
|
val read : bytes -> t
|
|
43
43
|
val interpret : t -> unit
|
|
44
44
|
val add_debug_info_filename : t -> string -> int
|