@grain/binaryen.ml 0.12.1 → 0.13.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 +14 -0
- binaryen-archive/README.md +24 -0
- binaryen-archive/binaryen.opam +2 -2
- binaryen-archive/esy.lock/index.json +6 -6
- binaryen-archive/js/binaryen.es5.js +363 -5
- binaryen-archive/js/dune +1 -1
- binaryen-archive/js/export.ml +0 -3
- binaryen-archive/js/expression.ml +161 -0
- binaryen-archive/js/literal.ml +0 -1
- binaryen-archive/js/module.ml +6 -9
- binaryen-archive/js/op.ml +0 -223
- binaryen-archive/js/prelude.js +2 -11
- binaryen-archive/js/type.ml +0 -9
- binaryen-archive/package.json +2 -2
- binaryen-archive/src/binaryen_stubs_expressions.c +250 -0
- binaryen-archive/src/binaryen_stubs_features.c +24 -0
- binaryen-archive/src/element_segment.ml +0 -1
- binaryen-archive/src/export.ml +0 -2
- binaryen-archive/src/expression.ml +94 -63
- binaryen-archive/src/function.ml +0 -6
- binaryen-archive/src/global.ml +0 -2
- binaryen-archive/src/literal.ml +0 -3
- binaryen-archive/src/module.ml +17 -9
- binaryen-archive/src/settings.ml +0 -6
- binaryen-archive/src/type.ml +0 -1
- binaryen-archive/test/config/ocamlopt_flags.ml +8 -1
- binaryen-archive/test/test.expected +8 -0
- binaryen-archive/test/test.ml +44 -22
- binaryen-archive/virtual/element_segment.mli +0 -4
- binaryen-archive/virtual/export.mli +0 -15
- binaryen-archive/virtual/expression.mli +93 -115
- binaryen-archive/virtual/function.mli +0 -12
- binaryen-archive/virtual/global.mli +0 -8
- binaryen-archive/virtual/import.mli +0 -4
- binaryen-archive/virtual/literal.mli +0 -5
- binaryen-archive/virtual/module.mli +4 -29
- binaryen-archive/virtual/op.mli +0 -315
- binaryen-archive/virtual/settings.mli +0 -17
- binaryen-archive/virtual/table.mli +0 -3
- binaryen-archive/virtual/type.mli +0 -11
- binaryen-archive/js/postlude.js +0 -2
binaryen-archive/js/dune
CHANGED
binaryen-archive/js/export.ml
CHANGED
|
@@ -46,11 +46,8 @@ let external_function =
|
|
|
46
46
|
meth_call global##.binaryen "_BinaryenExternalFunction" [||]
|
|
47
47
|
|
|
48
48
|
let external_table = meth_call global##.binaryen "_BinaryenExternalTable" [||]
|
|
49
|
-
|
|
50
49
|
let external_memory = meth_call global##.binaryen "_BinaryenExternalMemory" [||]
|
|
51
|
-
|
|
52
50
|
let external_global = meth_call global##.binaryen "_BinaryenExternalGlobal" [||]
|
|
53
|
-
|
|
54
51
|
let external_tag = meth_call global##.binaryen "_BinaryenExternalTag" [||]
|
|
55
52
|
|
|
56
53
|
let export_get_kind export =
|
|
@@ -942,3 +942,164 @@ end
|
|
|
942
942
|
module Null = struct
|
|
943
943
|
let make () = pure_js_expr "null"
|
|
944
944
|
end
|
|
945
|
+
|
|
946
|
+
module Ref = struct
|
|
947
|
+
(** Module, type *)
|
|
948
|
+
let null wasm_mod typ =
|
|
949
|
+
let scope = get wasm_mod "ref" in
|
|
950
|
+
meth_call scope "null" [| inject typ |]
|
|
951
|
+
|
|
952
|
+
(** Module, op, value *)
|
|
953
|
+
let is wasm_mod op value =
|
|
954
|
+
meth_call global##.binaryen "_BinaryenRefIs"
|
|
955
|
+
[| inject wasm_mod; inject op; inject value |]
|
|
956
|
+
|
|
957
|
+
(** Module, op, value *)
|
|
958
|
+
let as_ wasm_mod op value =
|
|
959
|
+
meth_call global##.binaryen "_BinaryenRefAs"
|
|
960
|
+
[| inject wasm_mod; inject op; inject value |]
|
|
961
|
+
|
|
962
|
+
(** Module, func, type *)
|
|
963
|
+
let func wasm_mod func typ =
|
|
964
|
+
let scope = get wasm_mod "ref" in
|
|
965
|
+
meth_call scope "func" [| inject (string func); inject typ |]
|
|
966
|
+
|
|
967
|
+
(** Module, left, right *)
|
|
968
|
+
let eq wasm_mod left right =
|
|
969
|
+
let scope = get wasm_mod "ref" in
|
|
970
|
+
meth_call scope "func" [| inject left; inject right |]
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
module Table = struct
|
|
974
|
+
(** Module, name, index, type *)
|
|
975
|
+
let get wasm_mod name index typ =
|
|
976
|
+
let scope = Js_of_ocaml.Js.Unsafe.get wasm_mod "table" in
|
|
977
|
+
meth_call scope "get" [| inject (string name); inject index; inject typ |]
|
|
978
|
+
|
|
979
|
+
(** Module, name, index, value *)
|
|
980
|
+
let set wasm_mod name index value =
|
|
981
|
+
let scope = Js_of_ocaml.Js.Unsafe.get wasm_mod "table" in
|
|
982
|
+
meth_call scope "set" [| inject (string name); inject index; inject value |]
|
|
983
|
+
|
|
984
|
+
(** Module, name *)
|
|
985
|
+
let size wasm_mod name =
|
|
986
|
+
let scope = Js_of_ocaml.Js.Unsafe.get wasm_mod "table" in
|
|
987
|
+
meth_call scope "size" [| inject (string name) |]
|
|
988
|
+
|
|
989
|
+
(** Module, name, value, delta *)
|
|
990
|
+
let grow wasm_mod name value delta =
|
|
991
|
+
let scope = Js_of_ocaml.Js.Unsafe.get wasm_mod "table" in
|
|
992
|
+
meth_call scope "grow"
|
|
993
|
+
[| inject (string name); inject value; inject delta |]
|
|
994
|
+
end
|
|
995
|
+
|
|
996
|
+
module Table_get = struct
|
|
997
|
+
(** Gets the name of the table being accessed by a `Table.get` expression. *)
|
|
998
|
+
let get_table exp =
|
|
999
|
+
to_string
|
|
1000
|
+
(meth_call global ##. binaryen ##. TableGet "getTable" [| inject exp |])
|
|
1001
|
+
|
|
1002
|
+
(** Gets the name of the table being accessed by a `Table.get` expression. *)
|
|
1003
|
+
let set_table exp name =
|
|
1004
|
+
meth_call
|
|
1005
|
+
global ##. binaryen ##. TableGet
|
|
1006
|
+
"setTable"
|
|
1007
|
+
[| inject exp; inject (string name) |]
|
|
1008
|
+
|
|
1009
|
+
(** Gets the index expression of a `Table.get` expression. *)
|
|
1010
|
+
let get_index exp =
|
|
1011
|
+
meth_call global ##. binaryen ##. TableGet "getIndex" [| inject exp |]
|
|
1012
|
+
|
|
1013
|
+
(** Gets the index expression of a `Table.get` expression. *)
|
|
1014
|
+
let set_index exp index =
|
|
1015
|
+
meth_call
|
|
1016
|
+
global ##. binaryen ##. TableGet
|
|
1017
|
+
"setIndex"
|
|
1018
|
+
[| inject exp; inject index |]
|
|
1019
|
+
end
|
|
1020
|
+
|
|
1021
|
+
module Table_set = struct
|
|
1022
|
+
(** Gets the name of the table being accessed by a `Table.set` expression. *)
|
|
1023
|
+
let get_table exp =
|
|
1024
|
+
to_string
|
|
1025
|
+
(meth_call global ##. binaryen ##. TableSet "getTable" [| inject exp |])
|
|
1026
|
+
|
|
1027
|
+
(** Sets the name of the table being accessed by a `Table.set` expression. *)
|
|
1028
|
+
let set_table exp name =
|
|
1029
|
+
meth_call
|
|
1030
|
+
global ##. binaryen ##. TableSet
|
|
1031
|
+
"setTable"
|
|
1032
|
+
[| inject exp; inject (string name) |]
|
|
1033
|
+
|
|
1034
|
+
(** Gets the index expression of a `Table.set` expression. *)
|
|
1035
|
+
let get_index exp =
|
|
1036
|
+
meth_call global ##. binaryen ##. TableSet "getIndex" [| inject exp |]
|
|
1037
|
+
|
|
1038
|
+
(** Sets the index expression of a `Table.set` expression. *)
|
|
1039
|
+
let set_index exp index =
|
|
1040
|
+
meth_call
|
|
1041
|
+
global ##. binaryen ##. TableSet
|
|
1042
|
+
"setIndex"
|
|
1043
|
+
[| inject exp; inject index |]
|
|
1044
|
+
|
|
1045
|
+
(** Gets the value expression of a `Table.set` expression. *)
|
|
1046
|
+
let get_value exp =
|
|
1047
|
+
meth_call global ##. binaryen ##. TableSet "getValue" [| inject exp |]
|
|
1048
|
+
|
|
1049
|
+
(** Sets the value expression of a `Table.set` expression. *)
|
|
1050
|
+
let set_value exp value =
|
|
1051
|
+
meth_call
|
|
1052
|
+
global ##. binaryen ##. TableSet
|
|
1053
|
+
"setValue"
|
|
1054
|
+
[| inject exp; inject value |]
|
|
1055
|
+
end
|
|
1056
|
+
|
|
1057
|
+
module Table_size = struct
|
|
1058
|
+
(** Gets the name of the table being accessed by a `Table.size` expression. *)
|
|
1059
|
+
let get_table exp =
|
|
1060
|
+
to_string
|
|
1061
|
+
(meth_call global ##. binaryen ##. TableSize "getTable" [| inject exp |])
|
|
1062
|
+
|
|
1063
|
+
(** Sets the name of the table being accessed by a `Table.size` expression. *)
|
|
1064
|
+
let set_table exp name =
|
|
1065
|
+
meth_call
|
|
1066
|
+
global ##. binaryen ##. TableSize
|
|
1067
|
+
"setTable"
|
|
1068
|
+
[| inject exp; inject (string name) |]
|
|
1069
|
+
end
|
|
1070
|
+
|
|
1071
|
+
module Table_grow = struct
|
|
1072
|
+
(** Gets the name of the table being accessed by a `Table.grow` expression. *)
|
|
1073
|
+
let get_table exp =
|
|
1074
|
+
to_string
|
|
1075
|
+
(meth_call global ##. binaryen ##. TableGrow "getTable" [| inject exp |])
|
|
1076
|
+
|
|
1077
|
+
(** Gets the name of the table being accessed by a `Table.grow` expression. *)
|
|
1078
|
+
let set_table exp name =
|
|
1079
|
+
meth_call
|
|
1080
|
+
global ##. binaryen ##. TableGrow
|
|
1081
|
+
"setTable"
|
|
1082
|
+
[| inject exp; inject (string name) |]
|
|
1083
|
+
|
|
1084
|
+
(** Gets the value expression of a `Table.grow` expression. *)
|
|
1085
|
+
let get_value exp =
|
|
1086
|
+
meth_call global ##. binaryen ##. TableGrow "getValue" [| inject exp |]
|
|
1087
|
+
|
|
1088
|
+
(** Sets the value expression of a `Table.grow` expression. *)
|
|
1089
|
+
let set_value exp value =
|
|
1090
|
+
meth_call
|
|
1091
|
+
global ##. binaryen ##. TableGrow
|
|
1092
|
+
"setValue"
|
|
1093
|
+
[| inject exp; inject value |]
|
|
1094
|
+
|
|
1095
|
+
(** Gets the delta of a `Table.grow` expression. *)
|
|
1096
|
+
let get_delta exp =
|
|
1097
|
+
meth_call global ##. binaryen ##. TableGrow "getDelta" [| inject exp |]
|
|
1098
|
+
|
|
1099
|
+
(** Sets the delta of a `Table.grow` expression. *)
|
|
1100
|
+
let set_delta exp delta =
|
|
1101
|
+
meth_call
|
|
1102
|
+
global ##. binaryen ##. TableGrow
|
|
1103
|
+
"setDelta"
|
|
1104
|
+
[| inject exp; inject delta |]
|
|
1105
|
+
end
|
binaryen-archive/js/literal.ml
CHANGED
binaryen-archive/js/module.ml
CHANGED
|
@@ -5,29 +5,29 @@ module Feature = struct
|
|
|
5
5
|
type t = int
|
|
6
6
|
|
|
7
7
|
let mvp : t = global ##. binaryen ##. Features ##. MVP
|
|
8
|
-
|
|
9
8
|
let atomics : t = global ##. binaryen ##. Features ##. Atomics
|
|
10
|
-
|
|
11
9
|
let bulk_memory : t = global ##. binaryen ##. Features ##. BulkMemory
|
|
12
|
-
|
|
13
10
|
let mutable_globals : t = global ##. binaryen ##. Features ##. MutableGlobals
|
|
14
11
|
|
|
15
12
|
let nontrapping_fp_to_int : t =
|
|
16
13
|
global ##. binaryen ##. Features ##. NontrappingFPToInt
|
|
17
14
|
|
|
18
15
|
let sign_ext : t = global ##. binaryen ##. Features ##. SignExt
|
|
19
|
-
|
|
20
16
|
let simd128 : t = global ##. binaryen ##. Features ##. SIMD128
|
|
21
17
|
|
|
22
18
|
let exception_handling : t =
|
|
23
19
|
global ##. binaryen ##. Features ##. ExceptionHandling
|
|
24
20
|
|
|
25
21
|
let tail_call : t = global ##. binaryen ##. Features ##. TailCall
|
|
26
|
-
|
|
27
22
|
let reference_types : t = global ##. binaryen ##. Features ##. ReferenceTypes
|
|
28
|
-
|
|
29
23
|
let multivalue : t = global ##. binaryen ##. Features ##. Multivalue
|
|
24
|
+
let gc : t = global ##. binaryen ##. Features ##. GC
|
|
25
|
+
let memory64 : t = global ##. binaryen ##. Features ##. Memory64
|
|
26
|
+
|
|
27
|
+
let typed_function_references : t =
|
|
28
|
+
global ##. binaryen ##. Features ##. TypedFunctionReferences
|
|
30
29
|
|
|
30
|
+
let relaxed_simd : t = global ##. binaryen ##. Features ##. RelaxedSIMD
|
|
31
31
|
let all : t = global ##. binaryen ##. Features ##. All
|
|
32
32
|
end
|
|
33
33
|
|
|
@@ -35,13 +35,11 @@ external u8a_to_bytes : 'a -> bytes = "caml_bytes_of_array"
|
|
|
35
35
|
|
|
36
36
|
(* TODO: Verify this converts to bytes correctly? *)
|
|
37
37
|
external bytes_to_u8a : bytes -> 'a = "caml_array_of_bytes"
|
|
38
|
-
|
|
39
38
|
external string_to_u8a : string -> 'a = "caml_array_of_string"
|
|
40
39
|
|
|
41
40
|
type t
|
|
42
41
|
|
|
43
42
|
let create () = new_obj global ##. binaryen ##. Module [||]
|
|
44
|
-
|
|
45
43
|
let dispose wasm_mod = ignore (meth_call wasm_mod "dispose" [||])
|
|
46
44
|
|
|
47
45
|
(* TODO: Check the unit8Array conversion *)
|
|
@@ -63,7 +61,6 @@ let print_asmjs wasm_mod =
|
|
|
63
61
|
print_string (to_string asm)
|
|
64
62
|
|
|
65
63
|
let validate wasm_mod = meth_call wasm_mod "validate" [||]
|
|
66
|
-
|
|
67
64
|
let optimize wasm_mod = meth_call wasm_mod "optimize" [||]
|
|
68
65
|
|
|
69
66
|
let get_features wasm_mod =
|