@grain/binaryen.ml 0.14.0 → 0.16.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 (76) hide show
  1. binaryen-archive/CHANGELOG.md +56 -0
  2. binaryen-archive/README.md +10 -24
  3. binaryen-archive/binaryen.opam +3 -5
  4. binaryen-archive/dune +1 -1
  5. binaryen-archive/esy.lock/index.json +77 -160
  6. binaryen-archive/esy.lock/opam/{cmdliner.1.1.0 → cmdliner.1.1.1}/opam +24 -18
  7. binaryen-archive/esy.lock/opam/{easy-format.1.3.2 → easy-format.1.3.3}/opam +30 -18
  8. binaryen-archive/esy.lock/opam/{ppx_yojson_conv_lib.v0.14.0 → ppx_yojson_conv_lib.v0.15.0}/opam +2 -2
  9. binaryen-archive/esy.lock/opam/{ppxlib.0.25.0 → ppxlib.0.26.0}/opam +5 -4
  10. binaryen-archive/esy.lock/opam/{re.1.10.3 → re.1.10.4}/opam +7 -7
  11. binaryen-archive/esy.lock/opam/{spawn.v0.15.0 → spawn.v0.15.1}/opam +4 -4
  12. binaryen-archive/esy.lock/overrides/opam__s__easy_format_opam__c__1.3.3_opam_override/package.json +3 -0
  13. binaryen-archive/package.json +4 -6
  14. binaryen-archive/src/binaryen_stubs_exports.js +110 -0
  15. binaryen-archive/src/binaryen_stubs_expressions.c +6 -1
  16. binaryen-archive/src/binaryen_stubs_expressions.js +1614 -0
  17. binaryen-archive/src/binaryen_stubs_features.js +105 -0
  18. binaryen-archive/src/binaryen_stubs_functions.js +92 -0
  19. binaryen-archive/src/binaryen_stubs_globals.js +62 -0
  20. binaryen-archive/src/binaryen_stubs_imports.js +86 -0
  21. binaryen-archive/src/binaryen_stubs_literals.js +29 -0
  22. binaryen-archive/src/binaryen_stubs_memory.js +25 -0
  23. binaryen-archive/src/binaryen_stubs_modules.js +121 -0
  24. binaryen-archive/src/binaryen_stubs_ops.js +1895 -0
  25. binaryen-archive/src/binaryen_stubs_settings.js +120 -0
  26. binaryen-archive/src/binaryen_stubs_tables.c +2 -0
  27. binaryen-archive/src/binaryen_stubs_tables.js +84 -0
  28. binaryen-archive/src/binaryen_stubs_types.js +73 -0
  29. binaryen-archive/src/dune +11 -4
  30. binaryen-archive/{virtual → src}/element_segment.mli +0 -0
  31. binaryen-archive/{virtual → src}/export.mli +0 -0
  32. binaryen-archive/src/expression.ml +1 -1
  33. binaryen-archive/{virtual → src}/expression.mli +1 -1
  34. binaryen-archive/{virtual → src}/function.mli +0 -0
  35. binaryen-archive/{virtual → src}/global.mli +0 -0
  36. binaryen-archive/{virtual → src}/import.mli +0 -0
  37. binaryen-archive/src/literal.ml +0 -13
  38. binaryen-archive/src/literal.mli +8 -0
  39. binaryen-archive/src/memory.ml +6 -6
  40. binaryen-archive/{virtual → src}/memory.mli +1 -1
  41. binaryen-archive/src/module.ml +1 -1
  42. binaryen-archive/{virtual → src}/module.mli +1 -1
  43. binaryen-archive/{virtual → src}/op.mli +0 -0
  44. binaryen-archive/src/passes.ml +345 -0
  45. binaryen-archive/src/passes.mli +343 -0
  46. binaryen-archive/{virtual → src}/settings.mli +0 -0
  47. binaryen-archive/{virtual → src}/table.mli +0 -0
  48. binaryen-archive/{virtual → src}/type.mli +0 -0
  49. binaryen-archive/test/config/ocamlopt_flags.ml +1 -8
  50. binaryen-archive/test/dune +2 -22
  51. binaryen-archive/test/test.expected +8 -4
  52. binaryen-archive/test/test.ml +47 -10
  53. binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +0 -44
  54. binaryen-archive/esy.lock/opam/js_of_ocaml.3.11.0/opam +0 -45
  55. binaryen-archive/esy.lock/opam/uchar.0.0.2/opam +0 -36
  56. binaryen-archive/esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/files/winpatch.patch +0 -11
  57. binaryen-archive/esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/package.json +0 -11
  58. binaryen-archive/js/binaryen.es5.js +0 -363
  59. binaryen-archive/js/dune +0 -13
  60. binaryen-archive/js/element_segment.ml +0 -33
  61. binaryen-archive/js/export.ml +0 -57
  62. binaryen-archive/js/expression.ml +0 -1105
  63. binaryen-archive/js/function.ml +0 -60
  64. binaryen-archive/js/global.ml +0 -48
  65. binaryen-archive/js/import.ml +0 -69
  66. binaryen-archive/js/literal.ml +0 -28
  67. binaryen-archive/js/memory.ml +0 -39
  68. binaryen-archive/js/module.ml +0 -116
  69. binaryen-archive/js/op.ml +0 -482
  70. binaryen-archive/js/prelude.js +0 -2
  71. binaryen-archive/js/settings.ml +0 -60
  72. binaryen-archive/js/stubs.c +0 -15
  73. binaryen-archive/js/table.ml +0 -29
  74. binaryen-archive/js/type.ml +0 -21
  75. binaryen-archive/virtual/dune +0 -6
  76. binaryen-archive/virtual/literal.mli +0 -19
@@ -1,5 +1,3 @@
1
- ; Tests for the default_implementation (mirrors 0.2.2 usage)
2
-
3
1
  (test
4
2
  (name test)
5
3
  (modules test)
@@ -9,24 +7,6 @@
9
7
  (action
10
8
  (run %{test})))
11
9
 
12
- ; Tests for binaryen.native implementation
13
-
14
- (rule
15
- (target test_native.ml)
16
- (action
17
- (progn
18
- (copy %{dep:test.ml} %{target})
19
- (copy test.expected test_native.expected))))
20
-
21
- (test
22
- (name test_native)
23
- (modules test_native)
24
- (libraries binaryen binaryen.native)
25
- (ocamlopt_flags
26
- (:include ./config/ocamlopt_flags.sexp))
27
- (action
28
- (run %{test})))
29
-
30
10
  ; Tests for binaryen.js implementation
31
11
 
32
12
  (rule
@@ -43,8 +23,8 @@
43
23
  (modules test_js)
44
24
  (modes
45
25
  (byte js))
46
- (libraries binaryen binaryen.js)
26
+ (libraries binaryen)
47
27
  (action
48
28
  (run node %{dep:test_js.bc.js}))
49
29
  (js_of_ocaml
50
- (flags --no-sourcemap)))
30
+ (flags --no-sourcemap --disable share)))
@@ -13,8 +13,10 @@
13
13
  (type $externref_=>_i32 (func (param externref) (result i32)))
14
14
  (import "future-wasi" "write" (func $write (param externref i32 i32) (result i32)))
15
15
  (global $max_int64 i64 (i64.const 9223372036854775807))
16
+ (global $max_int64_mut (mut i64) (i64.const 9223372036854775807))
16
17
  (global $test_float64_bits f64 (f64.const 1.23))
17
18
  (memory $0 1)
19
+ (data (i32.const 0) "hello")
18
20
  (table $table 1 1 funcref)
19
21
  (elem $elem (i32.const 0) $adder)
20
22
  (export "adder" (func $adder))
@@ -63,6 +65,7 @@
63
65
  (type $externref_=>_i32 (func (param externref) (result i32)))
64
66
  (import "future-wasi" "write" (func $write (param externref i32 i32) (result i32)))
65
67
  (memory $0 1)
68
+ (data (i32.const 0) "hello")
66
69
  (table $table 1 1 funcref)
67
70
  (elem $elem (i32.const 0) $adder)
68
71
  (export "adder" (func $adder))
@@ -98,12 +101,13 @@
98
101
  )
99
102
  )
100
103
  (module
101
- (type $externref_i32_i32_=>_i32 (func (param externref i32 i32) (result i32)))
102
- (type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
103
- (type $none_=>_none (func))
104
- (type $externref_=>_i32 (func (param externref) (result i32)))
104
+ (type $type$0 (func (param externref i32 i32) (result i32)))
105
+ (type $type$1 (func (param i32 i32) (result i32)))
106
+ (type $type$2 (func))
107
+ (type $type$3 (func (param externref) (result i32)))
105
108
  (import "future-wasi" "write" (func $fimport$0 (param externref i32 i32) (result i32)))
106
109
  (memory $0 1)
110
+ (data (i32.const 0) "hello")
107
111
  (table $0 1 1 funcref)
108
112
  (elem (i32.const 0) $0)
109
113
  (export "adder" (func $0))
@@ -20,6 +20,20 @@ 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
22
 
23
+ (* Testing Return.get_value *)
24
+ let _ =
25
+ assert (
26
+ Option.is_some
27
+ (Expression.Return.get_value
28
+ (Expression.Return.make wasm_mod
29
+ (Expression.Const.make wasm_mod (Literal.int32 0l)))))
30
+
31
+ let _ =
32
+ assert (
33
+ Option.is_none
34
+ (Expression.Return.get_value
35
+ (Expression.Return.make wasm_mod (Expression.Null.make ()))))
36
+
23
37
  (* Create function type for i32 (i32, i32) *)
24
38
  let params () = Type.create [| Type.int32; Type.int32 |]
25
39
  let results = Type.int32
@@ -34,15 +48,18 @@ let select =
34
48
 
35
49
  let bin = Expression.Binary.make wasm_mod Op.add_int32 select (y ())
36
50
 
51
+ let if_ =
52
+ Expression.If.make wasm_mod
53
+ (Expression.Const.make wasm_mod (Literal.int32 0l))
54
+ (Expression.Unreachable.make wasm_mod)
55
+ (Expression.Null.make ())
56
+
57
+ let _ = assert (Expression.If.get_if_false if_ = None)
58
+
37
59
  let add =
38
- Expression.Block.make wasm_mod ~return_type:Type.int32 "add"
39
- [
40
- Expression.If.make wasm_mod
41
- (Expression.Const.make wasm_mod (Literal.int32 0l))
42
- (Expression.Unreachable.make wasm_mod)
43
- (Expression.Null.make ());
44
- bin;
45
- ]
60
+ Expression.Block.make wasm_mod ~return_type:Type.int32 "add" [ if_; bin ]
61
+
62
+ let _ = assert (Expression.Block.get_name add = Some "add")
46
63
 
47
64
  (* Create the add function *)
48
65
  let adder = Function.add_function wasm_mod "adder" (params ()) results [||] add
@@ -91,6 +108,10 @@ let _ =
91
108
  Global.add_global wasm_mod "max_int64" Type.int64 false
92
109
  (Expression.Const.make wasm_mod (Literal.int64 Int64.max_int))
93
110
 
111
+ let _ =
112
+ Global.add_global wasm_mod "max_int64_mut" Type.int64 true
113
+ (Expression.Const.make wasm_mod (Literal.int64 Int64.max_int))
114
+
94
115
  let _ =
95
116
  Global.add_global wasm_mod "test_float64_bits" Type.float64 false
96
117
  (Expression.Const.make wasm_mod (Literal.float64_bits 0x3FF3AE147AE147AEL))
@@ -100,7 +121,15 @@ let _ =
100
121
  (Expression.Const.make wasm_mod (Literal.int32 0l))
101
122
 
102
123
  let _ = Function.set_start wasm_mod start
103
- let _ = Memory.set_memory wasm_mod 1 Memory.unlimited "memory" [] false
124
+
125
+ let segment : Binaryen.Memory.segment =
126
+ let data = "hello" in
127
+ let passive = false in
128
+ let offset = Expression.Const.make wasm_mod (Literal.int32 0l) in
129
+ let size = String.length data in
130
+ { data; passive; offset; size }
131
+
132
+ let _ = Memory.set_memory wasm_mod 1 Memory.unlimited "memory" [ segment ] false
104
133
 
105
134
  (* Create an imported "write" function i32 (externref, i32, i32) *)
106
135
  (* Similar to the example here: https://bytecodealliance.org/articles/reference-types-in-wasmtime *)
@@ -139,8 +168,16 @@ let _ = Module.print wasm_mod
139
168
 
140
169
  (* 3. Copy previous module bytes into new module, validate, and print *)
141
170
 
142
- let byts, _ = Module.write wasm_mod None
171
+ let byts, no_sourcemap = Module.write wasm_mod None
172
+ let _ = assert (no_sourcemap = None)
173
+ let _, sourcemap = Module.write wasm_mod (Some "test.wasm.map")
174
+
175
+ let _ =
176
+ assert (
177
+ sourcemap = Some {|{"version":3,"sources":[],"names":[],"mappings":""}|})
178
+
143
179
  let new_mod = Module.read byts
180
+ let _ = Module.run_passes new_mod [ Passes.name_types ]
144
181
 
145
182
  let _ =
146
183
  Module.set_features new_mod
@@ -1,44 +0,0 @@
1
- opam-version: "2.0"
2
- synopsis: "Compiler from OCaml bytecode to JavaScript"
3
- description:
4
- "Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js"
5
- maintainer: ["Ocsigen team <dev@ocsigen.org>"]
6
- authors: ["Ocsigen team <dev@ocsigen.org>"]
7
- license:
8
- "GPL-2.0-or-later AND LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
9
- homepage: "https://ocsigen.github.io/js_of_ocaml"
10
- doc: "https://ocsigen.github.io/js_of_ocaml"
11
- bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues"
12
- depends: [
13
- "dune" {>= "2.8"}
14
- "ocaml" {>= "4.04"}
15
- "js_of_ocaml" {= version}
16
- "ppxlib" {>= "0.15.0"}
17
- "num" {with-test}
18
- "ppx_expect" {with-test}
19
- "re" {>= "1.9.0" & with-test}
20
- "odoc" {with-doc}
21
- ]
22
- dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git"
23
- build: [
24
- ["dune" "subst"] {dev}
25
- [
26
- "dune"
27
- "build"
28
- "-p"
29
- name
30
- "-j"
31
- jobs
32
- "@install"
33
- "@doc" {with-doc}
34
- ]
35
- ]
36
- url {
37
- src:
38
- "https://github.com/ocsigen/js_of_ocaml/releases/download/3.11.0/js_of_ocaml-3.11.0.tbz"
39
- checksum: [
40
- "sha256=158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a"
41
- "sha512=d83f0988aa1089fa01a0a693d7e6a832018c5a8ce707f44685809769377ef7ef59ce48229b1612966bd9166b610d66ddff8f2606f6c3f09c49f601b74842fde1"
42
- ]
43
- }
44
- x-commit-hash: "4572278dea9cc8a7d44d65b440004a2ec3bce7a7"
@@ -1,45 +0,0 @@
1
- opam-version: "2.0"
2
- synopsis: "Compiler from OCaml bytecode to JavaScript"
3
- description:
4
- "Js_of_ocaml is a compiler from OCaml bytecode to JavaScript. It makes it possible to run pure OCaml programs in JavaScript environment like browsers and Node.js"
5
- maintainer: ["Ocsigen team <dev@ocsigen.org>"]
6
- authors: ["Ocsigen team <dev@ocsigen.org>"]
7
- license:
8
- "GPL-2.0-or-later AND LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
9
- homepage: "https://ocsigen.github.io/js_of_ocaml"
10
- doc: "https://ocsigen.github.io/js_of_ocaml"
11
- bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues"
12
- depends: [
13
- "dune" {>= "2.8"}
14
- "ocaml" {>= "4.04"}
15
- "js_of_ocaml-compiler" {= version}
16
- "ppxlib" {>= "0.15"}
17
- "uchar"
18
- "num" {with-test}
19
- "ppx_expect" {with-test}
20
- "re" {>= "1.9.0" & with-test}
21
- "odoc" {with-doc}
22
- ]
23
- dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git"
24
- build: [
25
- ["dune" "subst"] {dev}
26
- [
27
- "dune"
28
- "build"
29
- "-p"
30
- name
31
- "-j"
32
- jobs
33
- "@install"
34
- "@doc" {with-doc}
35
- ]
36
- ]
37
- url {
38
- src:
39
- "https://github.com/ocsigen/js_of_ocaml/releases/download/3.11.0/js_of_ocaml-3.11.0.tbz"
40
- checksum: [
41
- "sha256=158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a"
42
- "sha512=d83f0988aa1089fa01a0a693d7e6a832018c5a8ce707f44685809769377ef7ef59ce48229b1612966bd9166b610d66ddff8f2606f6c3f09c49f601b74842fde1"
43
- ]
44
- }
45
- x-commit-hash: "4572278dea9cc8a7d44d65b440004a2ec3bce7a7"
@@ -1,36 +0,0 @@
1
- opam-version: "2.0"
2
- maintainer: "Daniel Bünzli <daniel.buenzl i@erratique.ch>"
3
- authors: ["Daniel Bünzli <daniel.buenzl i@erratique.ch>"]
4
- homepage: "http://ocaml.org"
5
- doc: "https://ocaml.github.io/uchar/"
6
- dev-repo: "git+https://github.com/ocaml/uchar.git"
7
- bug-reports: "https://github.com/ocaml/uchar/issues"
8
- tags: [ "text" "character" "unicode" "compatibility" "org:ocaml.org" ]
9
- license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"
10
- depends: [
11
- "ocaml" {>= "3.12.0"}
12
- "ocamlbuild" {build}
13
- ]
14
- build: [
15
- ["ocaml" "pkg/git.ml"]
16
- [
17
- "ocaml"
18
- "pkg/build.ml"
19
- "native=%{ocaml:native}%"
20
- "native-dynlink=%{ocaml:native-dynlink}%"
21
- ]
22
- ]
23
- synopsis: "Compatibility library for OCaml's Uchar module"
24
- description: """
25
- The `uchar` package provides a compatibility library for the
26
- [`Uchar`][1] module introduced in OCaml 4.03.
27
-
28
- The `uchar` package is distributed under the license of the OCaml
29
- compiler. See [LICENSE](LICENSE) for details.
30
-
31
- [1]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Uchar.html"""
32
- url {
33
- src:
34
- "https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz"
35
- checksum: "md5=c9ba2c738d264c420c642f7bb1cf4a36"
36
- }
@@ -1,11 +0,0 @@
1
- --- ./pkg/topkg.ml
2
- +++ ./pkg/topkg.ml
3
- @@ -344,7 +344,7 @@
4
- let build ccomp btool bdir pkg mvs =
5
- let ext_to_string = Exts.ext_to_string ccomp in
6
- let install, exec = build_strings btool bdir ext_to_string mvs in
7
- - let e = Sys.command exec in
8
- + let e = Sys.command ("bash -c '" ^ exec ^ "'") in
9
- if e <> 0 then exit e else
10
- let install_file = pkg ^ ".install" in
11
- try
@@ -1,11 +0,0 @@
1
- {
2
- "build": [
3
- [
4
- "bash",
5
- "-c",
6
- "#{os == 'windows' ? 'patch -p1 < winpatch.patch' : 'true' }"
7
- ],
8
- "ocaml pkg/git.ml",
9
- "ocaml pkg/build.ml native=true native-dynlink=true"
10
- ]
11
- }