@grain/binaryen.ml 0.19.0 → 0.20.1
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 +50 -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 +285 -290
- binaryen-archive/esy.lock/opam/{base.v0.14.3 → base.v0.15.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/{chrome-trace.3.5.0 → chrome-trace.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-build-info.3.5.0 → dune-build-info.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dune-configurator.3.5.0 → dune-configurator.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-rpc.3.5.0 → dune-rpc.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.3.5.0 → dune.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dyn.3.5.0 → dyn.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{fiber.3.5.0 → 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.14.1 → ocaml-lsp-server.1.12.4}/opam +5 -5
- 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.1 → odoc-parser.2.0.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ordering.3.5.0 → ordering.3.6.1}/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.5.0 → 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/{xdg.3.5.0 → xdg.3.6.1}/opam +5 -5
- binaryen-archive/package.json +8 -8
- binaryen-archive/src/binaryen_stubs_expressions.c +43 -33
- binaryen-archive/src/binaryen_stubs_expressions.js +231 -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 +8 -6
- binaryen-archive/src/binaryen_stubs_imports.js +6 -6
- binaryen-archive/src/binaryen_stubs_memory.c +55 -16
- binaryen-archive/src/binaryen_stubs_memory.js +64 -15
- binaryen-archive/src/binaryen_stubs_modules.c +8 -6
- binaryen-archive/src/binaryen_stubs_modules.js +6 -6
- 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 +4 -2
- binaryen-archive/src/import.mli +2 -2
- binaryen-archive/src/memory.ml +19 -5
- binaryen-archive/src/memory.mli +9 -10
- binaryen-archive/src/module.ml +12 -2
- binaryen-archive/src/module.mli +3 -2
- 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 +8 -2
- binaryen-archive/src/passes.mli +8 -2
- 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 +32 -8
- binaryen-archive/test/test.ml +41 -16
- binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
|
@@ -75,10 +75,11 @@ caml_binaryen_function_import_get_module(value _fun) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
CAMLprim value
|
|
78
|
-
caml_binaryen_memory_import_get_module(value _module) {
|
|
79
|
-
|
|
78
|
+
caml_binaryen_memory_import_get_module(value _module, value _memoryName) {
|
|
79
|
+
CAMLparam2(_module, _memoryName);
|
|
80
80
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
81
|
-
|
|
81
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
82
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetModule(module, memoryName)));
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
CAMLprim value
|
|
@@ -96,10 +97,11 @@ caml_binaryen_function_import_get_base(value _fun) {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
CAMLprim value
|
|
99
|
-
caml_binaryen_memory_import_get_base(value _module) {
|
|
100
|
-
|
|
100
|
+
caml_binaryen_memory_import_get_base(value _module, value _memoryName) {
|
|
101
|
+
CAMLparam2(_module, _memoryName);
|
|
101
102
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
102
|
-
|
|
103
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
104
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetBase(module, memoryName)));
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
CAMLprim value
|
|
@@ -101,9 +101,9 @@ function caml_binaryen_function_import_get_module(func) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
//Provides: caml_binaryen_memory_import_get_module
|
|
104
|
-
//Requires: caml_string_of_jsstring
|
|
105
|
-
function caml_binaryen_memory_import_get_module(mod) {
|
|
106
|
-
var memory_info = mod.getMemoryInfo();
|
|
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
107
|
return caml_string_of_jsstring(memory_info.module);
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -124,9 +124,9 @@ function caml_binaryen_function_import_get_base(func) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
//Provides: caml_binaryen_memory_import_get_base
|
|
127
|
-
//Requires: caml_string_of_jsstring
|
|
128
|
-
function caml_binaryen_memory_import_get_base(mod) {
|
|
129
|
-
var memory_info = mod.getMemoryInfo();
|
|
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
130
|
return caml_string_of_jsstring(memory_info.base);
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -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,12 +40,13 @@ 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]);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
CAMLprim value
|
|
@@ -56,25 +57,28 @@ caml_binaryen_has_memory(value _module) {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
CAMLprim value
|
|
59
|
-
caml_binaryen_memory_get_initial(value _module) {
|
|
60
|
-
|
|
60
|
+
caml_binaryen_memory_get_initial(value _module, value _memoryName) {
|
|
61
|
+
CAMLparam2(_module, _memoryName);
|
|
61
62
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
62
|
-
|
|
63
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
64
|
+
CAMLreturn(Val_int(BinaryenMemoryGetInitial(module, memoryName)));
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
CAMLprim value
|
|
66
|
-
caml_binaryen_memory_has_max(value _module) {
|
|
67
|
-
|
|
68
|
+
caml_binaryen_memory_has_max(value _module, value _memoryName) {
|
|
69
|
+
CAMLparam2(_module, _memoryName);
|
|
68
70
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
69
|
-
|
|
71
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
72
|
+
CAMLreturn(Val_bool(BinaryenMemoryHasMax(module, memoryName)));
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
CAMLprim value
|
|
73
|
-
caml_binaryen_memory_get_max(value _module) {
|
|
74
|
-
|
|
76
|
+
caml_binaryen_memory_get_max(value _module, value _memoryName) {
|
|
77
|
+
CAMLparam2(_module, _memoryName);
|
|
75
78
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
80
|
+
if (BinaryenMemoryHasMax(module, memoryName)) {
|
|
81
|
+
CAMLreturn(Val_int(BinaryenMemoryGetMax(module, memoryName)));
|
|
78
82
|
} else {
|
|
79
83
|
// This ensures that our return is equal to Memory.unlimited
|
|
80
84
|
CAMLreturn(Val_int(-1));
|
|
@@ -82,8 +86,43 @@ caml_binaryen_memory_get_max(value _module) {
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
CAMLprim value
|
|
85
|
-
caml_binaryen_memory_is_shared(value _module) {
|
|
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) {
|
|
86
98
|
CAMLparam1(_module);
|
|
87
99
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
88
|
-
CAMLreturn(
|
|
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);
|
|
89
128
|
}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
//Provides: caml_binaryen_set_memory
|
|
2
2
|
//Requires: caml_list_to_js_array, caml_convert_bytes_to_array
|
|
3
3
|
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
4
|
-
function caml_binaryen_set_memory(
|
|
4
|
+
function caml_binaryen_set_memory(
|
|
5
|
+
wasm_mod,
|
|
6
|
+
initial,
|
|
7
|
+
maximum,
|
|
8
|
+
exportName,
|
|
9
|
+
segments,
|
|
10
|
+
segmentPassives,
|
|
11
|
+
segmentOffsets,
|
|
12
|
+
segmentSizes,
|
|
13
|
+
shared,
|
|
14
|
+
memoryName
|
|
15
|
+
) {
|
|
5
16
|
var passives = caml_list_to_js_array(segmentPassives);
|
|
6
17
|
var offsets = caml_list_to_js_array(segmentOffsets);
|
|
7
18
|
var segs = caml_list_to_js_array(segments).map(function (segment, idx) {
|
|
8
19
|
return {
|
|
9
20
|
data: caml_convert_bytes_to_array(segment),
|
|
10
21
|
passive: caml_js_from_bool(passives[idx]),
|
|
11
|
-
offset: offsets[idx]
|
|
12
|
-
}
|
|
22
|
+
offset: offsets[idx],
|
|
23
|
+
};
|
|
13
24
|
});
|
|
14
25
|
|
|
15
26
|
return wasm_mod.setMemory(
|
|
@@ -17,13 +28,25 @@ function caml_binaryen_set_memory(wasm_mod, initial, maximum, exportName, segmen
|
|
|
17
28
|
maximum,
|
|
18
29
|
caml_jsstring_of_string(exportName),
|
|
19
30
|
segs,
|
|
20
|
-
caml_js_from_bool(shared)
|
|
31
|
+
caml_js_from_bool(shared),
|
|
32
|
+
caml_jsstring_of_string(memoryName)
|
|
21
33
|
);
|
|
22
34
|
}
|
|
23
35
|
//Provides: caml_binaryen_set_memory__bytecode
|
|
24
36
|
//Requires: caml_binaryen_set_memory
|
|
25
37
|
function caml_binaryen_set_memory__bytecode() {
|
|
26
|
-
return caml_binaryen_set_memory(
|
|
38
|
+
return caml_binaryen_set_memory(
|
|
39
|
+
arguments[0],
|
|
40
|
+
arguments[1],
|
|
41
|
+
arguments[2],
|
|
42
|
+
arguments[3],
|
|
43
|
+
arguments[4],
|
|
44
|
+
arguments[5],
|
|
45
|
+
arguments[6],
|
|
46
|
+
arguments[7],
|
|
47
|
+
arguments[8],
|
|
48
|
+
arguments[9]
|
|
49
|
+
);
|
|
27
50
|
}
|
|
28
51
|
|
|
29
52
|
//Provides: caml_binaryen_has_memory
|
|
@@ -33,15 +56,16 @@ function caml_binaryen_has_memory(mod) {
|
|
|
33
56
|
}
|
|
34
57
|
|
|
35
58
|
//Provides: caml_binaryen_memory_get_initial
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
//Requires: caml_jsstring_of_string
|
|
60
|
+
function caml_binaryen_memory_get_initial(mod, memoryName) {
|
|
61
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
38
62
|
return memory_info.initial;
|
|
39
63
|
}
|
|
40
64
|
|
|
41
65
|
//Provides: caml_binaryen_memory_has_max
|
|
42
|
-
//Requires: caml_js_to_bool
|
|
43
|
-
function caml_binaryen_memory_has_max(mod) {
|
|
44
|
-
var memory_info = mod.getMemoryInfo();
|
|
66
|
+
//Requires: caml_js_to_bool, caml_jsstring_of_string
|
|
67
|
+
function caml_binaryen_memory_has_max(mod, memoryName) {
|
|
68
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
45
69
|
if (memory_info.max != null) {
|
|
46
70
|
return caml_js_to_bool(true);
|
|
47
71
|
} else {
|
|
@@ -50,8 +74,9 @@ function caml_binaryen_memory_has_max(mod) {
|
|
|
50
74
|
}
|
|
51
75
|
|
|
52
76
|
//Provides: caml_binaryen_memory_get_max
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
//Requires: caml_jsstring_of_string
|
|
78
|
+
function caml_binaryen_memory_get_max(mod, memoryName) {
|
|
79
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
55
80
|
if (memory_info.max != null) {
|
|
56
81
|
return memory_info.max;
|
|
57
82
|
} else {
|
|
@@ -61,8 +86,32 @@ function caml_binaryen_memory_get_max(mod) {
|
|
|
61
86
|
}
|
|
62
87
|
|
|
63
88
|
//Provides: caml_binaryen_memory_is_shared
|
|
64
|
-
//Requires: caml_js_to_bool
|
|
65
|
-
function caml_binaryen_memory_is_shared(mod) {
|
|
66
|
-
var memory_info = mod.getMemoryInfo();
|
|
89
|
+
//Requires: caml_js_to_bool, caml_jsstring_of_string
|
|
90
|
+
function caml_binaryen_memory_is_shared(mod, memoryName) {
|
|
91
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
67
92
|
return caml_js_to_bool(memory_info.shared);
|
|
68
93
|
}
|
|
94
|
+
|
|
95
|
+
//Provides: caml_binaryen_get_num_memory_segments
|
|
96
|
+
function caml_binaryen_get_num_memory_segments(wasm_mod) {
|
|
97
|
+
return wasm_mod.getNumMemorySegments();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//Provides: caml_binaryen_get_memory_segment_byte_offset
|
|
101
|
+
function caml_binaryen_get_memory_segment_byte_offset(wasm_mod, idx) {
|
|
102
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
103
|
+
return info.offset;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//Provides: caml_binaryen_get_memory_segment_passive
|
|
107
|
+
function caml_binaryen_get_memory_segment_passive(wasm_mod, idx) {
|
|
108
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
109
|
+
return info.passive;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//Provides: caml_binaryen_get_memory_segment_data
|
|
113
|
+
//Requires: caml_bytes_of_array
|
|
114
|
+
function caml_binaryen_get_memory_segment_data(wasm_mod, idx) {
|
|
115
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
116
|
+
return caml_bytes_of_array(info.data);
|
|
117
|
+
}
|
|
@@ -53,9 +53,10 @@ caml_binaryen_module_print_asmjs(value module) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
CAMLprim value
|
|
56
|
-
caml_binaryen_module_print_stack_ir(value module) {
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
caml_binaryen_module_print_stack_ir(value module, value _optimize) {
|
|
57
|
+
CAMLparam2(module, _optimize);
|
|
58
|
+
bool optimize = Bool_val(_optimize);
|
|
59
|
+
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module), optimize);
|
|
59
60
|
CAMLreturn(Val_unit);
|
|
60
61
|
}
|
|
61
62
|
|
|
@@ -135,10 +136,11 @@ caml_binaryen_module_write_text(value _module) {
|
|
|
135
136
|
// There is something weird with this function that causes a bunch of newlines to
|
|
136
137
|
// be printed on stdout when calling it. Not sure if that's a bug in Binaryen.
|
|
137
138
|
CAMLprim value
|
|
138
|
-
caml_binaryen_module_write_stack_ir(value _module) {
|
|
139
|
-
|
|
139
|
+
caml_binaryen_module_write_stack_ir(value _module, value _optimize) {
|
|
140
|
+
CAMLparam2(_module, _optimize);
|
|
140
141
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
141
|
-
|
|
142
|
+
bool optimize = Bool_val(_optimize);
|
|
143
|
+
char* result = BinaryenModuleAllocateAndWriteStackIR(module, optimize);
|
|
142
144
|
CAMLlocal1(text);
|
|
143
145
|
text = caml_copy_string(result);
|
|
144
146
|
free(result);
|
|
@@ -37,10 +37,10 @@ function caml_binaryen_module_print_asmjs(wasm_mod) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//Provides: caml_binaryen_module_print_stack_ir
|
|
40
|
-
//Requires: caml_string_of_jsstring
|
|
40
|
+
//Requires: caml_string_of_jsstring, caml_js_from_bool
|
|
41
41
|
//Requires: caml_ml_output, caml_ml_string_length
|
|
42
|
-
function caml_binaryen_module_print_stack_ir(wasm_mod) {
|
|
43
|
-
var stackir = wasm_mod.emitStackIR()
|
|
42
|
+
function caml_binaryen_module_print_stack_ir(wasm_mod, optimize) {
|
|
43
|
+
var stackir = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
|
|
44
44
|
var chanid = 1; // stdout
|
|
45
45
|
var s = caml_string_of_jsstring(stackir);
|
|
46
46
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
@@ -93,9 +93,9 @@ function caml_binaryen_module_write_text(wasm_mod) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
//Provides: caml_binaryen_module_write_stack_ir
|
|
96
|
-
//Requires: caml_string_of_jsstring
|
|
97
|
-
function caml_binaryen_module_write_stack_ir(wasm_mod) {
|
|
98
|
-
var text = wasm_mod.emitStackIR();
|
|
96
|
+
//Requires: caml_string_of_jsstring, caml_js_from_bool
|
|
97
|
+
function caml_binaryen_module_write_stack_ir(wasm_mod, optimize) {
|
|
98
|
+
var text = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
|
|
99
99
|
return caml_string_of_jsstring(text);
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
CAMLprim value
|
|
11
|
+
caml_binaryen_packed_type_not_packed(value unit) {
|
|
12
|
+
CAMLparam1(unit);
|
|
13
|
+
CAMLreturn(Val_int(BinaryenPackedTypeNotPacked()));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
CAMLprim value
|
|
17
|
+
caml_binaryen_packed_type_int8(value unit) {
|
|
18
|
+
CAMLparam1(unit);
|
|
19
|
+
CAMLreturn(Val_int(BinaryenPackedTypeInt8()));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
CAMLprim value
|
|
23
|
+
caml_binaryen_packed_type_int16(value unit) {
|
|
24
|
+
CAMLparam1(unit);
|
|
25
|
+
CAMLreturn(Val_int(BinaryenPackedTypeInt16()));
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//Provides: caml_binaryen_packed_type_not_packed
|
|
2
|
+
//Requires: Binaryen
|
|
3
|
+
function caml_binaryen_packed_type_not_packed() {
|
|
4
|
+
return Binaryen._BinaryenPackedTypeNotPacked();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_packed_type_int8
|
|
8
|
+
//Requires: Binaryen
|
|
9
|
+
function caml_binaryen_packed_type_int8() {
|
|
10
|
+
return Binaryen._BinaryenPackedTypeInt8();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_packed_type_int16
|
|
14
|
+
//Requires: Binaryen
|
|
15
|
+
function caml_binaryen_packed_type_int16() {
|
|
16
|
+
return Binaryen._BinaryenPackedTypeInt16();
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
CAMLprim value
|
|
11
|
+
caml_binaryen_type_system_equirecursive(value unit) {
|
|
12
|
+
CAMLparam1(unit);
|
|
13
|
+
CAMLreturn(Val_int(BinaryenTypeSystemEquirecursive()));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
CAMLprim value
|
|
17
|
+
caml_binaryen_type_system_nominal(value unit) {
|
|
18
|
+
CAMLparam1(unit);
|
|
19
|
+
CAMLreturn(Val_int(BinaryenTypeSystemNominal()));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
CAMLprim value
|
|
23
|
+
caml_binaryen_type_system_isorecursive(value unit) {
|
|
24
|
+
CAMLparam1(unit);
|
|
25
|
+
CAMLreturn(Val_int(BinaryenTypeSystemIsorecursive()));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
CAMLprim value
|
|
29
|
+
caml_binaryen_get_type_system(value unit) {
|
|
30
|
+
CAMLparam1(unit);
|
|
31
|
+
CAMLreturn(Val_int(BinaryenGetTypeSystem()));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
CAMLprim value
|
|
35
|
+
caml_binaryen_set_type_system(value _typeSystem) {
|
|
36
|
+
CAMLparam1(_typeSystem);
|
|
37
|
+
BinaryenTypeSystem typeSystem = Int_val(_typeSystem);
|
|
38
|
+
BinaryenSetTypeSystem(typeSystem);
|
|
39
|
+
CAMLreturn(Val_unit);
|
|
40
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//Provides: caml_binaryen_type_system_equirecursive
|
|
2
|
+
//Requires: Binaryen
|
|
3
|
+
function caml_binaryen_type_system_equirecursive() {
|
|
4
|
+
return Binaryen._BinaryenTypeSystemEquirecursive();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_type_system_nominal
|
|
8
|
+
//Requires: Binaryen
|
|
9
|
+
function caml_binaryen_type_system_nominal() {
|
|
10
|
+
return Binaryen._BinaryenTypeSystemNominal();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_type_system_isorecursive
|
|
14
|
+
//Requires: Binaryen
|
|
15
|
+
function caml_binaryen_type_system_isorecursive() {
|
|
16
|
+
return Binaryen._BinaryenTypeSystemIsorecursive();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Provides: caml_binaryen_get_type_system
|
|
20
|
+
//Requires: Binaryen
|
|
21
|
+
function caml_binaryen_get_type_system() {
|
|
22
|
+
return Binaryen._BinaryenGetTypeSystem();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//Provides: caml_binaryen_set_type_system
|
|
26
|
+
//Requires: Binaryen
|
|
27
|
+
function caml_binaryen_set_type_system(typeSystem) {
|
|
28
|
+
Binaryen._BinaryenSetTypeSystem(typeSystem);
|
|
29
|
+
}
|
|
@@ -93,6 +93,34 @@ caml_binaryen_type_dataref(value unit) {
|
|
|
93
93
|
CAMLreturn(alloc_BinaryenType(ty));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
CAMLprim value
|
|
97
|
+
caml_binaryen_type_stringref(value unit) {
|
|
98
|
+
CAMLparam1(unit);
|
|
99
|
+
BinaryenType ty = BinaryenTypeStringref();
|
|
100
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
CAMLprim value
|
|
104
|
+
caml_binaryen_type_stringview_wtf8(value unit) {
|
|
105
|
+
CAMLparam1(unit);
|
|
106
|
+
BinaryenType ty = BinaryenTypeStringviewWTF8();
|
|
107
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
CAMLprim value
|
|
111
|
+
caml_binaryen_type_stringview_wtf16(value unit) {
|
|
112
|
+
CAMLparam1(unit);
|
|
113
|
+
BinaryenType ty = BinaryenTypeStringviewWTF16();
|
|
114
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
CAMLprim value
|
|
118
|
+
caml_binaryen_type_stringview_iter(value unit) {
|
|
119
|
+
CAMLparam1(unit);
|
|
120
|
+
BinaryenType ty = BinaryenTypeStringviewIter();
|
|
121
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
122
|
+
}
|
|
123
|
+
|
|
96
124
|
CAMLprim value
|
|
97
125
|
caml_binaryen_type_unreachable(value unit) {
|
|
98
126
|
CAMLparam1(unit);
|
|
@@ -136,3 +164,19 @@ caml_binaryen_type_expand(value _ty) {
|
|
|
136
164
|
|
|
137
165
|
CAMLreturn(typeArray);
|
|
138
166
|
}
|
|
167
|
+
|
|
168
|
+
CAMLprim value
|
|
169
|
+
caml_binaryen_type_is_nullable(value _ty) {
|
|
170
|
+
CAMLparam1(_ty);
|
|
171
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
172
|
+
CAMLreturn(Val_bool(BinaryenTypeIsNullable(ty)));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
CAMLprim value
|
|
176
|
+
caml_binaryen_type_from_heap_type(value _ty, value _nullable) {
|
|
177
|
+
CAMLparam2(_ty, _nullable);
|
|
178
|
+
BinaryenHeapType heapTy = BinaryenHeapType_val(_ty);
|
|
179
|
+
bool nullable = Bool_val(_nullable);
|
|
180
|
+
BinaryenType ty = BinaryenTypeFromHeapType(heapTy, nullable);
|
|
181
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
182
|
+
}
|
|
@@ -64,6 +64,30 @@ function caml_binaryen_type_dataref() {
|
|
|
64
64
|
return Binaryen.dataref;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
//Provides: caml_binaryen_type_stringref
|
|
68
|
+
//Requires: Binaryen
|
|
69
|
+
function caml_binaryen_type_stringref() {
|
|
70
|
+
return Binaryen.stringref;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//Provides: caml_binaryen_type_stringview_wtf8
|
|
74
|
+
//Requires: Binaryen
|
|
75
|
+
function caml_binaryen_type_stringview_wtf8() {
|
|
76
|
+
return Binaryen.stringview_wtf8;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//Provides: caml_binaryen_type_stringview_wtf16
|
|
80
|
+
//Requires: Binaryen
|
|
81
|
+
function caml_binaryen_type_stringview_wtf16() {
|
|
82
|
+
return Binaryen.stringview_wtf16;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//Provides: caml_binaryen_type_stringview_iter
|
|
86
|
+
//Requires: Binaryen
|
|
87
|
+
function caml_binaryen_type_stringview_iter() {
|
|
88
|
+
return Binaryen.stringview_iter;
|
|
89
|
+
}
|
|
90
|
+
|
|
67
91
|
//Provides: caml_binaryen_type_unreachable
|
|
68
92
|
//Requires: Binaryen
|
|
69
93
|
function caml_binaryen_type_unreachable() {
|
|
@@ -89,3 +113,15 @@ function caml_binaryen_type_create(typs) {
|
|
|
89
113
|
function caml_binaryen_type_expand(typ) {
|
|
90
114
|
return caml_js_to_array(Binaryen.expandType(typ));
|
|
91
115
|
}
|
|
116
|
+
|
|
117
|
+
//Provides: caml_binaryen_type_is_nullable
|
|
118
|
+
//Requires: Binaryen
|
|
119
|
+
function caml_binaryen_type_is_nullable(typ) {
|
|
120
|
+
return Binaryen._BinaryenTypeIsNullable(typ);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//Provides: caml_binaryen_type_from_heap_type
|
|
124
|
+
//Requires: Binaryen
|
|
125
|
+
function caml_binaryen_type_from_heap_type(typ, nullable) {
|
|
126
|
+
return Binaryen._BinaryenTypeFromHeapType(typ, nullable);
|
|
127
|
+
}
|
binaryen-archive/src/dune
CHANGED
|
@@ -4,17 +4,40 @@
|
|
|
4
4
|
(libraries libbinaryen.c)
|
|
5
5
|
(foreign_stubs
|
|
6
6
|
(language c)
|
|
7
|
-
(names
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
(names
|
|
8
|
+
binaryen_stubs_types
|
|
9
|
+
binaryen_stubs_ops
|
|
10
|
+
binaryen_stubs_literals
|
|
11
|
+
binaryen_stubs_expressions
|
|
12
|
+
binaryen_stubs_functions
|
|
13
|
+
binaryen_stubs_imports
|
|
14
|
+
binaryen_stubs_exports
|
|
15
|
+
binaryen_stubs_globals
|
|
16
|
+
binaryen_stubs_tables
|
|
17
|
+
binaryen_stubs_memory
|
|
18
|
+
binaryen_stubs_features
|
|
19
|
+
binaryen_stubs_modules
|
|
20
|
+
binaryen_stubs_settings
|
|
21
|
+
binaryen_stubs_packed_types
|
|
22
|
+
binaryen_stubs_heap_types
|
|
23
|
+
binaryen_stubs_type_system
|
|
24
|
+
ocaml_helpers)
|
|
12
25
|
(flags :standard -O2 -Wall -Wextra))
|
|
13
26
|
(js_of_ocaml
|
|
14
|
-
(javascript_files
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
(javascript_files
|
|
28
|
+
binaryen_stubs_types.js
|
|
29
|
+
binaryen_stubs_ops.js
|
|
30
|
+
binaryen_stubs_literals.js
|
|
31
|
+
binaryen_stubs_expressions.js
|
|
32
|
+
binaryen_stubs_functions.js
|
|
33
|
+
binaryen_stubs_imports.js
|
|
34
|
+
binaryen_stubs_exports.js
|
|
35
|
+
binaryen_stubs_globals.js
|
|
36
|
+
binaryen_stubs_tables.js
|
|
37
|
+
binaryen_stubs_memory.js
|
|
38
|
+
binaryen_stubs_features.js
|
|
39
|
+
binaryen_stubs_modules.js
|
|
40
|
+
binaryen_stubs_settings.js
|
|
41
|
+
binaryen_stubs_packed_types.js
|
|
42
|
+
binaryen_stubs_heap_types.js
|
|
43
|
+
binaryen_stubs_type_system.js)))
|