@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.
- binaryen-archive/CHANGELOG.md +54 -0
- binaryen-archive/README.md +0 -16
- binaryen-archive/binaryen.opam +5 -5
- binaryen-archive/dune-project +1 -1
- binaryen-archive/dune-workspace +1 -1
- binaryen-archive/esy.lock/index.json +422 -372
- binaryen-archive/esy.lock/opam/{base.v0.14.3 → base.v0.15.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/camlp-streams.5.0.1/opam +59 -0
- binaryen-archive/esy.lock/opam/chrome-trace.3.6.1/opam +39 -0
- binaryen-archive/esy.lock/opam/{dune-build-info.3.3.1 → dune-build-info.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dune-configurator.3.3.1 → dune-configurator.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-rpc.3.3.1 → dune-rpc.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.3.3.1 → dune.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dyn.3.3.1 → dyn.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{fiber.3.3.1 → fiber.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.4.0.0 → js_of_ocaml-compiler.4.1.0}/opam +9 -10
- binaryen-archive/esy.lock/opam/menhir.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/menhirLib.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/menhirSdk.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.12.2 → ocaml-lsp-server.1.12.4}/opam +7 -6
- binaryen-archive/esy.lock/opam/{ocaml-version.3.4.0 → ocaml-version.3.5.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlbuild.0.14.1 → ocamlbuild.0.14.2}/opam +3 -3
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/files/0001-Fix-bug-when-installing-with-a-system-compiler.patch +26 -0
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/opam +2 -0
- binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.22.4 → ocamlformat-rpc-lib.0.24.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlformat.0.20.1 → ocamlformat.0.24.1}/opam +12 -12
- binaryen-archive/esy.lock/opam/{odoc-parser.1.0.0 → odoc-parser.2.0.0}/opam +6 -5
- binaryen-archive/esy.lock/opam/omd.1.3.2/opam +50 -0
- binaryen-archive/esy.lock/opam/{ordering.3.3.1 → ordering.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{ppxlib.0.27.0 → ppxlib.0.28.0}/opam +5 -5
- binaryen-archive/esy.lock/opam/{sexplib0.v0.14.0 → sexplib0.v0.15.1}/opam +3 -3
- binaryen-archive/esy.lock/opam/{stdio.v0.14.0 → stdio.v0.15.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{stdune.3.3.1 → stdune.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{topkg.1.0.5 → topkg.1.0.6}/opam +22 -19
- binaryen-archive/esy.lock/opam/uucp.15.0.0/opam +55 -0
- binaryen-archive/esy.lock/opam/{uuseg.14.0.0 → uuseg.15.0.0}/opam +39 -25
- binaryen-archive/esy.lock/opam/{xdg.3.3.1 → xdg.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{yojson.2.0.0 → yojson.2.0.2}/opam +5 -5
- 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
- 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
- binaryen-archive/package.json +8 -8
- binaryen-archive/src/binaryen_stubs_expressions.c +43 -33
- binaryen-archive/src/binaryen_stubs_expressions.js +221 -42
- binaryen-archive/src/binaryen_stubs_features.c +6 -0
- binaryen-archive/src/binaryen_stubs_features.js +6 -0
- binaryen-archive/src/binaryen_stubs_heap_types.c +95 -0
- binaryen-archive/src/binaryen_stubs_heap_types.js +65 -0
- binaryen-archive/src/binaryen_stubs_imports.c +16 -0
- binaryen-archive/src/binaryen_stubs_imports.js +14 -0
- binaryen-archive/src/binaryen_stubs_memory.c +83 -4
- binaryen-archive/src/binaryen_stubs_memory.js +95 -5
- binaryen-archive/src/binaryen_stubs_modules.c +22 -0
- binaryen-archive/src/binaryen_stubs_modules.js +17 -0
- binaryen-archive/src/binaryen_stubs_packed_types.c +26 -0
- binaryen-archive/src/binaryen_stubs_packed_types.js +17 -0
- binaryen-archive/src/binaryen_stubs_type_system.c +40 -0
- binaryen-archive/src/binaryen_stubs_type_system.js +29 -0
- binaryen-archive/src/binaryen_stubs_types.c +44 -0
- binaryen-archive/src/binaryen_stubs_types.js +36 -0
- binaryen-archive/src/dune +35 -12
- binaryen-archive/src/expression.ml +21 -24
- binaryen-archive/src/expression.mli +9 -9
- binaryen-archive/src/heap_type.ml +15 -0
- binaryen-archive/src/heap_type.mli +12 -0
- binaryen-archive/src/import.ml +6 -0
- binaryen-archive/src/import.mli +2 -0
- binaryen-archive/src/memory.ml +24 -0
- binaryen-archive/src/memory.mli +10 -1
- binaryen-archive/src/module.ml +12 -0
- binaryen-archive/src/module.mli +3 -0
- binaryen-archive/src/ocaml_helpers.h +1 -0
- binaryen-archive/src/packed_type.ml +13 -0
- binaryen-archive/src/packed_type.mli +5 -0
- binaryen-archive/src/passes.ml +6 -0
- binaryen-archive/src/passes.mli +6 -0
- binaryen-archive/src/type.ml +19 -0
- binaryen-archive/src/type.mli +7 -0
- binaryen-archive/src/type_system.ml +7 -0
- binaryen-archive/src/type_system.mli +7 -0
- binaryen-archive/test/dune +19 -20
- binaryen-archive/test/test.expected +64 -4
- binaryen-archive/test/test.ml +49 -5
- binaryen-archive/esy.lock/opam/omd.1.3.1/opam +0 -39
- binaryen-archive/esy.lock/opam/uucp.14.0.0/opam +0 -41
- binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
|
@@ -173,16 +173,88 @@ function caml_binaryen_global_set(wasm_mod, name, value) {
|
|
|
173
173
|
|
|
174
174
|
//Provides: caml_binaryen_load
|
|
175
175
|
//Requires: Binaryen
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
//Requires: caml_jsstring_of_string
|
|
177
|
+
//Requires: caml_failwith
|
|
178
|
+
function caml_binaryen_load(
|
|
179
|
+
wasm_mod,
|
|
180
|
+
bytes,
|
|
181
|
+
signed,
|
|
182
|
+
offset,
|
|
183
|
+
align,
|
|
184
|
+
typ,
|
|
185
|
+
ptr,
|
|
186
|
+
memoryName
|
|
187
|
+
) {
|
|
188
|
+
var name = caml_jsstring_of_string(memoryName);
|
|
189
|
+
|
|
190
|
+
switch (typ) {
|
|
191
|
+
case Binaryen.i32: {
|
|
192
|
+
if (signed) {
|
|
193
|
+
if (bytes === 4) {
|
|
194
|
+
return wasm_mod.i32.load(offset, align, ptr, name);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (bytes === 1) {
|
|
198
|
+
return wasm_mod.i32.load8_s(offset, align, ptr, name);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (bytes === 2) {
|
|
202
|
+
return wasm_mod.i32.load16_s(offset, align, ptr, name);
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
if (bytes === 1) {
|
|
206
|
+
return wasm_mod.i32.load8_u(offset, align, ptr, name);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (bytes === 2) {
|
|
210
|
+
return wasm_mod.i32.load16_u(offset, align, ptr, name);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
case Binaryen.i64: {
|
|
215
|
+
if (signed) {
|
|
216
|
+
if (bytes === 8) {
|
|
217
|
+
return wasm_mod.i64.load(offset, align, ptr, name);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (bytes === 1) {
|
|
221
|
+
return wasm_mod.i64.load8_s(offset, align, ptr, name);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (bytes === 2) {
|
|
225
|
+
return wasm_mod.i64.load16_s(offset, align, ptr, name);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (bytes === 4) {
|
|
229
|
+
return wasm_mod.i64.load32_s(offset, align, ptr, name);
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
if (bytes === 1) {
|
|
233
|
+
return wasm_mod.i64.load8_u(offset, align, ptr, name);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (bytes === 2) {
|
|
237
|
+
return wasm_mod.i64.load16_u(offset, align, ptr, name);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (bytes === 4) {
|
|
241
|
+
return wasm_mod.i64.load32_u(offset, align, ptr, name);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
case Binaryen.f32: {
|
|
246
|
+
return wasm_mod.f32.load(offset, align, ptr, name);
|
|
247
|
+
}
|
|
248
|
+
case Binaryen.f64: {
|
|
249
|
+
return wasm_mod.f64.load(offset, align, ptr, name);
|
|
250
|
+
}
|
|
251
|
+
case Binaryen.v128: {
|
|
252
|
+
return wasm_mod.v128.load(offset, align, ptr, name);
|
|
253
|
+
}
|
|
254
|
+
default: {
|
|
255
|
+
caml_failwith("Invalid arguments to BinaryenLoad");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
186
258
|
}
|
|
187
259
|
//Provides: caml_binaryen_load__bytecode
|
|
188
260
|
//Requires: caml_binaryen_load
|
|
@@ -194,22 +266,71 @@ function caml_binaryen_load__bytecode() {
|
|
|
194
266
|
arguments[3],
|
|
195
267
|
arguments[4],
|
|
196
268
|
arguments[5],
|
|
197
|
-
arguments[6]
|
|
269
|
+
arguments[6],
|
|
270
|
+
arguments[7]
|
|
198
271
|
);
|
|
199
272
|
}
|
|
200
273
|
|
|
201
274
|
//Provides: caml_binaryen_store
|
|
202
275
|
//Requires: Binaryen
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
276
|
+
//Requires: caml_jsstring_of_string
|
|
277
|
+
//Requires: caml_failwith
|
|
278
|
+
function caml_binaryen_store(
|
|
279
|
+
wasm_mod,
|
|
280
|
+
bytes,
|
|
281
|
+
offset,
|
|
282
|
+
align,
|
|
283
|
+
ptr,
|
|
284
|
+
value,
|
|
285
|
+
typ,
|
|
286
|
+
memoryName
|
|
287
|
+
) {
|
|
288
|
+
var name = caml_jsstring_of_string(memoryName);
|
|
289
|
+
|
|
290
|
+
switch (typ) {
|
|
291
|
+
case Binaryen.i32: {
|
|
292
|
+
if (bytes === 4) {
|
|
293
|
+
return wasm_mod.i32.store(offset, align, ptr, value, name);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (bytes === 1) {
|
|
297
|
+
return wasm_mod.i32.store8(offset, align, ptr, value, name);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (bytes === 2) {
|
|
301
|
+
return wasm_mod.i32.store16(offset, align, ptr, value, name);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
case Binaryen.i64: {
|
|
305
|
+
if (bytes === 8) {
|
|
306
|
+
return wasm_mod.i64.store(offset, align, ptr, value, name);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (bytes === 1) {
|
|
310
|
+
return wasm_mod.i64.store8(offset, align, ptr, value, name);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (bytes === 2) {
|
|
314
|
+
return wasm_mod.i64.store16(offset, align, ptr, value, name);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (bytes === 4) {
|
|
318
|
+
return wasm_mod.i64.store32(offset, align, ptr, value, name);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
case Binaryen.f32: {
|
|
322
|
+
return wasm_mod.f32.store(offset, align, ptr, value, name);
|
|
323
|
+
}
|
|
324
|
+
case Binaryen.f64: {
|
|
325
|
+
return wasm_mod.f64.store(offset, align, ptr, value, name);
|
|
326
|
+
}
|
|
327
|
+
case Binaryen.v128: {
|
|
328
|
+
return wasm_mod.v128.store(offset, align, ptr, value, name);
|
|
329
|
+
}
|
|
330
|
+
default: {
|
|
331
|
+
caml_failwith("Invalid arguments to BinaryenStore");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
213
334
|
}
|
|
214
335
|
//Provides: caml_binaryen_store__bytecode
|
|
215
336
|
//Requires: caml_binaryen_store
|
|
@@ -221,7 +342,8 @@ function caml_binaryen_store__bytecode() {
|
|
|
221
342
|
arguments[3],
|
|
222
343
|
arguments[4],
|
|
223
344
|
arguments[5],
|
|
224
|
-
arguments[6]
|
|
345
|
+
arguments[6],
|
|
346
|
+
arguments[7]
|
|
225
347
|
);
|
|
226
348
|
}
|
|
227
349
|
|
|
@@ -286,13 +408,22 @@ function caml_binaryen_return(wasm_mod, value) {
|
|
|
286
408
|
}
|
|
287
409
|
|
|
288
410
|
//Provides: caml_binaryen_memory_size
|
|
289
|
-
|
|
290
|
-
|
|
411
|
+
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
412
|
+
function caml_binaryen_memory_size(wasm_mod, memoryName, memoryIs64) {
|
|
413
|
+
return wasm_mod.memory.size(
|
|
414
|
+
caml_jsstring_of_string(memoryName),
|
|
415
|
+
caml_js_from_bool(memoryIs64)
|
|
416
|
+
);
|
|
291
417
|
}
|
|
292
418
|
|
|
293
419
|
//Provides: caml_binaryen_memory_grow
|
|
294
|
-
|
|
295
|
-
|
|
420
|
+
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
421
|
+
function caml_binaryen_memory_grow(wasm_mod, value, memoryName, memoryIs64) {
|
|
422
|
+
return wasm_mod.memory.grow(
|
|
423
|
+
value,
|
|
424
|
+
caml_jsstring_of_string(memoryName),
|
|
425
|
+
caml_js_from_bool(memoryIs64)
|
|
426
|
+
);
|
|
296
427
|
}
|
|
297
428
|
|
|
298
429
|
//Provides: caml_binaryen_nop
|
|
@@ -306,8 +437,34 @@ function caml_binaryen_unreachable(wasm_mod) {
|
|
|
306
437
|
}
|
|
307
438
|
|
|
308
439
|
//Provides: caml_binaryen_memory_init
|
|
309
|
-
|
|
310
|
-
|
|
440
|
+
//Requires: caml_jsstring_of_string
|
|
441
|
+
function caml_binaryen_memory_init(
|
|
442
|
+
wasm_mod,
|
|
443
|
+
segment,
|
|
444
|
+
dest,
|
|
445
|
+
offset,
|
|
446
|
+
size,
|
|
447
|
+
memoryName
|
|
448
|
+
) {
|
|
449
|
+
return wasm_mod.memory.init(
|
|
450
|
+
segment,
|
|
451
|
+
dest,
|
|
452
|
+
offset,
|
|
453
|
+
size,
|
|
454
|
+
caml_jsstring_of_string(memoryName)
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
//Provides: caml_binaryen_memory_init__bytecode
|
|
458
|
+
//Requires: caml_binaryen_memory_init
|
|
459
|
+
function caml_binaryen_memory_init__bytecode() {
|
|
460
|
+
return caml_binaryen_memory_init(
|
|
461
|
+
arguments[0],
|
|
462
|
+
arguments[1],
|
|
463
|
+
arguments[2],
|
|
464
|
+
arguments[3],
|
|
465
|
+
arguments[4],
|
|
466
|
+
arguments[5]
|
|
467
|
+
);
|
|
311
468
|
}
|
|
312
469
|
|
|
313
470
|
//Provides: caml_binaryen_data_drop
|
|
@@ -316,13 +473,45 @@ function caml_binaryen_data_drop(wasm_mod, segment) {
|
|
|
316
473
|
}
|
|
317
474
|
|
|
318
475
|
//Provides: caml_binaryen_memory_copy
|
|
319
|
-
|
|
320
|
-
|
|
476
|
+
//Requires: caml_jsstring_of_string
|
|
477
|
+
function caml_binaryen_memory_copy(
|
|
478
|
+
wasm_mod,
|
|
479
|
+
dest,
|
|
480
|
+
source,
|
|
481
|
+
size,
|
|
482
|
+
dest_memory,
|
|
483
|
+
source_memory
|
|
484
|
+
) {
|
|
485
|
+
return wasm_mod.memory.copy(
|
|
486
|
+
dest,
|
|
487
|
+
source,
|
|
488
|
+
size,
|
|
489
|
+
caml_jsstring_of_string(dest_memory),
|
|
490
|
+
caml_jsstring_of_string(source_memory)
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
//Provides: caml_binaryen_memory_copy__bytecode
|
|
494
|
+
//Requires: caml_binaryen_memory_copy
|
|
495
|
+
function caml_binaryen_memory_copy__bytecode() {
|
|
496
|
+
return caml_binaryen_memory_copy(
|
|
497
|
+
arguments[0],
|
|
498
|
+
arguments[1],
|
|
499
|
+
arguments[2],
|
|
500
|
+
arguments[3],
|
|
501
|
+
arguments[4],
|
|
502
|
+
arguments[5]
|
|
503
|
+
);
|
|
321
504
|
}
|
|
322
505
|
|
|
323
506
|
//Provides: caml_binaryen_memory_fill
|
|
324
|
-
|
|
325
|
-
|
|
507
|
+
//Requires: caml_jsstring_of_string
|
|
508
|
+
function caml_binaryen_memory_fill(wasm_mod, dest, value, size, memoryName) {
|
|
509
|
+
return wasm_mod.memory.fill(
|
|
510
|
+
dest,
|
|
511
|
+
value,
|
|
512
|
+
size,
|
|
513
|
+
caml_jsstring_of_string(memoryName)
|
|
514
|
+
);
|
|
326
515
|
}
|
|
327
516
|
|
|
328
517
|
//Provides: caml_binaryen_tuple_make
|
|
@@ -628,16 +817,6 @@ function caml_binaryen_expression_id_ref_cast() {
|
|
|
628
817
|
function caml_binaryen_expression_id_br_on() {
|
|
629
818
|
return Binaryen.BrOnId;
|
|
630
819
|
}
|
|
631
|
-
//Provides: caml_binaryen_expression_id_rtt_canon
|
|
632
|
-
//Requires: Binaryen
|
|
633
|
-
function caml_binaryen_expression_id_rtt_canon() {
|
|
634
|
-
return Binaryen.RttCanonId;
|
|
635
|
-
}
|
|
636
|
-
//Provides: caml_binaryen_expression_id_rtt_sub
|
|
637
|
-
//Requires: Binaryen
|
|
638
|
-
function caml_binaryen_expression_id_rtt_sub() {
|
|
639
|
-
return Binaryen.RttSubId;
|
|
640
|
-
}
|
|
641
820
|
//Provides: caml_binaryen_expression_id_struct_new
|
|
642
821
|
//Requires: Binaryen
|
|
643
822
|
function caml_binaryen_expression_id_struct_new() {
|
|
@@ -119,6 +119,12 @@ caml_binaryen_feature_extended_const(value unit) {
|
|
|
119
119
|
CAMLreturn(Val_int(BinaryenFeatureExtendedConst()));
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
CAMLprim value
|
|
123
|
+
caml_binaryen_feature_strings(value unit) {
|
|
124
|
+
CAMLparam1(unit);
|
|
125
|
+
CAMLreturn(Val_int(BinaryenFeatureStrings()));
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
CAMLprim value
|
|
123
129
|
caml_binaryen_feature_all(value unit) {
|
|
124
130
|
CAMLparam1(unit);
|
|
@@ -104,6 +104,12 @@ function caml_binaryen_feature_extended_const() {
|
|
|
104
104
|
return Binaryen.Features.ExtendedConst;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
//Provides: caml_binaryen_feature_strings
|
|
108
|
+
//Requires: Binaryen
|
|
109
|
+
function caml_binaryen_feature_strings() {
|
|
110
|
+
return Binaryen.Features.Strings;
|
|
111
|
+
}
|
|
112
|
+
|
|
107
113
|
//Provides: caml_binaryen_feature_all
|
|
108
114
|
//Requires: Binaryen
|
|
109
115
|
function caml_binaryen_feature_all() {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#define CAML_NAME_SPACE
|
|
2
|
+
#include <caml/mlvalues.h>
|
|
3
|
+
#include <caml/fail.h>
|
|
4
|
+
#include <caml/memory.h>
|
|
5
|
+
|
|
6
|
+
#include "binaryen-c.h"
|
|
7
|
+
#include "ocaml_helpers.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/* Allocating an OCaml custom block to hold the given BinaryenHeapType */
|
|
11
|
+
static value alloc_BinaryenHeapType(BinaryenHeapType typ)
|
|
12
|
+
{
|
|
13
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenHeapType), 0, 1);
|
|
14
|
+
BinaryenHeapType_val(v) = typ;
|
|
15
|
+
return v;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
CAMLprim value
|
|
20
|
+
caml_binaryen_heap_type_ext(value unit) {
|
|
21
|
+
CAMLparam1(unit);
|
|
22
|
+
BinaryenHeapType ty = BinaryenHeapTypeExt();
|
|
23
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
CAMLprim value
|
|
27
|
+
caml_binaryen_heap_type_func(value unit) {
|
|
28
|
+
CAMLparam1(unit);
|
|
29
|
+
BinaryenHeapType ty = BinaryenHeapTypeFunc();
|
|
30
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
CAMLprim value
|
|
34
|
+
caml_binaryen_heap_type_any(value unit) {
|
|
35
|
+
CAMLparam1(unit);
|
|
36
|
+
BinaryenHeapType ty = BinaryenHeapTypeAny();
|
|
37
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
CAMLprim value
|
|
41
|
+
caml_binaryen_heap_type_eq(value unit) {
|
|
42
|
+
CAMLparam1(unit);
|
|
43
|
+
BinaryenHeapType ty = BinaryenHeapTypeEq();
|
|
44
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
CAMLprim value
|
|
48
|
+
caml_binaryen_heap_type_i31(value unit) {
|
|
49
|
+
CAMLparam1(unit);
|
|
50
|
+
BinaryenHeapType ty = BinaryenHeapTypeI31();
|
|
51
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
CAMLprim value
|
|
55
|
+
caml_binaryen_heap_type_data(value unit) {
|
|
56
|
+
CAMLparam1(unit);
|
|
57
|
+
BinaryenHeapType ty = BinaryenHeapTypeData();
|
|
58
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
CAMLprim value
|
|
62
|
+
caml_binaryen_heap_type_string(value unit) {
|
|
63
|
+
CAMLparam1(unit);
|
|
64
|
+
BinaryenHeapType ty = BinaryenHeapTypeString();
|
|
65
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
CAMLprim value
|
|
69
|
+
caml_binaryen_heap_type_stringview_wtf8(value unit) {
|
|
70
|
+
CAMLparam1(unit);
|
|
71
|
+
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF8();
|
|
72
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
CAMLprim value
|
|
76
|
+
caml_binaryen_heap_type_stringview_wtf16(value unit) {
|
|
77
|
+
CAMLparam1(unit);
|
|
78
|
+
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF16();
|
|
79
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
CAMLprim value
|
|
83
|
+
caml_binaryen_heap_type_stringview_iter(value unit) {
|
|
84
|
+
CAMLparam1(unit);
|
|
85
|
+
BinaryenHeapType ty = BinaryenHeapTypeStringviewIter();
|
|
86
|
+
CAMLreturn(alloc_BinaryenHeapType(ty));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
CAMLprim value
|
|
90
|
+
caml_binaryen_type_get_heap_type(value _ty) {
|
|
91
|
+
CAMLparam1(_ty);
|
|
92
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
93
|
+
BinaryenHeapType heapTy = BinaryenTypeGetHeapType(ty);
|
|
94
|
+
CAMLreturn(alloc_BinaryenHeapType(heapTy));
|
|
95
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//Provides: caml_binaryen_heap_type_ext
|
|
2
|
+
//Requires: Binaryen
|
|
3
|
+
function caml_binaryen_heap_type_ext() {
|
|
4
|
+
return Binaryen._BinaryenHeapTypeExt();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_heap_type_func
|
|
8
|
+
//Requires: Binaryen
|
|
9
|
+
function caml_binaryen_heap_type_func() {
|
|
10
|
+
return Binaryen._BinaryenHeapTypeFunc();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_heap_type_any
|
|
14
|
+
//Requires: Binaryen
|
|
15
|
+
function caml_binaryen_heap_type_any() {
|
|
16
|
+
return Binaryen._BinaryenHeapTypeAny();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Provides: caml_binaryen_heap_type_eq
|
|
20
|
+
//Requires: Binaryen
|
|
21
|
+
function caml_binaryen_heap_type_eq() {
|
|
22
|
+
return Binaryen._BinaryenHeapTypeEq();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//Provides: caml_binaryen_heap_type_i31
|
|
26
|
+
//Requires: Binaryen
|
|
27
|
+
function caml_binaryen_heap_type_i31() {
|
|
28
|
+
return Binaryen._BinaryenHeapTypeI31();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//Provides: caml_binaryen_heap_type_data
|
|
32
|
+
//Requires: Binaryen
|
|
33
|
+
function caml_binaryen_heap_type_data() {
|
|
34
|
+
return Binaryen._BinaryenHeapTypeData();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//Provides: caml_binaryen_heap_type_string
|
|
38
|
+
//Requires: Binaryen
|
|
39
|
+
function caml_binaryen_heap_type_string() {
|
|
40
|
+
return Binaryen._BinaryenHeapTypeString();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//Provides: caml_binaryen_heap_type_stringview_wtf8
|
|
44
|
+
//Requires: Binaryen
|
|
45
|
+
function caml_binaryen_heap_type_stringview_wtf8() {
|
|
46
|
+
return Binaryen._BinaryenHeapTypeStringviewWTF8();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//Provides: caml_binaryen_heap_type_stringview_wtf16
|
|
50
|
+
//Requires: Binaryen
|
|
51
|
+
function caml_binaryen_heap_type_stringview_wtf16() {
|
|
52
|
+
return Binaryen._BinaryenHeapTypeStringviewWTF16();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//Provides: caml_binaryen_heap_type_stringview_iter
|
|
56
|
+
//Requires: Binaryen
|
|
57
|
+
function caml_binaryen_heap_type_stringview_iter() {
|
|
58
|
+
return Binaryen._BinaryenHeapTypeStringviewIter();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//Provides: caml_binaryen_type_get_heap_type
|
|
62
|
+
//Requires: Binaryen
|
|
63
|
+
function caml_binaryen_type_get_heap_type(typ) {
|
|
64
|
+
return Binaryen._BinaryenTypeGetHeapType(typ);
|
|
65
|
+
}
|
|
@@ -74,6 +74,14 @@ caml_binaryen_function_import_get_module(value _fun) {
|
|
|
74
74
|
CAMLreturn(caml_copy_string(BinaryenFunctionImportGetModule(fun)));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
CAMLprim value
|
|
78
|
+
caml_binaryen_memory_import_get_module(value _module, value _memoryName) {
|
|
79
|
+
CAMLparam2(_module, _memoryName);
|
|
80
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
81
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
82
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetModule(module, memoryName)));
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
CAMLprim value
|
|
78
86
|
caml_binaryen_global_import_get_module(value _global) {
|
|
79
87
|
CAMLparam1(_global);
|
|
@@ -88,6 +96,14 @@ caml_binaryen_function_import_get_base(value _fun) {
|
|
|
88
96
|
CAMLreturn(caml_copy_string(BinaryenFunctionImportGetBase(fun)));
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
CAMLprim value
|
|
100
|
+
caml_binaryen_memory_import_get_base(value _module, value _memoryName) {
|
|
101
|
+
CAMLparam2(_module, _memoryName);
|
|
102
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
103
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
104
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetBase(module, memoryName)));
|
|
105
|
+
}
|
|
106
|
+
|
|
91
107
|
CAMLprim value
|
|
92
108
|
caml_binaryen_global_import_get_base(value _global) {
|
|
93
109
|
CAMLparam1(_global);
|
|
@@ -100,6 +100,13 @@ function caml_binaryen_function_import_get_module(func) {
|
|
|
100
100
|
return caml_string_of_jsstring(func_info.module);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
//Provides: caml_binaryen_memory_import_get_module
|
|
104
|
+
//Requires: caml_string_of_jsstring, caml_jsstring_of_string
|
|
105
|
+
function caml_binaryen_memory_import_get_module(mod, memoryName) {
|
|
106
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
107
|
+
return caml_string_of_jsstring(memory_info.module);
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
//Provides: caml_binaryen_global_import_get_module
|
|
104
111
|
//Requires: Binaryen
|
|
105
112
|
//Requires: caml_string_of_jsstring
|
|
@@ -116,6 +123,13 @@ function caml_binaryen_function_import_get_base(func) {
|
|
|
116
123
|
return caml_string_of_jsstring(func_info.base);
|
|
117
124
|
}
|
|
118
125
|
|
|
126
|
+
//Provides: caml_binaryen_memory_import_get_base
|
|
127
|
+
//Requires: caml_string_of_jsstring, caml_jsstring_of_string
|
|
128
|
+
function caml_binaryen_memory_import_get_base(mod, memoryName) {
|
|
129
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
130
|
+
return caml_string_of_jsstring(memory_info.base);
|
|
131
|
+
}
|
|
132
|
+
|
|
119
133
|
//Provides: caml_binaryen_global_import_get_base
|
|
120
134
|
//Requires: Binaryen
|
|
121
135
|
//Requires: caml_string_of_jsstring
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
CAMLprim value
|
|
11
|
-
caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value _segments, value _segmentPassive, value _segmentOffsets, value _segmentSizes, value _shared) {
|
|
11
|
+
caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _exportName, value _segments, value _segmentPassive, value _segmentOffsets, value _segmentSizes, value _shared, value _memoryName) {
|
|
12
12
|
CAMLparam5(_module, _initial, _maximum, _exportName, _segments);
|
|
13
|
-
|
|
13
|
+
CAMLxparam5(_segmentPassive, _segmentOffsets, _segmentSizes, _shared, _memoryName);
|
|
14
14
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
15
15
|
BinaryenIndex initial = Int_val(_initial);
|
|
16
16
|
BinaryenIndex maximum = Int_val(_maximum);
|
|
@@ -40,10 +40,89 @@ caml_binaryen_set_memory(value _module, value _initial, value _maximum, value _e
|
|
|
40
40
|
segmentSizes[i] = Int_val(Field(_segmentSizes, i));
|
|
41
41
|
}
|
|
42
42
|
uint8_t shared = Bool_val(_shared);
|
|
43
|
-
|
|
43
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
44
|
+
BinaryenSetMemory(module, initial, maximum, exportName, segments, segmentPassive, segmentOffsets, segmentSizes, segmentsLen, shared, memoryName);
|
|
44
45
|
CAMLreturn(Val_unit);
|
|
45
46
|
}
|
|
46
47
|
CAMLprim value
|
|
47
48
|
caml_binaryen_set_memory__bytecode(value * argv) {
|
|
48
|
-
return caml_binaryen_set_memory(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]);
|
|
49
|
+
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]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
CAMLprim value
|
|
53
|
+
caml_binaryen_has_memory(value _module) {
|
|
54
|
+
CAMLparam1(_module);
|
|
55
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
56
|
+
CAMLreturn(Val_bool(BinaryenHasMemory(module)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
CAMLprim value
|
|
60
|
+
caml_binaryen_memory_get_initial(value _module, value _memoryName) {
|
|
61
|
+
CAMLparam2(_module, _memoryName);
|
|
62
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
63
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
64
|
+
CAMLreturn(Val_int(BinaryenMemoryGetInitial(module, memoryName)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
CAMLprim value
|
|
68
|
+
caml_binaryen_memory_has_max(value _module, value _memoryName) {
|
|
69
|
+
CAMLparam2(_module, _memoryName);
|
|
70
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
71
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
72
|
+
CAMLreturn(Val_bool(BinaryenMemoryHasMax(module, memoryName)));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
CAMLprim value
|
|
76
|
+
caml_binaryen_memory_get_max(value _module, value _memoryName) {
|
|
77
|
+
CAMLparam2(_module, _memoryName);
|
|
78
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
79
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
80
|
+
if (BinaryenMemoryHasMax(module, memoryName)) {
|
|
81
|
+
CAMLreturn(Val_int(BinaryenMemoryGetMax(module, memoryName)));
|
|
82
|
+
} else {
|
|
83
|
+
// This ensures that our return is equal to Memory.unlimited
|
|
84
|
+
CAMLreturn(Val_int(-1));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
CAMLprim value
|
|
89
|
+
caml_binaryen_memory_is_shared(value _module, value _memoryName) {
|
|
90
|
+
CAMLparam2(_module, _memoryName);
|
|
91
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
92
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
93
|
+
CAMLreturn(Val_bool(BinaryenMemoryIsShared(module, memoryName)));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
CAMLprim value
|
|
97
|
+
caml_binaryen_get_num_memory_segments(value _module) {
|
|
98
|
+
CAMLparam1(_module);
|
|
99
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
100
|
+
CAMLreturn(Val_int(BinaryenGetNumMemorySegments(module)));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
CAMLprim value
|
|
104
|
+
caml_binaryen_get_memory_segment_byte_offset(value _module, value _id) {
|
|
105
|
+
CAMLparam2(_module, _id);
|
|
106
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
107
|
+
BinaryenIndex id = Int_val(_id);
|
|
108
|
+
CAMLreturn(Val_int(BinaryenGetMemorySegmentByteOffset(module, id)));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
CAMLprim value
|
|
112
|
+
caml_binaryen_get_memory_segment_passive(value _module, value _id) {
|
|
113
|
+
CAMLparam2(_module, _id);
|
|
114
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
115
|
+
BinaryenIndex id = Int_val(_id);
|
|
116
|
+
CAMLreturn(Val_bool(BinaryenGetMemorySegmentPassive(module, id)));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
CAMLprim value
|
|
120
|
+
caml_binaryen_get_memory_segment_data(value _module, value _id) {
|
|
121
|
+
CAMLparam2(_module, _id);
|
|
122
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
123
|
+
BinaryenIndex id = Int_val(_id);
|
|
124
|
+
size_t size = BinaryenGetMemorySegmentByteLength(module, id);
|
|
125
|
+
CAMLprim value bytes = caml_alloc_string(size);
|
|
126
|
+
BinaryenCopyMemorySegmentData(module, id, (char*)Bytes_val(bytes));
|
|
127
|
+
CAMLreturn(bytes);
|
|
49
128
|
}
|