@grain/binaryen.ml 0.34.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 +37 -0
- binaryen-archive/binaryen.opam +3 -3
- binaryen-archive/esy.lock/index.json +366 -391
- binaryen-archive/esy.lock/opam/base.v0.17.3/opam +5 -3
- binaryen-archive/esy.lock/opam/{chrome-trace.3.20.2 → 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.20.2 → dune-build-info.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune-configurator.3.20.2 → dune-configurator.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune.3.20.2 → dune.3.24.2}/opam +15 -10
- 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/{menhir.20250912 → menhir.20260209}/opam +6 -4
- binaryen-archive/esy.lock/opam/{menhirCST.20250912 → menhirCST.20260209}/opam +4 -3
- binaryen-archive/esy.lock/opam/menhirGLR.20260209/opam +30 -0
- binaryen-archive/esy.lock/opam/{menhirLib.20250912 → menhirLib.20260209}/opam +5 -4
- binaryen-archive/esy.lock/opam/{menhirSdk.20250912 → menhirSdk.20260209}/opam +5 -4
- 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 -3
- binaryen-archive/esy.lock/opam/ocamlbuild.0.16.1/opam +1 -0
- 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/ppx_yojson_conv_lib.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/{ppxlib.0.37.0 → ppxlib.0.39.0~5.6preview}/opam +12 -13
- binaryen-archive/esy.lock/opam/sexplib0.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/stdio.v0.17.0/opam +3 -1
- binaryen-archive/esy.lock/opam/{xdg.3.20.2 → xdg.3.24.2}/opam +6 -8
- binaryen-archive/package.json +9 -5
- binaryen-archive/src/dune +6 -1
- binaryen-archive/src/export.c +10 -0
- binaryen-archive/src/export.js +13 -0
- binaryen-archive/src/export.ml +4 -0
- binaryen-archive/src/export.mli +1 -0
- binaryen-archive/src/expression.c +636 -0
- binaryen-archive/src/expression.js +423 -7
- binaryen-archive/src/expression.ml +224 -0
- binaryen-archive/src/expression.mli +159 -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/import.c +32 -0
- binaryen-archive/src/import.js +47 -0
- binaryen-archive/src/import.ml +12 -0
- binaryen-archive/src/import.mli +5 -0
- 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 +9 -22
- 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 +17 -0
- binaryen-archive/src/ocaml_helpers.h +9 -0
- binaryen-archive/src/ocaml_helpers.js +11 -0
- binaryen-archive/src/passes.ml +13 -11
- binaryen-archive/src/passes.mli +13 -11
- binaryen-archive/src/tag.c +61 -0
- binaryen-archive/src/tag.js +43 -0
- binaryen-archive/src/tag.ml +11 -0
- binaryen-archive/src/tag.mli +8 -0
- binaryen-archive/src/type.c +5 -3
- binaryen-archive/src/type.js +5 -9
- 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 +323 -33
- binaryen-archive/test/test.ml +220 -4
- binaryen-archive/esy.lock/opam/base-bytes.base/opam +0 -10
- 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
|
@@ -161,6 +161,21 @@ module Call_indirect : sig
|
|
|
161
161
|
val set_return : t -> bool -> unit
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
+
module Call_ref : sig
|
|
165
|
+
val make : Module.t -> t -> t list -> Type.t -> t
|
|
166
|
+
val make_return : Module.t -> t -> t list -> Type.t -> t
|
|
167
|
+
val get_target : t -> t
|
|
168
|
+
val set_target : t -> t -> unit
|
|
169
|
+
val get_num_operands : t -> int
|
|
170
|
+
val get_operand_at : t -> int -> t
|
|
171
|
+
val set_operand_at : t -> int -> t -> unit
|
|
172
|
+
val append_operand : t -> t -> int
|
|
173
|
+
val insert_operand_at : t -> int -> t -> unit
|
|
174
|
+
val remove_operand_at : t -> int -> t
|
|
175
|
+
val is_return : t -> bool
|
|
176
|
+
val set_return : t -> bool -> unit
|
|
177
|
+
end
|
|
178
|
+
|
|
164
179
|
module Local_get : sig
|
|
165
180
|
val make : Module.t -> int -> Type.t -> t
|
|
166
181
|
end
|
|
@@ -348,6 +363,150 @@ module Ref : sig
|
|
|
348
363
|
|
|
349
364
|
val eq : Module.t -> t -> t -> t
|
|
350
365
|
(** Module, left, right *)
|
|
366
|
+
|
|
367
|
+
val test : Module.t -> t -> Type.t -> t
|
|
368
|
+
(** Module, value, type *)
|
|
369
|
+
|
|
370
|
+
val cast : Module.t -> t -> Type.t -> t
|
|
371
|
+
(** Module, value, type *)
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
module BrOn : sig
|
|
375
|
+
val make : Module.t -> Op.t -> string -> t -> Type.t -> t
|
|
376
|
+
(** Module, op, label, value, type *)
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
module Struct : sig
|
|
380
|
+
val new_ : Module.t -> t list option -> Heap_type.t -> t
|
|
381
|
+
(** Mdoule, operands, type *)
|
|
382
|
+
|
|
383
|
+
val get : Module.t -> int -> t -> Type.t -> bool -> t
|
|
384
|
+
(** Module, index, struct, type, signed *)
|
|
385
|
+
|
|
386
|
+
val set : Module.t -> int -> t -> t -> t
|
|
387
|
+
(** Module, index, struct, value *)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
module Array : sig
|
|
391
|
+
val new_ : Module.t -> Heap_type.t -> t -> t -> t
|
|
392
|
+
(** Module, type, size, init *)
|
|
393
|
+
|
|
394
|
+
val new_data : Module.t -> Heap_type.t -> string -> t -> t -> t
|
|
395
|
+
(** Module, type, data name, offset, size *)
|
|
396
|
+
|
|
397
|
+
val new_elem : Module.t -> Heap_type.t -> string -> t -> t -> t
|
|
398
|
+
(** Module, type, seg, offset, size *)
|
|
399
|
+
|
|
400
|
+
val new_fixed : Module.t -> Heap_type.t -> t list -> t
|
|
401
|
+
(** Module, type, values *)
|
|
402
|
+
|
|
403
|
+
val get : Module.t -> t -> t -> Type.t -> bool -> t
|
|
404
|
+
(** Module, array, index, type, signed *)
|
|
405
|
+
|
|
406
|
+
val set : Module.t -> t -> t -> t -> t
|
|
407
|
+
(** Module, array, index, value *)
|
|
408
|
+
|
|
409
|
+
val len : Module.t -> t -> t
|
|
410
|
+
(** Module, array *)
|
|
411
|
+
|
|
412
|
+
val fill : Module.t -> t -> t -> t -> t -> t
|
|
413
|
+
(** Module, array, index, value, offset *)
|
|
414
|
+
|
|
415
|
+
val copy : Module.t -> t -> t -> t -> t -> t -> t
|
|
416
|
+
(** Module, dest, dest index, src, src index, length *)
|
|
417
|
+
|
|
418
|
+
val init_data : Module.t -> string -> t -> t -> t -> t -> t
|
|
419
|
+
(** Module, name, ref, index, offset, size *)
|
|
420
|
+
|
|
421
|
+
val init_elem : Module.t -> string -> t -> t -> t -> t -> t
|
|
422
|
+
(** Module, seg, ref, index, offset, size *)
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
(** Bindings for `try` instruction. *)
|
|
426
|
+
module Try : sig
|
|
427
|
+
val make :
|
|
428
|
+
Module.t -> string option -> t -> (string * t) list -> t option -> t
|
|
429
|
+
(** Module, name, body, catch clauses, catch all *)
|
|
430
|
+
|
|
431
|
+
val get_name : t -> string option
|
|
432
|
+
(** expr *)
|
|
433
|
+
|
|
434
|
+
val set_name : t -> string -> unit
|
|
435
|
+
(** expr, name *)
|
|
436
|
+
|
|
437
|
+
val get_body : t -> t
|
|
438
|
+
(** expr *)
|
|
439
|
+
|
|
440
|
+
val set_body : t -> t -> unit
|
|
441
|
+
(** expr, bodyExpr *)
|
|
442
|
+
|
|
443
|
+
val get_num_catch_tags : t -> int
|
|
444
|
+
(** expr *)
|
|
445
|
+
|
|
446
|
+
val get_num_catch_bodies : t -> int
|
|
447
|
+
(** expr *)
|
|
448
|
+
|
|
449
|
+
val get_catch_tag_at : t -> int -> string
|
|
450
|
+
(** expr, index *)
|
|
451
|
+
|
|
452
|
+
val set_catch_tag_at : t -> int -> string -> unit
|
|
453
|
+
(** expr, index, catchTag *)
|
|
454
|
+
|
|
455
|
+
val append_catch_tag : t -> string -> int
|
|
456
|
+
(** expr, catchTag *)
|
|
457
|
+
|
|
458
|
+
val insert_catch_tag_at : t -> int -> string -> unit
|
|
459
|
+
(** expr, index, catchTag *)
|
|
460
|
+
|
|
461
|
+
val remove_catch_tag_at : t -> int -> string
|
|
462
|
+
(** expr, index *)
|
|
463
|
+
|
|
464
|
+
val get_catch_body_at : t -> int -> t
|
|
465
|
+
(** expr, index *)
|
|
466
|
+
|
|
467
|
+
val set_catch_body_at : t -> int -> t -> unit
|
|
468
|
+
(** expr, index, catchExpr *)
|
|
469
|
+
|
|
470
|
+
val append_catch_body : t -> t -> int
|
|
471
|
+
(** expr, catchExpr *)
|
|
472
|
+
|
|
473
|
+
val insert_catch_body_at : t -> int -> t -> unit
|
|
474
|
+
(** expr, index, catchExpr *)
|
|
475
|
+
|
|
476
|
+
val remove_catch_body_at : t -> int -> t
|
|
477
|
+
(** expr, index *)
|
|
478
|
+
|
|
479
|
+
val has_catch_all : t -> bool
|
|
480
|
+
(** expr *)
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
module Throw : sig
|
|
484
|
+
val make : Module.t -> string -> t list -> t
|
|
485
|
+
(** Module, tag, operands *)
|
|
486
|
+
|
|
487
|
+
val get_tag : t -> string
|
|
488
|
+
(** expr *)
|
|
489
|
+
|
|
490
|
+
val set_tag : t -> string -> unit
|
|
491
|
+
(** expr, tagName *)
|
|
492
|
+
|
|
493
|
+
val get_num_operands : t -> int
|
|
494
|
+
(** expr *)
|
|
495
|
+
|
|
496
|
+
val get_operand_at : t -> int -> t
|
|
497
|
+
(** expr, index *)
|
|
498
|
+
|
|
499
|
+
val set_operand_at : t -> int -> t -> unit
|
|
500
|
+
(** expr, index, operandExpr *)
|
|
501
|
+
|
|
502
|
+
val append_operand : t -> t -> int
|
|
503
|
+
(** expr, operandExpr *)
|
|
504
|
+
|
|
505
|
+
val insert_operand_at : t -> int -> t -> unit
|
|
506
|
+
(** expr, index, operandExpr *)
|
|
507
|
+
|
|
508
|
+
val remove_operand_at : t -> int -> t
|
|
509
|
+
(** expr, index *)
|
|
351
510
|
end
|
|
352
511
|
|
|
353
512
|
module Table : sig
|
binaryen-archive/src/heap_type.c
CHANGED
|
@@ -148,3 +148,22 @@ caml_binaryen_type_get_heap_type(value _ty) {
|
|
|
148
148
|
BinaryenHeapType heapTy = BinaryenTypeGetHeapType(ty);
|
|
149
149
|
CAMLreturn(alloc_BinaryenHeapType(heapTy));
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
CAMLprim value caml_binaryen_module_set_type_name(value _module, value _heapType, value _name) {
|
|
153
|
+
CAMLparam3(_module, _heapType, _name);
|
|
154
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
155
|
+
BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
|
|
156
|
+
const char* name = String_val(_name);
|
|
157
|
+
BinaryenModuleSetTypeName(module, heapType, name);
|
|
158
|
+
CAMLreturn(Val_unit);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
CAMLprim value caml_binaryen_module_set_field_name(value _module, value _heapType, value _index, value _name) {
|
|
162
|
+
CAMLparam4(_module, _heapType, _index, _name);
|
|
163
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
164
|
+
BinaryenHeapType heapType = BinaryenHeapType_val(_heapType);
|
|
165
|
+
BinaryenIndex index = Int_val(_index);
|
|
166
|
+
const char* name = String_val(_name);
|
|
167
|
+
BinaryenModuleSetFieldName(module, heapType, index, name);
|
|
168
|
+
CAMLreturn(Val_unit);
|
|
169
|
+
}
|
|
@@ -111,3 +111,15 @@ function caml_binaryen_heap_type_is_sub_type(left, right) {
|
|
|
111
111
|
function caml_binaryen_type_get_heap_type(typ) {
|
|
112
112
|
return Binaryen._BinaryenTypeGetHeapType(typ);
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
//Provides: caml_binaryen_module_set_type_name
|
|
116
|
+
//Requires: caml_jsstring_of_string
|
|
117
|
+
function caml_binaryen_module_set_type_name(wasm_mod, heapType, name) {
|
|
118
|
+
wasm_mod.setTypeName(heapType, caml_jsstring_of_string(name));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//Provides: caml_binaryen_module_set_field_name
|
|
122
|
+
//Requires: caml_jsstring_of_string
|
|
123
|
+
function caml_binaryen_module_set_field_name(wasm_mod, heapType, index, name) {
|
|
124
|
+
wasm_mod.setFieldName(heapType, index, caml_jsstring_of_string(name));
|
|
125
|
+
}
|
|
@@ -17,4 +17,13 @@ external is_struct : t -> bool = "caml_binaryen_heap_type_is_struct"
|
|
|
17
17
|
external is_array : t -> bool = "caml_binaryen_heap_type_is_array"
|
|
18
18
|
external is_bottom : t -> bool = "caml_binaryen_heap_type_is_bottom"
|
|
19
19
|
external get_bottom : t -> t = "caml_binaryen_heap_type_get_bottom"
|
|
20
|
-
external is_sub_type : t -> bool = "caml_binaryen_heap_type_is_sub_type"
|
|
20
|
+
external is_sub_type : t -> t -> bool = "caml_binaryen_heap_type_is_sub_type"
|
|
21
|
+
|
|
22
|
+
external set_type_name : Module.t -> t -> string -> unit
|
|
23
|
+
= "caml_binaryen_module_set_type_name"
|
|
24
|
+
(** Sets the textual name of a compound `heapType`. Has no effect if the type
|
|
25
|
+
already has a canonical name. *)
|
|
26
|
+
|
|
27
|
+
external set_field_name : Module.t -> t -> int -> string -> unit
|
|
28
|
+
= "caml_binaryen_module_set_field_name"
|
|
29
|
+
(** Sets the field name of a struct `heapType` at index `index`. *)
|
|
@@ -17,4 +17,11 @@ val is_struct : t -> bool
|
|
|
17
17
|
val is_array : t -> bool
|
|
18
18
|
val is_bottom : t -> bool
|
|
19
19
|
val get_bottom : t -> t
|
|
20
|
-
val is_sub_type : t -> bool
|
|
20
|
+
val is_sub_type : t -> t -> bool
|
|
21
|
+
|
|
22
|
+
val set_type_name : Module.t -> t -> string -> unit
|
|
23
|
+
(** Sets the textual name of a compound `heapType`. Has no effect if the type
|
|
24
|
+
already has a canonical name. *)
|
|
25
|
+
|
|
26
|
+
val set_field_name : Module.t -> t -> int -> string -> unit
|
|
27
|
+
(** Sets the field name of a struct `heapType` at index `index`. *)
|
binaryen-archive/src/import.c
CHANGED
|
@@ -67,6 +67,24 @@ caml_binaryen_add_global_import__bytecode(value * argv) {
|
|
|
67
67
|
return caml_binaryen_add_global_import(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
CAMLprim value
|
|
71
|
+
caml_binaryen_add_tag_import(value _module, value _internalName, value _externalModuleName, value _externalBaseName, value _paramsty, value _resultsty) {
|
|
72
|
+
CAMLparam5(_module, _internalName, _externalModuleName, _externalBaseName, _paramsty);
|
|
73
|
+
CAMLxparam1(_resultsty);
|
|
74
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
75
|
+
char* internalName = Safe_String_val(_internalName);
|
|
76
|
+
char* externalModuleName = Safe_String_val(_externalModuleName);
|
|
77
|
+
char* externalBaseName = Safe_String_val(_externalBaseName);
|
|
78
|
+
BinaryenType paramsty = BinaryenType_val(_paramsty);
|
|
79
|
+
BinaryenType resultsty = BinaryenType_val(_resultsty);
|
|
80
|
+
BinaryenAddTagImport(module, internalName, externalModuleName, externalBaseName, paramsty, resultsty);
|
|
81
|
+
CAMLreturn(Val_unit);
|
|
82
|
+
}
|
|
83
|
+
CAMLprim value
|
|
84
|
+
caml_binaryen_add_tag_import__bytecode(value * argv) {
|
|
85
|
+
return caml_binaryen_add_tag_import(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
CAMLprim value
|
|
71
89
|
caml_binaryen_function_import_get_module(value _fun) {
|
|
72
90
|
CAMLparam1(_fun);
|
|
@@ -89,6 +107,13 @@ caml_binaryen_global_import_get_module(value _global) {
|
|
|
89
107
|
CAMLreturn(caml_copy_string(BinaryenGlobalImportGetModule(global)));
|
|
90
108
|
}
|
|
91
109
|
|
|
110
|
+
CAMLprim value
|
|
111
|
+
caml_binaryen_tag_import_get_module(value _tag) {
|
|
112
|
+
CAMLparam1(_tag);
|
|
113
|
+
BinaryenTagRef tag = BinaryenTagRef_val(_tag);
|
|
114
|
+
CAMLreturn(caml_copy_string(BinaryenTagImportGetModule(tag)));
|
|
115
|
+
}
|
|
116
|
+
|
|
92
117
|
CAMLprim value
|
|
93
118
|
caml_binaryen_function_import_get_base(value _fun) {
|
|
94
119
|
CAMLparam1(_fun);
|
|
@@ -110,3 +135,10 @@ caml_binaryen_global_import_get_base(value _global) {
|
|
|
110
135
|
BinaryenGlobalRef global = BinaryenGlobalRef_val(_global);
|
|
111
136
|
CAMLreturn(caml_copy_string(BinaryenGlobalImportGetBase(global)));
|
|
112
137
|
}
|
|
138
|
+
|
|
139
|
+
CAMLprim value
|
|
140
|
+
caml_binaryen_tag_import_get_base(value _tag) {
|
|
141
|
+
CAMLparam1(_tag);
|
|
142
|
+
BinaryenTagRef tag = BinaryenTagRef_val(_tag);
|
|
143
|
+
CAMLreturn(caml_copy_string(BinaryenTagImportGetBase(tag)));
|
|
144
|
+
}
|
binaryen-archive/src/import.js
CHANGED
|
@@ -92,6 +92,37 @@ function caml_binaryen_add_global_import__bytecode() {
|
|
|
92
92
|
);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
//Provides: caml_binaryen_add_tag_import
|
|
96
|
+
//Requires: caml_jsstring_of_string
|
|
97
|
+
function caml_binaryen_add_tag_import(
|
|
98
|
+
wasm_mod,
|
|
99
|
+
internalName,
|
|
100
|
+
externalModuleName,
|
|
101
|
+
externalBaseName,
|
|
102
|
+
paramsty,
|
|
103
|
+
resultsty
|
|
104
|
+
) {
|
|
105
|
+
return wasm_mod.addTagImport(
|
|
106
|
+
caml_jsstring_of_string(internalName),
|
|
107
|
+
caml_jsstring_of_string(externalModuleName),
|
|
108
|
+
caml_jsstring_of_string(externalBaseName),
|
|
109
|
+
paramsty,
|
|
110
|
+
resultsty
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
//Provides: caml_binaryen_add_tag_import__bytecode
|
|
114
|
+
//Requires: caml_binaryen_add_tag_import
|
|
115
|
+
function caml_binaryen_add_tag_import__bytecode() {
|
|
116
|
+
return caml_binaryen_add_tag_import(
|
|
117
|
+
arguments[0],
|
|
118
|
+
arguments[1],
|
|
119
|
+
arguments[2],
|
|
120
|
+
arguments[3],
|
|
121
|
+
arguments[4],
|
|
122
|
+
arguments[5]
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
95
126
|
//Provides: caml_binaryen_function_import_get_module
|
|
96
127
|
//Requires: Binaryen
|
|
97
128
|
//Requires: caml_string_of_jsstring
|
|
@@ -115,6 +146,14 @@ function caml_binaryen_global_import_get_module(global) {
|
|
|
115
146
|
return caml_string_of_jsstring(global_info.module);
|
|
116
147
|
}
|
|
117
148
|
|
|
149
|
+
//Provides: caml_binaryen_tag_import_get_module
|
|
150
|
+
//Requires: Binaryen
|
|
151
|
+
//Requires: caml_string_of_jsstring
|
|
152
|
+
function caml_binaryen_tag_import_get_module(tag) {
|
|
153
|
+
var tag_info = Binaryen.getTagInfo(tag);
|
|
154
|
+
return caml_string_of_jsstring(tag_info.module);
|
|
155
|
+
}
|
|
156
|
+
|
|
118
157
|
//Provides: caml_binaryen_function_import_get_base
|
|
119
158
|
//Requires: Binaryen
|
|
120
159
|
//Requires: caml_string_of_jsstring
|
|
@@ -137,3 +176,11 @@ function caml_binaryen_global_import_get_base(global) {
|
|
|
137
176
|
var global_info = Binaryen.getGlobalInfo(global);
|
|
138
177
|
return caml_string_of_jsstring(global_info.base);
|
|
139
178
|
}
|
|
179
|
+
|
|
180
|
+
//Provides: caml_binaryen_tag_import_get_base
|
|
181
|
+
//Requires: Binaryen
|
|
182
|
+
//Requires: caml_string_of_jsstring
|
|
183
|
+
function caml_binaryen_tag_import_get_base(tag) {
|
|
184
|
+
var tag_info = Binaryen.getTagInfo(tag);
|
|
185
|
+
return caml_string_of_jsstring(tag_info.base);
|
|
186
|
+
}
|
binaryen-archive/src/import.ml
CHANGED
|
@@ -21,6 +21,12 @@ external add_global_import :
|
|
|
21
21
|
(** Module, internal name, external module name, external base name, type,
|
|
22
22
|
mutable. *)
|
|
23
23
|
|
|
24
|
+
external add_tag_import :
|
|
25
|
+
Module.t -> string -> string -> string -> Type.t -> Type.t -> unit
|
|
26
|
+
= "caml_binaryen_add_tag_import__bytecode" "caml_binaryen_add_tag_import"
|
|
27
|
+
(** Module, internal name, external module name, external base name, params
|
|
28
|
+
type, results type. *)
|
|
29
|
+
|
|
24
30
|
external function_import_get_module : Function.t -> string
|
|
25
31
|
= "caml_binaryen_function_import_get_module"
|
|
26
32
|
|
|
@@ -30,6 +36,9 @@ external memory_import_get_module : Module.t -> string -> string
|
|
|
30
36
|
external global_import_get_module : Global.t -> string
|
|
31
37
|
= "caml_binaryen_global_import_get_module"
|
|
32
38
|
|
|
39
|
+
external tag_import_get_module : Tag.t -> string
|
|
40
|
+
= "caml_binaryen_tag_import_get_module"
|
|
41
|
+
|
|
33
42
|
external function_import_get_base : Function.t -> string
|
|
34
43
|
= "caml_binaryen_function_import_get_base"
|
|
35
44
|
|
|
@@ -38,3 +47,6 @@ external memory_import_get_base : Module.t -> string -> string
|
|
|
38
47
|
|
|
39
48
|
external global_import_get_base : Global.t -> string
|
|
40
49
|
= "caml_binaryen_global_import_get_base"
|
|
50
|
+
|
|
51
|
+
external tag_import_get_base : Tag.t -> string
|
|
52
|
+
= "caml_binaryen_tag_import_get_base"
|
binaryen-archive/src/import.mli
CHANGED
|
@@ -7,9 +7,14 @@ val add_memory_import : Module.t -> string -> string -> string -> bool -> unit
|
|
|
7
7
|
val add_global_import :
|
|
8
8
|
Module.t -> string -> string -> string -> Type.t -> bool -> unit
|
|
9
9
|
|
|
10
|
+
val add_tag_import :
|
|
11
|
+
Module.t -> string -> string -> string -> Type.t -> Type.t -> unit
|
|
12
|
+
|
|
10
13
|
val function_import_get_module : Function.t -> string
|
|
11
14
|
val memory_import_get_module : Module.t -> string -> string
|
|
12
15
|
val global_import_get_module : Global.t -> string
|
|
16
|
+
val tag_import_get_module : Tag.t -> string
|
|
13
17
|
val function_import_get_base : Function.t -> string
|
|
14
18
|
val memory_import_get_base : Module.t -> string -> string
|
|
15
19
|
val global_import_get_base : Global.t -> string
|
|
20
|
+
val tag_import_get_base : Tag.t -> string
|
binaryen-archive/src/memory.c
CHANGED
|
@@ -121,7 +121,12 @@ caml_binaryen_get_memory_segment_byte_offset(value _module, value _name) {
|
|
|
121
121
|
CAMLparam2(_module, _name);
|
|
122
122
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
123
123
|
char* name = Safe_String_val(_name);
|
|
124
|
-
|
|
124
|
+
if (BinaryenGetMemorySegmentPassive(module, name)) {
|
|
125
|
+
CAMLreturn(Val_none);
|
|
126
|
+
} else {
|
|
127
|
+
int offset = BinaryenGetMemorySegmentByteOffset(module, name);
|
|
128
|
+
CAMLreturn(caml_alloc_some(Val_int(offset)));
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
CAMLprim value
|
binaryen-archive/src/memory.js
CHANGED
|
@@ -112,10 +112,10 @@ function caml_binaryen_get_num_memory_segments(wasm_mod) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
//Provides: caml_binaryen_get_memory_segment_byte_offset
|
|
115
|
-
//Requires: caml_jsstring_of_string
|
|
115
|
+
//Requires: caml_jsstring_of_string, to_option
|
|
116
116
|
function caml_binaryen_get_memory_segment_byte_offset(wasm_mod, name) {
|
|
117
117
|
var info = wasm_mod.getMemorySegmentInfo(caml_jsstring_of_string(name));
|
|
118
|
-
return info.offset;
|
|
118
|
+
return to_option(info.offset);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
//Provides: caml_binaryen_get_memory_segment_passive
|
binaryen-archive/src/memory.ml
CHANGED
|
@@ -71,7 +71,7 @@ let unlimited = -1
|
|
|
71
71
|
external get_num_segments : Module.t -> int
|
|
72
72
|
= "caml_binaryen_get_num_memory_segments"
|
|
73
73
|
|
|
74
|
-
external get_segment_byte_offset : Module.t -> string -> int
|
|
74
|
+
external get_segment_byte_offset : Module.t -> string -> int option
|
|
75
75
|
= "caml_binaryen_get_memory_segment_byte_offset"
|
|
76
76
|
|
|
77
77
|
external get_segment_passive : Module.t -> string -> bool
|
binaryen-archive/src/memory.mli
CHANGED
|
@@ -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 -> string -> int
|
|
23
|
+
val get_segment_byte_offset : Module.t -> string -> int option
|
|
24
24
|
val get_segment_passive : Module.t -> string -> bool
|
|
25
25
|
val get_segment_data : Module.t -> string -> bytes
|
binaryen-archive/src/module.js
CHANGED
|
@@ -17,36 +17,24 @@ function caml_binaryen_module_parse(text) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//Provides: caml_binaryen_module_print
|
|
20
|
-
//Requires:
|
|
21
|
-
//Requires: caml_string_of_jsstring
|
|
22
|
-
//Requires: caml_ml_output, caml_ml_string_length
|
|
20
|
+
//Requires: caml_ml_output_str_stdout
|
|
23
21
|
function caml_binaryen_module_print(wasm_mod) {
|
|
24
22
|
var text = wasm_mod.emitText();
|
|
25
|
-
|
|
26
|
-
var s = caml_string_of_jsstring(text);
|
|
27
|
-
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
23
|
+
caml_ml_output_str_stdout(text);
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
//Provides: caml_binaryen_module_print_asmjs
|
|
31
|
-
//Requires:
|
|
32
|
-
//Requires: caml_string_of_jsstring
|
|
33
|
-
//Requires: caml_ml_output, caml_ml_string_length
|
|
27
|
+
//Requires: caml_ml_output_str_stdout
|
|
34
28
|
function caml_binaryen_module_print_asmjs(wasm_mod) {
|
|
35
29
|
var asm = wasm_mod.emitAsmjs();
|
|
36
|
-
|
|
37
|
-
var s = caml_string_of_jsstring(asm);
|
|
38
|
-
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
30
|
+
caml_ml_output_str_stdout(asm);
|
|
39
31
|
}
|
|
40
32
|
|
|
41
33
|
//Provides: caml_binaryen_module_print_stack_ir
|
|
42
|
-
//Requires:
|
|
43
|
-
//Requires: caml_string_of_jsstring
|
|
44
|
-
//Requires: caml_ml_output, caml_ml_string_length
|
|
34
|
+
//Requires: caml_ml_output_str_stdout
|
|
45
35
|
function caml_binaryen_module_print_stack_ir(wasm_mod) {
|
|
46
36
|
var stackir = wasm_mod.emitStackIR();
|
|
47
|
-
|
|
48
|
-
var s = caml_string_of_jsstring(stackir);
|
|
49
|
-
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
37
|
+
caml_ml_output_str_stdout(stackir);
|
|
50
38
|
}
|
|
51
39
|
|
|
52
40
|
//Provides: caml_binaryen_module_validate
|
|
@@ -122,16 +110,15 @@ function caml_binaryen_module_get_debug_info_filename(wasm_mod, index) {
|
|
|
122
110
|
}
|
|
123
111
|
|
|
124
112
|
//Provides: caml_binaryen_add_custom_section
|
|
125
|
-
//Requires: caml_jsstring_of_string,
|
|
113
|
+
//Requires: caml_jsstring_of_string, caml_uint8_array_of_string
|
|
126
114
|
function caml_binaryen_add_custom_section(wasm_mod, name, contents) {
|
|
127
115
|
return wasm_mod.addCustomSection(
|
|
128
116
|
caml_jsstring_of_string(name),
|
|
129
|
-
|
|
117
|
+
caml_uint8_array_of_string(contents)
|
|
130
118
|
);
|
|
131
119
|
}
|
|
132
120
|
|
|
133
121
|
//Provides: caml_binaryen_module_update_maps
|
|
134
122
|
function caml_binaryen_module_update_maps(wasm_mod) {
|
|
135
|
-
|
|
136
|
-
return;
|
|
123
|
+
return wasm_mod.updateMaps();
|
|
137
124
|
}
|
binaryen-archive/src/module.ml
CHANGED
|
@@ -98,6 +98,10 @@ module Feature = struct
|
|
|
98
98
|
|
|
99
99
|
let call_indirect_overlong = call_indirect_overlong ()
|
|
100
100
|
|
|
101
|
+
external relaxed_atomics : unit -> t = "caml_binaryen_feature_relaxed_atomics"
|
|
102
|
+
|
|
103
|
+
let relaxed_atomics = relaxed_atomics ()
|
|
104
|
+
|
|
101
105
|
external all : unit -> t = "caml_binaryen_feature_all"
|
|
102
106
|
|
|
103
107
|
let all = all ()
|
binaryen-archive/src/module.mli
CHANGED
|
@@ -155,6 +155,12 @@ caml_binaryen_feature_call_indirect_overlong(value unit) {
|
|
|
155
155
|
CAMLreturn(Val_int(BinaryenFeatureCallIndirectOverlong()));
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
CAMLprim value
|
|
159
|
+
caml_binaryen_feature_relaxed_atomics(value unit) {
|
|
160
|
+
CAMLparam1(unit);
|
|
161
|
+
CAMLreturn(Val_int(BinaryenFeatureRelaxedAtomics()));
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
CAMLprim value
|
|
159
165
|
caml_binaryen_feature_all(value unit) {
|
|
160
166
|
CAMLparam1(unit);
|
|
@@ -140,6 +140,12 @@ function caml_binaryen_feature_call_indirect_overlong() {
|
|
|
140
140
|
return Binaryen.Features.BulkMemoryOpt;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
//Provides: caml_binaryen_feature_relaxed_atomics
|
|
144
|
+
//Requires: Binaryen
|
|
145
|
+
function caml_binaryen_feature_relaxed_atomics() {
|
|
146
|
+
return Binaryen.Features.RelaxedAtomics;
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
//Provides: caml_binaryen_feature_all
|
|
144
150
|
//Requires: Binaryen
|
|
145
151
|
function caml_binaryen_feature_all() {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <caml/fail.h>
|
|
4
4
|
#include <caml/memory.h>
|
|
5
5
|
#include <caml/callback.h>
|
|
6
|
+
#include <caml/alloc.h>
|
|
6
7
|
|
|
7
8
|
#include "ocaml_helpers.h"
|
|
8
9
|
|
|
@@ -38,6 +39,14 @@ value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp)
|
|
|
38
39
|
return v;
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
/* Allocating an OCaml custom block to hold the given BinaryenTagRef */
|
|
43
|
+
value alloc_BinaryenTagRef(BinaryenTagRef exp)
|
|
44
|
+
{
|
|
45
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenTagRef), 0, 1);
|
|
46
|
+
BinaryenTagRef_val(v) = exp;
|
|
47
|
+
return v;
|
|
48
|
+
}
|
|
49
|
+
|
|
41
50
|
/* Allocating an OCaml custom block to hold the given BinaryenExportRef */
|
|
42
51
|
value alloc_BinaryenExportRef(BinaryenExportRef exp)
|
|
43
52
|
{
|
|
@@ -94,6 +103,14 @@ value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem)
|
|
|
94
103
|
return v;
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
/* Allocating an OCaml custom block to hold the given TypeBuilderRef */
|
|
107
|
+
value alloc_TypeBuilderRef(TypeBuilderRef builder)
|
|
108
|
+
{
|
|
109
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(TypeBuilderRef), 0, 1);
|
|
110
|
+
TypeBuilderRef_val(v) = builder;
|
|
111
|
+
return v;
|
|
112
|
+
}
|
|
113
|
+
|
|
97
114
|
CAMLprim value
|
|
98
115
|
array_of_list(value list) {
|
|
99
116
|
CAMLparam1(list);
|
|
@@ -23,15 +23,18 @@ static struct custom_operations binaryen_ops = {
|
|
|
23
23
|
|
|
24
24
|
#define BinaryenModuleRef_val(v) (*((BinaryenModuleRef*) Data_custom_val(v)))
|
|
25
25
|
#define BinaryenType_val(v) (*((BinaryenType*) Data_custom_val(v)))
|
|
26
|
+
#define BinaryenPackedType_val(v) Int_val(v)
|
|
26
27
|
#define BinaryenHeapType_val(v) (*((BinaryenHeapType*) Data_custom_val(v)))
|
|
27
28
|
#define BinaryenExpressionRef_val(v) (*((BinaryenExpressionRef*) Data_custom_val(v)))
|
|
28
29
|
#define BinaryenOp_val(v) (*((BinaryenOp*) Data_custom_val(v)))
|
|
29
30
|
#define BinaryenLiteral_val(v) (*((struct BinaryenLiteral*) Data_custom_val(v)))
|
|
30
31
|
#define BinaryenFunctionRef_val(v) (*((BinaryenFunctionRef*) Data_custom_val(v)))
|
|
31
32
|
#define BinaryenGlobalRef_val(v) (*((BinaryenGlobalRef*) Data_custom_val(v)))
|
|
33
|
+
#define BinaryenTagRef_val(v) (*((BinaryenTagRef*) Data_custom_val(v)))
|
|
32
34
|
#define BinaryenExportRef_val(v) (*((BinaryenExportRef*) Data_custom_val(v)))
|
|
33
35
|
#define BinaryenTableRef_val(v) (*((BinaryenTableRef*) Data_custom_val(v)))
|
|
34
36
|
#define BinaryenElementSegmentRef_val(v) (*((BinaryenElementSegmentRef*) Data_custom_val(v)))
|
|
37
|
+
#define TypeBuilderRef_val(v) (*((TypeBuilderRef*) Data_custom_val(v)))
|
|
35
38
|
|
|
36
39
|
#define Val_none Val_int(0)
|
|
37
40
|
#define Some_val(v) Field(v, 0)
|
|
@@ -53,6 +56,9 @@ value alloc_BinaryenType(BinaryenType typ);
|
|
|
53
56
|
/* Allocating an OCaml custom block to hold the given BinaryenGlobalRef */
|
|
54
57
|
value alloc_BinaryenGlobalRef(BinaryenGlobalRef exp);
|
|
55
58
|
|
|
59
|
+
/* Allocating an OCaml custom block to hold the given BinaryenTagRef */
|
|
60
|
+
value alloc_BinaryenTagRef(BinaryenTagRef exp);
|
|
61
|
+
|
|
56
62
|
/* Allocating an OCaml custom block to hold the given BinaryenExportRef */
|
|
57
63
|
value alloc_BinaryenExportRef(BinaryenExportRef exp);
|
|
58
64
|
|
|
@@ -74,6 +80,9 @@ value alloc_BinaryenTableRef(BinaryenTableRef table);
|
|
|
74
80
|
/* Allocating an OCaml custom block to hold the given BinaryenElementSegmentRef */
|
|
75
81
|
value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem);
|
|
76
82
|
|
|
83
|
+
/* Allocating an OCaml custom block to hold the given TypeBuilderRef */
|
|
84
|
+
value alloc_TypeBuilderRef(TypeBuilderRef builder);
|
|
85
|
+
|
|
77
86
|
CAMLprim value
|
|
78
87
|
array_of_list(value list);
|
|
79
88
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//Provides: caml_ml_output_str_stdout
|
|
2
|
+
//Requires: caml_ml_std_channel_id
|
|
3
|
+
//Requires: caml_string_of_jsstring
|
|
4
|
+
//Requires: caml_ml_output, caml_ml_string_length
|
|
5
|
+
function caml_ml_output_str_stdout(text) {
|
|
6
|
+
var chanid = caml_ml_std_channel_id[1]; // stdout
|
|
7
|
+
|
|
8
|
+
const raw_string = caml_string_of_jsstring(text);
|
|
9
|
+
const length = caml_ml_string_length(raw_string);
|
|
10
|
+
caml_ml_output(chanid, raw_string, 0, length);
|
|
11
|
+
}
|