@grain/binaryen.ml 0.19.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 +38 -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 +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 +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/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 +29 -5
- binaryen-archive/test/test.ml +33 -15
- binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
|
@@ -224,9 +224,9 @@ caml_binaryen_global_set(value _module, value _name, value _val) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
CAMLprim value
|
|
227
|
-
caml_binaryen_load(value _module, value _bytes, value _signed_, value _offset, value _align, value _ty, value _ptr) {
|
|
227
|
+
caml_binaryen_load(value _module, value _bytes, value _signed_, value _offset, value _align, value _ty, value _ptr, value _memoryName) {
|
|
228
228
|
CAMLparam5(_module, _bytes, _signed_, _offset, _align);
|
|
229
|
-
|
|
229
|
+
CAMLxparam3(_ty, _ptr, _memoryName);
|
|
230
230
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
231
231
|
int bytes = Int_val(_bytes);
|
|
232
232
|
int8_t signed_ = Bool_val(_signed_);
|
|
@@ -234,18 +234,19 @@ caml_binaryen_load(value _module, value _bytes, value _signed_, value _offset, v
|
|
|
234
234
|
int align = Int_val(_align);
|
|
235
235
|
BinaryenType ty = BinaryenType_val(_ty);
|
|
236
236
|
BinaryenExpressionRef ptr = BinaryenExpressionRef_val(_ptr);
|
|
237
|
-
|
|
237
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
238
|
+
BinaryenExpressionRef exp = BinaryenLoad(module, bytes, signed_, offset, align, ty, ptr, memoryName);
|
|
238
239
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
239
240
|
}
|
|
240
241
|
CAMLprim value
|
|
241
242
|
caml_binaryen_load__bytecode(value * argv) {
|
|
242
|
-
return caml_binaryen_load(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
|
|
243
|
+
return caml_binaryen_load(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
CAMLprim value
|
|
246
|
-
caml_binaryen_store(value _module, value _bytes, value _offset, value _align, value _ptr, value _val, value _ty) {
|
|
247
|
+
caml_binaryen_store(value _module, value _bytes, value _offset, value _align, value _ptr, value _val, value _ty, value _memoryName) {
|
|
247
248
|
CAMLparam5(_module, _bytes, _offset, _align, _ptr);
|
|
248
|
-
|
|
249
|
+
CAMLxparam3(_val, _ty, _memoryName);
|
|
249
250
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
250
251
|
int bytes = Int_val(_bytes);
|
|
251
252
|
int offset = Int_val(_offset);
|
|
@@ -253,12 +254,13 @@ caml_binaryen_store(value _module, value _bytes, value _offset, value _align, va
|
|
|
253
254
|
BinaryenExpressionRef ptr = BinaryenExpressionRef_val(_ptr);
|
|
254
255
|
BinaryenExpressionRef val = BinaryenExpressionRef_val(_val);
|
|
255
256
|
BinaryenType ty = BinaryenType_val(_ty);
|
|
256
|
-
|
|
257
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
258
|
+
BinaryenExpressionRef exp = BinaryenStore(module, bytes, offset, align, ptr, val, ty, memoryName);
|
|
257
259
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
258
260
|
}
|
|
259
261
|
CAMLprim value
|
|
260
262
|
caml_binaryen_store__bytecode(value * argv) {
|
|
261
|
-
return caml_binaryen_store(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
|
|
263
|
+
return caml_binaryen_store(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7]);
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
CAMLprim value
|
|
@@ -322,19 +324,23 @@ caml_binaryen_return(value _module, value _p1) {
|
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
CAMLprim value
|
|
325
|
-
caml_binaryen_memory_size(value _module) {
|
|
326
|
-
|
|
327
|
+
caml_binaryen_memory_size(value _module, value _memoryName, value _memoryIs64) {
|
|
328
|
+
CAMLparam3(_module, _memoryName, _memoryIs64);
|
|
327
329
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
328
|
-
|
|
330
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
331
|
+
bool memoryIs64 = Bool_val(_memoryIs64);
|
|
332
|
+
BinaryenExpressionRef exp = BinaryenMemorySize(module, memoryName, memoryIs64);
|
|
329
333
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
330
334
|
}
|
|
331
335
|
|
|
332
336
|
CAMLprim value
|
|
333
|
-
caml_binaryen_memory_grow(value _module, value
|
|
334
|
-
|
|
337
|
+
caml_binaryen_memory_grow(value _module, value _delta, value _memoryName, value _memoryIs64) {
|
|
338
|
+
CAMLparam4(_module, _delta, _memoryName, _memoryIs64);
|
|
335
339
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
336
|
-
BinaryenExpressionRef
|
|
337
|
-
|
|
340
|
+
BinaryenExpressionRef delta = BinaryenExpressionRef_val(_delta);
|
|
341
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
342
|
+
bool memoryIs64 = Bool_val(_memoryIs64);
|
|
343
|
+
BinaryenExpressionRef exp = BinaryenMemoryGrow(module, delta, memoryName, memoryIs64);
|
|
338
344
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
339
345
|
}
|
|
340
346
|
|
|
@@ -355,16 +361,22 @@ caml_binaryen_unreachable(value _module) {
|
|
|
355
361
|
}
|
|
356
362
|
|
|
357
363
|
CAMLprim value
|
|
358
|
-
caml_binaryen_memory_init(value _module, value _segment, value _dest, value _offset, value _size) {
|
|
364
|
+
caml_binaryen_memory_init(value _module, value _segment, value _dest, value _offset, value _size, value _memoryName) {
|
|
359
365
|
CAMLparam5(_module, _segment, _dest, _offset, _size);
|
|
366
|
+
CAMLxparam1(_memoryName);
|
|
360
367
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
361
368
|
uint32_t segment = Int_val(_segment);
|
|
362
369
|
BinaryenExpressionRef dest = BinaryenExpressionRef_val(_dest);
|
|
363
370
|
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
364
371
|
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
365
|
-
|
|
372
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
373
|
+
BinaryenExpressionRef exp = BinaryenMemoryInit(module, segment, dest, offset, size, memoryName);
|
|
366
374
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
367
375
|
}
|
|
376
|
+
CAMLprim value
|
|
377
|
+
caml_binaryen_memory_init__bytecode(value * argv) {
|
|
378
|
+
return caml_binaryen_memory_init(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
379
|
+
}
|
|
368
380
|
|
|
369
381
|
CAMLprim value
|
|
370
382
|
caml_binaryen_data_drop(value _module, value _segment) {
|
|
@@ -376,24 +388,32 @@ caml_binaryen_data_drop(value _module, value _segment) {
|
|
|
376
388
|
}
|
|
377
389
|
|
|
378
390
|
CAMLprim value
|
|
379
|
-
caml_binaryen_memory_copy(value _module, value _dest, value _source, value _size) {
|
|
380
|
-
|
|
391
|
+
caml_binaryen_memory_copy(value _module, value _dest, value _source, value _size, value _destMemory, value _sourceMemory) {
|
|
392
|
+
CAMLparam5(_module, _dest, _source, _size, _destMemory);
|
|
393
|
+
CAMLxparam1(_sourceMemory);
|
|
381
394
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
382
395
|
BinaryenExpressionRef dest = BinaryenExpressionRef_val(_dest);
|
|
383
396
|
BinaryenExpressionRef source = BinaryenExpressionRef_val(_source);
|
|
384
397
|
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
385
|
-
|
|
398
|
+
char* destMemory = Safe_String_val(_destMemory);
|
|
399
|
+
char* sourceMemory = Safe_String_val(_sourceMemory);
|
|
400
|
+
BinaryenExpressionRef exp = BinaryenMemoryCopy(module, dest, source, size, destMemory, sourceMemory);
|
|
386
401
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
387
402
|
}
|
|
403
|
+
CAMLprim value
|
|
404
|
+
caml_binaryen_memory_copy__bytecode(value * argv) {
|
|
405
|
+
return caml_binaryen_memory_copy(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
406
|
+
}
|
|
388
407
|
|
|
389
408
|
CAMLprim value
|
|
390
|
-
caml_binaryen_memory_fill(value _module, value _dest, value _val, value _size) {
|
|
391
|
-
|
|
409
|
+
caml_binaryen_memory_fill(value _module, value _dest, value _val, value _size, value _memoryName) {
|
|
410
|
+
CAMLparam5(_module, _dest, _val, _size, _memoryName);
|
|
392
411
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
393
412
|
BinaryenExpressionRef dest = BinaryenExpressionRef_val(_dest);
|
|
394
413
|
BinaryenExpressionRef val = BinaryenExpressionRef_val(_val);
|
|
395
414
|
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
396
|
-
|
|
415
|
+
char* memoryName = Safe_String_val(_memoryName);
|
|
416
|
+
BinaryenExpressionRef exp = BinaryenMemoryFill(module, dest, val, size, memoryName);
|
|
397
417
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
398
418
|
}
|
|
399
419
|
|
|
@@ -717,16 +737,6 @@ caml_binaryen_expression_id_br_on(value unit) {
|
|
|
717
737
|
CAMLreturn(Val_int(BinaryenBrOnId()));
|
|
718
738
|
}
|
|
719
739
|
CAMLprim value
|
|
720
|
-
caml_binaryen_expression_id_rtt_canon(value unit) {
|
|
721
|
-
CAMLparam1(unit);
|
|
722
|
-
CAMLreturn(Val_int(BinaryenRttCanonId()));
|
|
723
|
-
}
|
|
724
|
-
CAMLprim value
|
|
725
|
-
caml_binaryen_expression_id_rtt_sub(value unit) {
|
|
726
|
-
CAMLparam1(unit);
|
|
727
|
-
CAMLreturn(Val_int(BinaryenRttSubId()));
|
|
728
|
-
}
|
|
729
|
-
CAMLprim value
|
|
730
740
|
caml_binaryen_expression_id_struct_new(value unit) {
|
|
731
741
|
CAMLparam1(unit);
|
|
732
742
|
CAMLreturn(Val_int(BinaryenStructNewId()));
|
|
@@ -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
|
+
}
|