@grain/binaryen.ml 0.35.0 → 0.36.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 +20 -0
- binaryen-archive/binaryen.opam +3 -3
- binaryen-archive/esy.lock/index.json +338 -462
- binaryen-archive/esy.lock/opam/base.v0.17.3/opam +1 -1
- binaryen-archive/esy.lock/opam/{chrome-trace.3.21.1 → chrome-trace.3.24.1}/opam +6 -8
- binaryen-archive/esy.lock/opam/{cmdliner.1.3.0 → cmdliner.2.1.1}/opam +26 -10
- binaryen-archive/esy.lock/opam/{dune-build-info.3.21.1 → dune-build-info.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune-configurator.3.21.1 → dune-configurator.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune-rpc.3.21.1 → dune-rpc.3.20.2}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.3.21.1 → dune.3.24.2}/opam +13 -9
- binaryen-archive/esy.lock/opam/{dyn.3.21.1 → dyn.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/fix.20250919/opam +1 -0
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.4.1/opam +67 -0
- binaryen-archive/esy.lock/opam/ocaml-lsp-server.1.23.1/opam +2 -2
- binaryen-archive/esy.lock/opam/{ocaml-version.4.0.3 → ocaml-version.4.1.3}/opam +3 -3
- binaryen-archive/esy.lock/opam/{ocaml_intrinsics_kernel.v0.17.1 → ocaml_intrinsics_kernel.v0.17.2}/opam +3 -5
- binaryen-archive/esy.lock/opam/ocamlbuild.0.16.1/opam +1 -0
- binaryen-archive/esy.lock/opam/{ocamlc-loc.3.21.1 → ocamlc-loc.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.8/opam +2 -1
- binaryen-archive/esy.lock/opam/{ocamlformat-lib.0.27.0 → ocamlformat-lib.0.29.0}/opam +7 -6
- binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.28.1 → ocamlformat-rpc-lib.0.29.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlformat.0.27.0 → ocamlformat.0.29.0}/opam +6 -5
- binaryen-archive/esy.lock/opam/{ocp-indent.1.7.0 → ocp-indent.1.9.0}/opam +10 -9
- binaryen-archive/esy.lock/opam/{ordering.3.21.1 → ordering.3.20.2}/opam +6 -6
- binaryen-archive/esy.lock/opam/{ppxlib.0.37.0 → ppxlib.0.39.0~5.6preview}/opam +12 -13
- binaryen-archive/esy.lock/opam/{stdune.3.21.1 → stdune.3.20.2}/opam +7 -9
- binaryen-archive/esy.lock/opam/{xdg.3.21.1 → xdg.3.24.2}/opam +6 -8
- binaryen-archive/package.json +9 -5
- binaryen-archive/src/dune +4 -1
- binaryen-archive/src/expression.c +345 -0
- binaryen-archive/src/expression.js +241 -7
- binaryen-archive/src/expression.ml +106 -0
- binaryen-archive/src/expression.mli +72 -0
- binaryen-archive/src/heap_type.c +19 -0
- binaryen-archive/src/heap_type.js +12 -0
- binaryen-archive/src/heap_type.ml +10 -1
- binaryen-archive/src/heap_type.mli +8 -1
- binaryen-archive/src/memory.c +6 -1
- binaryen-archive/src/memory.js +2 -2
- binaryen-archive/src/memory.ml +1 -1
- binaryen-archive/src/memory.mli +1 -1
- binaryen-archive/src/module.js +7 -20
- binaryen-archive/src/module.ml +4 -0
- binaryen-archive/src/module.mli +1 -0
- binaryen-archive/src/module_feature.c +6 -0
- binaryen-archive/src/module_feature.js +6 -0
- binaryen-archive/src/ocaml_helpers.c +9 -0
- binaryen-archive/src/ocaml_helpers.h +5 -0
- binaryen-archive/src/ocaml_helpers.js +11 -0
- binaryen-archive/src/passes.ml +10 -4
- binaryen-archive/src/passes.mli +11 -5
- binaryen-archive/src/type.c +5 -3
- binaryen-archive/src/type.js +2 -3
- binaryen-archive/src/type.ml +4 -1
- binaryen-archive/src/type.mli +1 -1
- binaryen-archive/src/type_builder.c +180 -0
- binaryen-archive/src/type_builder.js +116 -0
- binaryen-archive/src/type_builder.ml +67 -0
- binaryen-archive/src/type_builder.mli +28 -0
- binaryen-archive/test/test.expected +188 -25
- binaryen-archive/test/test.ml +131 -4
- binaryen-archive/esy.lock/opam/base-bytes.base/opam +0 -10
- binaryen-archive/esy.lock/opam/fs-io.3.21.1/opam +0 -41
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.2.0/opam +0 -56
- binaryen-archive/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -31
- binaryen-archive/esy.lock/opam/top-closure.3.21.1/opam +0 -40
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
(i32.const 0)
|
|
8
8
|
)
|
|
9
9
|
(module
|
|
10
|
-
(type $
|
|
11
|
-
(type $1 (
|
|
12
|
-
(type $2 (func))
|
|
13
|
-
(type $3 (func (param
|
|
14
|
-
(type $4 (func
|
|
15
|
-
(
|
|
10
|
+
(type $List (struct (field $head i31ref) (field $tail (ref null $List))))
|
|
11
|
+
(type $1 (array (mut i8)))
|
|
12
|
+
(type $2 (func (param i32)))
|
|
13
|
+
(type $3 (func (param i32 i32) (result i32)))
|
|
14
|
+
(type $4 (func))
|
|
15
|
+
(type $5 (func (param anyref i32 i32) (result i32)))
|
|
16
|
+
(type $6 (func (param anyref) (result i32)))
|
|
17
|
+
(type $7 (func (param anyref) (result anyref anyref)))
|
|
18
|
+
(type $8 (func (result (ref $1) (ref $List))))
|
|
19
|
+
(import "future-wasi" "write" (func $write (type $5) (param anyref i32 i32) (result i32)))
|
|
16
20
|
(global $max_int64 i64 (i64.const 9223372036854775807))
|
|
17
21
|
(global $max_int64_mut (mut i64) (i64.const 9223372036854775807))
|
|
18
22
|
(global $test_float64_bits f64 (f64.const 1.23))
|
|
@@ -21,14 +25,15 @@
|
|
|
21
25
|
(data $world "world")
|
|
22
26
|
(table $table 1 1 funcref)
|
|
23
27
|
(elem $elem (i32.const 0) $adder)
|
|
24
|
-
(tag $foo (type $
|
|
25
|
-
(tag $bar (type $
|
|
28
|
+
(tag $foo (type $2) (param i32))
|
|
29
|
+
(tag $bar (type $2) (param i32))
|
|
26
30
|
(export "adder" (func $adder))
|
|
27
31
|
(export "memory" (memory $0))
|
|
28
32
|
(export "hello" (func $hello))
|
|
29
33
|
(export "try" (func $try))
|
|
34
|
+
(export "gc" (func $gc))
|
|
30
35
|
(start $start)
|
|
31
|
-
(func $adder (type $
|
|
36
|
+
(func $adder (type $3) (param $0 i32) (param $1 i32) (result i32)
|
|
32
37
|
(block $add (result i32)
|
|
33
38
|
(if
|
|
34
39
|
(i32.const 0)
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
)
|
|
49
54
|
)
|
|
50
55
|
)
|
|
51
|
-
(func $start (type $
|
|
56
|
+
(func $start (type $4)
|
|
52
57
|
(block $start
|
|
53
58
|
(memory.init $world
|
|
54
59
|
(i32.const 2048)
|
|
@@ -56,7 +61,7 @@
|
|
|
56
61
|
(i32.const 5)
|
|
57
62
|
)
|
|
58
63
|
(drop
|
|
59
|
-
(call_indirect $table (type $
|
|
64
|
+
(call_indirect $table (type $3)
|
|
60
65
|
(i32.const 3)
|
|
61
66
|
(i32.const 5)
|
|
62
67
|
(i32.const 0)
|
|
@@ -64,14 +69,14 @@
|
|
|
64
69
|
)
|
|
65
70
|
)
|
|
66
71
|
)
|
|
67
|
-
(func $hello (type $
|
|
72
|
+
(func $hello (type $6) (param $0 anyref) (result i32)
|
|
68
73
|
(call $write
|
|
69
74
|
(local.get $0)
|
|
70
75
|
(i32.const 0)
|
|
71
76
|
(i32.const 1)
|
|
72
77
|
)
|
|
73
78
|
)
|
|
74
|
-
(func $try (type $
|
|
79
|
+
(func $try (type $4)
|
|
75
80
|
(block $blk
|
|
76
81
|
(drop
|
|
77
82
|
(try $tc1 (result i32)
|
|
@@ -139,27 +144,76 @@
|
|
|
139
144
|
)
|
|
140
145
|
)
|
|
141
146
|
)
|
|
147
|
+
(func $gc (type $7) (param $0 anyref) (result anyref anyref)
|
|
148
|
+
(local $1 (ref $1))
|
|
149
|
+
(local $2 (ref $List))
|
|
150
|
+
(block $gc_block (type $8) (result (ref $1) (ref $List))
|
|
151
|
+
(local.set $1
|
|
152
|
+
(array.new_fixed $1 2
|
|
153
|
+
(i32.const 0)
|
|
154
|
+
(i32.const 255)
|
|
155
|
+
)
|
|
156
|
+
)
|
|
157
|
+
(array.set $1
|
|
158
|
+
(local.get $1)
|
|
159
|
+
(i32.const 1)
|
|
160
|
+
(i32.const 42)
|
|
161
|
+
)
|
|
162
|
+
(local.set $2
|
|
163
|
+
(struct.new $List
|
|
164
|
+
(ref.cast i31ref
|
|
165
|
+
(local.get $0)
|
|
166
|
+
)
|
|
167
|
+
(struct.new $List
|
|
168
|
+
(ref.i31
|
|
169
|
+
(i32.const 1)
|
|
170
|
+
)
|
|
171
|
+
(struct.new $List
|
|
172
|
+
(ref.i31
|
|
173
|
+
(i32.const 2)
|
|
174
|
+
)
|
|
175
|
+
(struct.new $List
|
|
176
|
+
(ref.i31
|
|
177
|
+
(i32.const 3)
|
|
178
|
+
)
|
|
179
|
+
(ref.null none)
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
(tuple.make 2
|
|
186
|
+
(local.get $1)
|
|
187
|
+
(local.get $2)
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
)
|
|
142
191
|
)
|
|
143
192
|
(module
|
|
144
|
-
(type $
|
|
145
|
-
(type $1 (
|
|
146
|
-
(type $2 (func (param i32
|
|
147
|
-
(type $3 (func
|
|
148
|
-
(type $4 (func (param
|
|
149
|
-
(
|
|
193
|
+
(type $List (struct (field $head i31ref) (field $tail (ref null $List))))
|
|
194
|
+
(type $1 (array (mut i8)))
|
|
195
|
+
(type $2 (func (param i32)))
|
|
196
|
+
(type $3 (func))
|
|
197
|
+
(type $4 (func (param i32 i32) (result i32)))
|
|
198
|
+
(type $5 (func (param anyref i32 i32) (result i32)))
|
|
199
|
+
(type $6 (func (param anyref) (result i32)))
|
|
200
|
+
(type $7 (func (param anyref) (result anyref anyref)))
|
|
201
|
+
(type $8 (func (result (ref (exact $1)) (ref (exact $List)))))
|
|
202
|
+
(import "future-wasi" "write" (func $write (type $5) (param anyref i32 i32) (result i32)))
|
|
150
203
|
(memory $0 1)
|
|
151
204
|
(data $hello (i32.const 0) "hello")
|
|
152
205
|
(data $world "world")
|
|
153
206
|
(table $table 1 1 funcref)
|
|
154
207
|
(elem $elem (i32.const 0) $adder)
|
|
155
|
-
(tag $foo (type $
|
|
156
|
-
(tag $bar (type $
|
|
208
|
+
(tag $foo (type $2) (param i32))
|
|
209
|
+
(tag $bar (type $2) (param i32))
|
|
157
210
|
(export "adder" (func $adder))
|
|
158
211
|
(export "memory" (memory $0))
|
|
159
212
|
(export "hello" (func $hello))
|
|
160
213
|
(export "try" (func $try))
|
|
214
|
+
(export "gc" (func $gc))
|
|
161
215
|
(start $start)
|
|
162
|
-
(func $adder (type $
|
|
216
|
+
(func $adder (type $4) (param $0 i32) (param $1 i32) (result i32)
|
|
163
217
|
(i32.add
|
|
164
218
|
(select
|
|
165
219
|
(local.get $0)
|
|
@@ -171,7 +225,7 @@
|
|
|
171
225
|
(local.get $1)
|
|
172
226
|
)
|
|
173
227
|
)
|
|
174
|
-
(func $start (type $
|
|
228
|
+
(func $start (type $3)
|
|
175
229
|
(memory.init $world
|
|
176
230
|
(i32.const 2048)
|
|
177
231
|
(i32.const 0)
|
|
@@ -184,14 +238,14 @@
|
|
|
184
238
|
)
|
|
185
239
|
)
|
|
186
240
|
)
|
|
187
|
-
(func $hello (type $
|
|
241
|
+
(func $hello (type $6) (param $0 anyref) (result i32)
|
|
188
242
|
(call $write
|
|
189
243
|
(local.get $0)
|
|
190
244
|
(i32.const 0)
|
|
191
245
|
(i32.const 1)
|
|
192
246
|
)
|
|
193
247
|
)
|
|
194
|
-
(func $try (type $
|
|
248
|
+
(func $try (type $3)
|
|
195
249
|
(drop
|
|
196
250
|
(try (result i32)
|
|
197
251
|
(do
|
|
@@ -231,12 +285,53 @@
|
|
|
231
285
|
)
|
|
232
286
|
)
|
|
233
287
|
)
|
|
288
|
+
(func $gc (type $7) (param $0 anyref) (result anyref anyref)
|
|
289
|
+
(local $1 (ref (exact $1)))
|
|
290
|
+
(array.set $1
|
|
291
|
+
(local.tee $1
|
|
292
|
+
(array.new_fixed $1 2
|
|
293
|
+
(i32.const 0)
|
|
294
|
+
(i32.const 255)
|
|
295
|
+
)
|
|
296
|
+
)
|
|
297
|
+
(i32.const 1)
|
|
298
|
+
(i32.const 42)
|
|
299
|
+
)
|
|
300
|
+
(tuple.make 2
|
|
301
|
+
(local.get $1)
|
|
302
|
+
(struct.new $List
|
|
303
|
+
(ref.cast i31ref
|
|
304
|
+
(local.get $0)
|
|
305
|
+
)
|
|
306
|
+
(struct.new $List
|
|
307
|
+
(ref.i31
|
|
308
|
+
(i32.const 1)
|
|
309
|
+
)
|
|
310
|
+
(struct.new $List
|
|
311
|
+
(ref.i31
|
|
312
|
+
(i32.const 2)
|
|
313
|
+
)
|
|
314
|
+
(struct.new $List
|
|
315
|
+
(ref.i31
|
|
316
|
+
(i32.const 3)
|
|
317
|
+
)
|
|
318
|
+
(ref.null none)
|
|
319
|
+
)
|
|
320
|
+
)
|
|
321
|
+
)
|
|
322
|
+
)
|
|
323
|
+
)
|
|
324
|
+
)
|
|
234
325
|
)
|
|
235
326
|
(module
|
|
327
|
+
(type $type_7 (struct (field i31ref) (field (ref null $type_7))))
|
|
328
|
+
(type $type_6 (array (mut i8)))
|
|
236
329
|
(type $type_3 (func))
|
|
237
330
|
(type $type_1 (func (param anyref i32 i32) (result i32)))
|
|
238
331
|
(type $type_2 (func (param i32 i32) (result i32)))
|
|
239
332
|
(type $type_4 (func (param anyref) (result i32)))
|
|
333
|
+
(type $type_5 (func (param anyref) (result anyref anyref)))
|
|
334
|
+
(type $type_8 (func (result anyref anyref)))
|
|
240
335
|
(import "future-wasi" "write" (func $fimport$0 (type $type_1) (param anyref i32 i32) (result i32)))
|
|
241
336
|
(memory $0 1)
|
|
242
337
|
(data $0 (i32.const 0) "hello")
|
|
@@ -247,6 +342,7 @@
|
|
|
247
342
|
(export "memory" (memory $0))
|
|
248
343
|
(export "hello" (func $2))
|
|
249
344
|
(export "try" (func $3))
|
|
345
|
+
(export "gc" (func $4))
|
|
250
346
|
(start $1)
|
|
251
347
|
(func $0 (type $type_2) (param $0 i32) (param $1 i32) (result i32)
|
|
252
348
|
(i32.add
|
|
@@ -286,12 +382,53 @@
|
|
|
286
382
|
)
|
|
287
383
|
(unreachable)
|
|
288
384
|
)
|
|
385
|
+
(func $4 (type $type_5) (param $0 anyref) (result anyref anyref)
|
|
386
|
+
(local $1 (ref (exact $type_6)))
|
|
387
|
+
(array.set $type_6
|
|
388
|
+
(local.tee $1
|
|
389
|
+
(array.new_fixed $type_6 2
|
|
390
|
+
(i32.const 0)
|
|
391
|
+
(i32.const 255)
|
|
392
|
+
)
|
|
393
|
+
)
|
|
394
|
+
(i32.const 1)
|
|
395
|
+
(i32.const 42)
|
|
396
|
+
)
|
|
397
|
+
(tuple.make 2
|
|
398
|
+
(local.get $1)
|
|
399
|
+
(struct.new $type_7
|
|
400
|
+
(ref.cast i31ref
|
|
401
|
+
(local.get $0)
|
|
402
|
+
)
|
|
403
|
+
(struct.new $type_7
|
|
404
|
+
(ref.i31
|
|
405
|
+
(i32.const 1)
|
|
406
|
+
)
|
|
407
|
+
(struct.new $type_7
|
|
408
|
+
(ref.i31
|
|
409
|
+
(i32.const 2)
|
|
410
|
+
)
|
|
411
|
+
(struct.new $type_7
|
|
412
|
+
(ref.i31
|
|
413
|
+
(i32.const 3)
|
|
414
|
+
)
|
|
415
|
+
(ref.null none)
|
|
416
|
+
)
|
|
417
|
+
)
|
|
418
|
+
)
|
|
419
|
+
)
|
|
420
|
+
)
|
|
421
|
+
)
|
|
289
422
|
)
|
|
290
423
|
(module
|
|
424
|
+
(type $type_7 (struct (field i31ref) (field (ref null $type_7))))
|
|
425
|
+
(type $type_6 (array (mut i8)))
|
|
291
426
|
(type $type_3 (func))
|
|
292
427
|
(type $type_1 (func (param anyref i32 i32) (result i32)))
|
|
293
428
|
(type $type_2 (func (param i32 i32) (result i32)))
|
|
294
429
|
(type $type_4 (func (param anyref) (result i32)))
|
|
430
|
+
(type $type_5 (func (param anyref) (result anyref anyref)))
|
|
431
|
+
(type $type_8 (func (result anyref anyref)))
|
|
295
432
|
(import "future-wasi" "write" (func $fimport$0 (type $type_1) (param anyref i32 i32) (result i32)))
|
|
296
433
|
(memory $0 1)
|
|
297
434
|
(data $0 (i32.const 0) "hello")
|
|
@@ -302,6 +439,7 @@
|
|
|
302
439
|
(export "memory" (memory $0))
|
|
303
440
|
(export "hello" (func $2))
|
|
304
441
|
(export "try" (func $3))
|
|
442
|
+
(export "gc" (func $4))
|
|
305
443
|
(start $1)
|
|
306
444
|
(func $0 (type $type_2) (param $0 i32) (param $1 i32) (result i32)
|
|
307
445
|
local.get $0
|
|
@@ -331,4 +469,29 @@
|
|
|
331
469
|
(func $3 (type $type_3)
|
|
332
470
|
unreachable
|
|
333
471
|
)
|
|
472
|
+
(func $4 (type $type_5) (param $0 anyref) (result anyref anyref)
|
|
473
|
+
(local $1 (ref (exact $type_6)))
|
|
474
|
+
i32.const 0
|
|
475
|
+
i32.const 255
|
|
476
|
+
array.new_fixed $type_6 2
|
|
477
|
+
local.tee $1
|
|
478
|
+
i32.const 1
|
|
479
|
+
i32.const 42
|
|
480
|
+
array.set $type_6
|
|
481
|
+
local.get $1
|
|
482
|
+
local.get $0
|
|
483
|
+
ref.cast i31ref
|
|
484
|
+
i32.const 1
|
|
485
|
+
ref.i31
|
|
486
|
+
i32.const 2
|
|
487
|
+
ref.i31
|
|
488
|
+
i32.const 3
|
|
489
|
+
ref.i31
|
|
490
|
+
ref.null none
|
|
491
|
+
struct.new $type_7
|
|
492
|
+
struct.new $type_7
|
|
493
|
+
struct.new $type_7
|
|
494
|
+
struct.new $type_7
|
|
495
|
+
tuple.make 2
|
|
496
|
+
)
|
|
334
497
|
)
|
binaryen-archive/test/test.ml
CHANGED
|
@@ -171,13 +171,19 @@ let start =
|
|
|
171
171
|
let _ = Export.add_function_export wasm_mod "adder" "adder"
|
|
172
172
|
let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
let adder_type =
|
|
175
|
+
let builder = Type_builder.make 1 in
|
|
176
|
+
Type_builder.set_signature_type builder 0 (params ()) results;
|
|
177
|
+
match Type_builder.build_and_dispose builder with
|
|
178
|
+
| Ok [ ty ] -> ty
|
|
179
|
+
| _ -> failwith "failed to build type"
|
|
180
|
+
|
|
181
|
+
let funcref_expr1 = Expression.Ref.func wasm_mod "adder" adder_type
|
|
176
182
|
|
|
177
183
|
let _ =
|
|
178
184
|
Expression.Table.set wasm_mod "table"
|
|
179
185
|
(Expression.Const.make wasm_mod (Literal.int32 0l))
|
|
180
|
-
funcref_expr1
|
|
186
|
+
funcref_expr1
|
|
181
187
|
|
|
182
188
|
let funcref_expr2 =
|
|
183
189
|
Expression.Table.get wasm_mod "table"
|
|
@@ -248,12 +254,28 @@ let _ = Memory.set_memory max_memory_wasm_mod 1 2 "memory" [] false false "0"
|
|
|
248
254
|
let _ = assert (Memory.has_max max_memory_wasm_mod "0" = true)
|
|
249
255
|
let _ = assert (Memory.get_max max_memory_wasm_mod "0" = 2)
|
|
250
256
|
|
|
257
|
+
(* Memory.get_segment_byte_offset Passive *)
|
|
258
|
+
let _ = assert (Memory.get_segment_byte_offset wasm_mod "world" = None)
|
|
259
|
+
|
|
251
260
|
let _ =
|
|
252
261
|
assert (
|
|
253
262
|
Bytes.equal
|
|
254
263
|
(Memory.get_segment_data wasm_mod "world")
|
|
255
264
|
(Bytes.of_string "world"))
|
|
256
265
|
|
|
266
|
+
(* Call_ref *)
|
|
267
|
+
let thunk_type =
|
|
268
|
+
let builder = Type_builder.make 1 in
|
|
269
|
+
Type_builder.set_signature_type builder 0 Type.none Type.none;
|
|
270
|
+
match Type_builder.build_and_dispose builder with
|
|
271
|
+
| Ok [ ty ] -> ty
|
|
272
|
+
| _ -> failwith "failed to build type"
|
|
273
|
+
|
|
274
|
+
let _ =
|
|
275
|
+
Expression.Call_ref.make wasm_mod
|
|
276
|
+
(Expression.Ref.func wasm_mod "start" thunk_type)
|
|
277
|
+
[] Type.none
|
|
278
|
+
|
|
257
279
|
let _ = Tag.add_tag wasm_mod "foo" Type.int32 Type.none
|
|
258
280
|
let _ = Tag.add_tag wasm_mod "bar" Type.int32 Type.none
|
|
259
281
|
|
|
@@ -365,6 +387,111 @@ let _ = Export.add_function_export wasm_mod "hello" "hello"
|
|
|
365
387
|
let _ = Export.add_function_export wasm_mod "try" "try"
|
|
366
388
|
let _ = Module.validate wasm_mod
|
|
367
389
|
|
|
390
|
+
(* Create a function that does gc *)
|
|
391
|
+
let _ =
|
|
392
|
+
let array_u8_type =
|
|
393
|
+
let builder = Type_builder.make 1 in
|
|
394
|
+
Type_builder.set_array_type builder 0 Type.int32 Packed_type.int8 true;
|
|
395
|
+
match Type_builder.build_and_dispose builder with
|
|
396
|
+
| Ok [ ty ] -> ty
|
|
397
|
+
| _ -> failwith "failed to make array type"
|
|
398
|
+
in
|
|
399
|
+
let list_type =
|
|
400
|
+
let builder = Type_builder.make 1 in
|
|
401
|
+
let temp_heap_type = Type_builder.get_temp_heap_type builder 0 in
|
|
402
|
+
let temp_ref_type =
|
|
403
|
+
Type_builder.get_temp_ref_type builder temp_heap_type true
|
|
404
|
+
in
|
|
405
|
+
Type_builder.set_struct_type builder 0
|
|
406
|
+
[
|
|
407
|
+
Type_builder.
|
|
408
|
+
{
|
|
409
|
+
type_ = Type.i31ref;
|
|
410
|
+
packed_type = Packed_type.not_packed;
|
|
411
|
+
mutable_ = false;
|
|
412
|
+
};
|
|
413
|
+
Type_builder.
|
|
414
|
+
{
|
|
415
|
+
type_ = temp_ref_type;
|
|
416
|
+
packed_type = Packed_type.not_packed;
|
|
417
|
+
mutable_ = false;
|
|
418
|
+
};
|
|
419
|
+
];
|
|
420
|
+
match Type_builder.build_and_dispose builder with
|
|
421
|
+
| Ok [ ty ] -> ty
|
|
422
|
+
| _ -> failwith "failed to make list type"
|
|
423
|
+
in
|
|
424
|
+
let i32 v = Expression.Const.make wasm_mod (Literal.int32 v) in
|
|
425
|
+
let i31 v = Expression.I31.make wasm_mod (i32 v) in
|
|
426
|
+
let cons first rest =
|
|
427
|
+
Expression.Struct.new_ wasm_mod (Some [ first; rest ]) list_type
|
|
428
|
+
in
|
|
429
|
+
let empty () =
|
|
430
|
+
Expression.Ref.null wasm_mod (Type.from_heap_type list_type true)
|
|
431
|
+
in
|
|
432
|
+
Function.add_function wasm_mod "gc" Type.anyref
|
|
433
|
+
(Type.create [| Type.anyref; Type.anyref |])
|
|
434
|
+
[|
|
|
435
|
+
Type.from_heap_type array_u8_type false;
|
|
436
|
+
Type.from_heap_type list_type false;
|
|
437
|
+
|]
|
|
438
|
+
(Expression.Block.make wasm_mod "gc_block"
|
|
439
|
+
[
|
|
440
|
+
Expression.Local_set.make wasm_mod 1
|
|
441
|
+
(Expression.Array.new_fixed wasm_mod array_u8_type
|
|
442
|
+
[ i32 0l; i32 255l ]);
|
|
443
|
+
Expression.Array.set wasm_mod
|
|
444
|
+
(Expression.Local_get.make wasm_mod 1
|
|
445
|
+
(Type.from_heap_type array_u8_type false))
|
|
446
|
+
(i32 1l) (i32 42l);
|
|
447
|
+
Expression.Local_set.make wasm_mod 2
|
|
448
|
+
(cons
|
|
449
|
+
(Expression.Ref.cast wasm_mod
|
|
450
|
+
(Expression.Local_get.make wasm_mod 0 Type.anyref)
|
|
451
|
+
Type.i31ref)
|
|
452
|
+
(cons (i31 1l) (cons (i31 2l) (cons (i31 3l) (empty ())))));
|
|
453
|
+
Expression.Tuple_make.make wasm_mod
|
|
454
|
+
[
|
|
455
|
+
Expression.Local_get.make wasm_mod 1
|
|
456
|
+
(Type.from_heap_type array_u8_type false);
|
|
457
|
+
Expression.Local_get.make wasm_mod 2
|
|
458
|
+
(Type.from_heap_type list_type false);
|
|
459
|
+
];
|
|
460
|
+
])
|
|
461
|
+
|
|
462
|
+
let _ = Export.add_function_export wasm_mod "gc" "gc"
|
|
463
|
+
let _ = assert (Module.validate wasm_mod == 1)
|
|
464
|
+
|
|
465
|
+
(* Test Heap_type.set_type_name and Heap_type.set_field_name *)
|
|
466
|
+
let list_type =
|
|
467
|
+
let builder = Type_builder.make 1 in
|
|
468
|
+
let temp_heap_type = Type_builder.get_temp_heap_type builder 0 in
|
|
469
|
+
let temp_ref_type =
|
|
470
|
+
Type_builder.get_temp_ref_type builder temp_heap_type true
|
|
471
|
+
in
|
|
472
|
+
Type_builder.set_struct_type builder 0
|
|
473
|
+
[
|
|
474
|
+
Type_builder.
|
|
475
|
+
{
|
|
476
|
+
type_ = Type.i31ref;
|
|
477
|
+
packed_type = Packed_type.not_packed;
|
|
478
|
+
mutable_ = false;
|
|
479
|
+
};
|
|
480
|
+
Type_builder.
|
|
481
|
+
{
|
|
482
|
+
type_ = temp_ref_type;
|
|
483
|
+
packed_type = Packed_type.not_packed;
|
|
484
|
+
mutable_ = false;
|
|
485
|
+
};
|
|
486
|
+
];
|
|
487
|
+
match Type_builder.build_and_dispose builder with
|
|
488
|
+
| Ok [ ty ] -> ty
|
|
489
|
+
| _ -> failwith "failed to make list type"
|
|
490
|
+
|
|
491
|
+
let _ = Heap_type.set_type_name wasm_mod list_type "List"
|
|
492
|
+
let _ = Heap_type.set_field_name wasm_mod list_type 0 "head"
|
|
493
|
+
let _ = Heap_type.set_field_name wasm_mod list_type 1 "tail"
|
|
494
|
+
|
|
368
495
|
(* Shouldn't actually do anything since we aren't doing function renames *)
|
|
369
496
|
let _ = Module.update_maps wasm_mod
|
|
370
497
|
|
|
@@ -437,7 +564,7 @@ let _ =
|
|
|
437
564
|
Module.Feature.all;
|
|
438
565
|
]
|
|
439
566
|
|
|
440
|
-
let _ = Module.validate new_mod
|
|
567
|
+
let _ = assert (Module.validate new_mod == 1)
|
|
441
568
|
let _ = Module.print new_mod
|
|
442
569
|
let _ = Module.print_stack_ir new_mod
|
|
443
570
|
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
opam-version: "2.0"
|
|
2
|
-
synopsis: "File System Operations"
|
|
3
|
-
description: "Misc. Collection of File System Operations"
|
|
4
|
-
maintainer: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
|
5
|
-
authors: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
|
6
|
-
license: "MIT"
|
|
7
|
-
homepage: "https://github.com/ocaml/dune"
|
|
8
|
-
doc: "https://dune.readthedocs.io/"
|
|
9
|
-
bug-reports: "https://github.com/ocaml/dune/issues"
|
|
10
|
-
depends: [
|
|
11
|
-
"dune" {>= "3.21"}
|
|
12
|
-
"base-unix"
|
|
13
|
-
"ocaml" {>= "4.08"}
|
|
14
|
-
"odoc" {with-doc}
|
|
15
|
-
]
|
|
16
|
-
dev-repo: "git+https://github.com/ocaml/dune.git"
|
|
17
|
-
x-maintenance-intent: ["none"]
|
|
18
|
-
build: [
|
|
19
|
-
["dune" "subst"] {dev}
|
|
20
|
-
["rm" "-rf" "vendor/csexp"]
|
|
21
|
-
["rm" "-rf" "vendor/pp"]
|
|
22
|
-
[
|
|
23
|
-
"dune"
|
|
24
|
-
"build"
|
|
25
|
-
"-p"
|
|
26
|
-
name
|
|
27
|
-
"-j"
|
|
28
|
-
jobs
|
|
29
|
-
"@install"
|
|
30
|
-
"@doc" {with-doc}
|
|
31
|
-
]
|
|
32
|
-
]
|
|
33
|
-
url {
|
|
34
|
-
src:
|
|
35
|
-
"https://github.com/ocaml/dune/releases/download/3.21.1/dune-3.21.1.tbz"
|
|
36
|
-
checksum: [
|
|
37
|
-
"sha256=84f7a82c6d80a7124f3847e9a489e80cfbeafb7bed3573ac01286ef56fd08d94"
|
|
38
|
-
"sha512=d9fa44e24036d2593adfe59e52e0ad64f3e7e973d23f84af57fc79e38fa210630b0cb55590f314d6ef455333b96a8e0ce188c2720eaae44576222541ba78efb3"
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
x-commit-hash: "0b5863d9be475453b3cc2bd321fde222af2544d4"
|
|
@@ -1,56 +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" "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
|
|
9
|
-
]
|
|
10
|
-
homepage: "https://ocsigen.org/js_of_ocaml/latest/manual/overview"
|
|
11
|
-
doc: "https://ocsigen.org/js_of_ocaml/latest/manual/overview"
|
|
12
|
-
bug-reports: "https://github.com/ocsigen/js_of_ocaml/issues"
|
|
13
|
-
depends: [
|
|
14
|
-
"dune" {>= "3.19"}
|
|
15
|
-
"ocaml" {>= "4.13" & < "5.5"}
|
|
16
|
-
"num" {with-test}
|
|
17
|
-
"ppx_expect" {>= "v0.16.1" & with-test}
|
|
18
|
-
"ppxlib" {>= "0.35"}
|
|
19
|
-
"re" {with-test}
|
|
20
|
-
"cmdliner" {>= "1.1.0"}
|
|
21
|
-
"sedlex" {>= "3.3"}
|
|
22
|
-
"qcheck" {with-test}
|
|
23
|
-
"menhir"
|
|
24
|
-
"menhirLib"
|
|
25
|
-
"menhirSdk"
|
|
26
|
-
"yojson" {>= "2.1"}
|
|
27
|
-
"odoc" {with-doc}
|
|
28
|
-
]
|
|
29
|
-
depopts: ["ocamlfind"]
|
|
30
|
-
conflicts: [
|
|
31
|
-
"ocamlfind" {< "1.5.1"}
|
|
32
|
-
"js_of_ocaml" {< "3.0"}
|
|
33
|
-
]
|
|
34
|
-
dev-repo: "git+https://github.com/ocsigen/js_of_ocaml.git"
|
|
35
|
-
x-maintenance-intent: ["(latest)"]
|
|
36
|
-
build: [
|
|
37
|
-
[
|
|
38
|
-
"dune"
|
|
39
|
-
"build"
|
|
40
|
-
"-p"
|
|
41
|
-
name
|
|
42
|
-
"-j"
|
|
43
|
-
jobs
|
|
44
|
-
"@install"
|
|
45
|
-
"@doc" {with-doc}
|
|
46
|
-
]
|
|
47
|
-
]
|
|
48
|
-
url {
|
|
49
|
-
src:
|
|
50
|
-
"https://github.com/ocsigen/js_of_ocaml/releases/download/6.2.0/js_of_ocaml-6.2.0.tbz"
|
|
51
|
-
checksum: [
|
|
52
|
-
"sha256=7cc641778d1b172a352a88333ee0e8c621365a0acfcd9b87e38bfddb8dd2a5da"
|
|
53
|
-
"sha512=da50c79e1ad667df22abe03d0928ee135729c90cf09279e3c4854aec66557e8600890ca58f550529de1b1a44698720890b97528df167fd9e10cce24c71e763e6"
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
x-commit-hash: "938c18c46b78836119483d9cc9ce25ffdc44b718"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
opam-version: "2.0"
|
|
2
|
-
maintainer: "The stdlib-shims programmers"
|
|
3
|
-
authors: "The stdlib-shims programmers"
|
|
4
|
-
homepage: "https://github.com/ocaml/stdlib-shims"
|
|
5
|
-
doc: "https://ocaml.github.io/stdlib-shims/"
|
|
6
|
-
dev-repo: "git+https://github.com/ocaml/stdlib-shims.git"
|
|
7
|
-
bug-reports: "https://github.com/ocaml/stdlib-shims/issues"
|
|
8
|
-
tags: ["stdlib" "compatibility" "org:ocaml"]
|
|
9
|
-
license: ["LGPL-2.1-only WITH OCaml-LGPL-linking-exception"]
|
|
10
|
-
depends: [
|
|
11
|
-
"dune"
|
|
12
|
-
"ocaml" {>= "4.02.3"}
|
|
13
|
-
]
|
|
14
|
-
build: [ "dune" "build" "-p" name "-j" jobs ]
|
|
15
|
-
synopsis: "Backport some of the new stdlib features to older compiler"
|
|
16
|
-
description: """
|
|
17
|
-
Backport some of the new stdlib features to older compiler,
|
|
18
|
-
such as the Stdlib module.
|
|
19
|
-
|
|
20
|
-
This allows projects that require compatibility with older compiler to
|
|
21
|
-
use these new features in their code.
|
|
22
|
-
"""
|
|
23
|
-
x-commit-hash: "fb6815e5d745f07fd567c11671149de6ef2e74c8"
|
|
24
|
-
url {
|
|
25
|
-
src:
|
|
26
|
-
"https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz"
|
|
27
|
-
checksum: [
|
|
28
|
-
"sha256=babf72d3917b86f707885f0c5528e36c63fccb698f4b46cf2bab5c7ccdd6d84a"
|
|
29
|
-
"sha512=1151d7edc8923516e9a36995a3f8938d323aaade759ad349ed15d6d8501db61ffbe63277e97c4d86149cf371306ac23df0f581ec7e02611f58335126e1870980"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
opam-version: "2.0"
|
|
2
|
-
synopsis: "Topological Closure"
|
|
3
|
-
description: "Generic Topological Closure"
|
|
4
|
-
maintainer: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
|
5
|
-
authors: ["Jane Street Group, LLC <opensource@janestreet.com>"]
|
|
6
|
-
license: "MIT"
|
|
7
|
-
homepage: "https://github.com/ocaml/dune"
|
|
8
|
-
doc: "https://dune.readthedocs.io/"
|
|
9
|
-
bug-reports: "https://github.com/ocaml/dune/issues"
|
|
10
|
-
depends: [
|
|
11
|
-
"dune" {>= "3.21"}
|
|
12
|
-
"ocaml" {>= "4.08"}
|
|
13
|
-
"odoc" {with-doc}
|
|
14
|
-
]
|
|
15
|
-
dev-repo: "git+https://github.com/ocaml/dune.git"
|
|
16
|
-
x-maintenance-intent: ["none"]
|
|
17
|
-
build: [
|
|
18
|
-
["dune" "subst"] {dev}
|
|
19
|
-
["rm" "-rf" "vendor/csexp"]
|
|
20
|
-
["rm" "-rf" "vendor/pp"]
|
|
21
|
-
[
|
|
22
|
-
"dune"
|
|
23
|
-
"build"
|
|
24
|
-
"-p"
|
|
25
|
-
name
|
|
26
|
-
"-j"
|
|
27
|
-
jobs
|
|
28
|
-
"@install"
|
|
29
|
-
"@doc" {with-doc}
|
|
30
|
-
]
|
|
31
|
-
]
|
|
32
|
-
url {
|
|
33
|
-
src:
|
|
34
|
-
"https://github.com/ocaml/dune/releases/download/3.21.1/dune-3.21.1.tbz"
|
|
35
|
-
checksum: [
|
|
36
|
-
"sha256=84f7a82c6d80a7124f3847e9a489e80cfbeafb7bed3573ac01286ef56fd08d94"
|
|
37
|
-
"sha512=d9fa44e24036d2593adfe59e52e0ad64f3e7e973d23f84af57fc79e38fa210630b0cb55590f314d6ef455333b96a8e0ce188c2720eaae44576222541ba78efb3"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
x-commit-hash: "0b5863d9be475453b3cc2bd321fde222af2544d4"
|