@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
|
@@ -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,94 @@ 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
|
+
// Using four bytes doesn't matter if it is signed or unsigned
|
|
193
|
+
if (bytes === 4) {
|
|
194
|
+
return wasm_mod.i32.load(offset, align, ptr, name);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (signed) {
|
|
198
|
+
if (bytes === 1) {
|
|
199
|
+
return wasm_mod.i32.load8_s(offset, align, ptr, name);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (bytes === 2) {
|
|
203
|
+
return wasm_mod.i32.load16_s(offset, align, ptr, name);
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
if (bytes === 1) {
|
|
207
|
+
return wasm_mod.i32.load8_u(offset, align, ptr, name);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (bytes === 2) {
|
|
211
|
+
return wasm_mod.i32.load16_u(offset, align, ptr, name);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case Binaryen.i64: {
|
|
218
|
+
// Using eight bytes doesn't matter if it is signed or unsigned
|
|
219
|
+
if (bytes === 8) {
|
|
220
|
+
return wasm_mod.i64.load(offset, align, ptr, name);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (signed) {
|
|
224
|
+
if (bytes === 1) {
|
|
225
|
+
return wasm_mod.i64.load8_s(offset, align, ptr, name);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (bytes === 2) {
|
|
229
|
+
return wasm_mod.i64.load16_s(offset, align, ptr, name);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (bytes === 4) {
|
|
233
|
+
return wasm_mod.i64.load32_s(offset, align, ptr, name);
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
if (bytes === 1) {
|
|
237
|
+
return wasm_mod.i64.load8_u(offset, align, ptr, name);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (bytes === 2) {
|
|
241
|
+
return wasm_mod.i64.load16_u(offset, align, ptr, name);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (bytes === 4) {
|
|
245
|
+
return wasm_mod.i64.load32_u(offset, align, ptr, name);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case Binaryen.f32: {
|
|
252
|
+
return wasm_mod.f32.load(offset, align, ptr, name);
|
|
253
|
+
}
|
|
254
|
+
case Binaryen.f64: {
|
|
255
|
+
return wasm_mod.f64.load(offset, align, ptr, name);
|
|
256
|
+
}
|
|
257
|
+
case Binaryen.v128: {
|
|
258
|
+
return wasm_mod.v128.load(offset, align, ptr, name);
|
|
259
|
+
}
|
|
260
|
+
default: {
|
|
261
|
+
caml_failwith("Invalid arguments to BinaryenLoad");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
186
264
|
}
|
|
187
265
|
//Provides: caml_binaryen_load__bytecode
|
|
188
266
|
//Requires: caml_binaryen_load
|
|
@@ -194,22 +272,75 @@ function caml_binaryen_load__bytecode() {
|
|
|
194
272
|
arguments[3],
|
|
195
273
|
arguments[4],
|
|
196
274
|
arguments[5],
|
|
197
|
-
arguments[6]
|
|
275
|
+
arguments[6],
|
|
276
|
+
arguments[7]
|
|
198
277
|
);
|
|
199
278
|
}
|
|
200
279
|
|
|
201
280
|
//Provides: caml_binaryen_store
|
|
202
281
|
//Requires: Binaryen
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
282
|
+
//Requires: caml_jsstring_of_string
|
|
283
|
+
//Requires: caml_failwith
|
|
284
|
+
function caml_binaryen_store(
|
|
285
|
+
wasm_mod,
|
|
286
|
+
bytes,
|
|
287
|
+
offset,
|
|
288
|
+
align,
|
|
289
|
+
ptr,
|
|
290
|
+
value,
|
|
291
|
+
typ,
|
|
292
|
+
memoryName
|
|
293
|
+
) {
|
|
294
|
+
var name = caml_jsstring_of_string(memoryName);
|
|
295
|
+
|
|
296
|
+
switch (typ) {
|
|
297
|
+
case Binaryen.i32: {
|
|
298
|
+
if (bytes === 4) {
|
|
299
|
+
return wasm_mod.i32.store(offset, align, ptr, value, name);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (bytes === 1) {
|
|
303
|
+
return wasm_mod.i32.store8(offset, align, ptr, value, name);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (bytes === 2) {
|
|
307
|
+
return wasm_mod.i32.store16(offset, align, ptr, value, name);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
case Binaryen.i64: {
|
|
313
|
+
if (bytes === 8) {
|
|
314
|
+
return wasm_mod.i64.store(offset, align, ptr, value, name);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (bytes === 1) {
|
|
318
|
+
return wasm_mod.i64.store8(offset, align, ptr, value, name);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (bytes === 2) {
|
|
322
|
+
return wasm_mod.i64.store16(offset, align, ptr, value, name);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (bytes === 4) {
|
|
326
|
+
return wasm_mod.i64.store32(offset, align, ptr, value, name);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case Binaryen.f32: {
|
|
332
|
+
return wasm_mod.f32.store(offset, align, ptr, value, name);
|
|
333
|
+
}
|
|
334
|
+
case Binaryen.f64: {
|
|
335
|
+
return wasm_mod.f64.store(offset, align, ptr, value, name);
|
|
336
|
+
}
|
|
337
|
+
case Binaryen.v128: {
|
|
338
|
+
return wasm_mod.v128.store(offset, align, ptr, value, name);
|
|
339
|
+
}
|
|
340
|
+
default: {
|
|
341
|
+
caml_failwith("Invalid arguments to BinaryenStore");
|
|
342
|
+
}
|
|
343
|
+
}
|
|
213
344
|
}
|
|
214
345
|
//Provides: caml_binaryen_store__bytecode
|
|
215
346
|
//Requires: caml_binaryen_store
|
|
@@ -221,7 +352,8 @@ function caml_binaryen_store__bytecode() {
|
|
|
221
352
|
arguments[3],
|
|
222
353
|
arguments[4],
|
|
223
354
|
arguments[5],
|
|
224
|
-
arguments[6]
|
|
355
|
+
arguments[6],
|
|
356
|
+
arguments[7]
|
|
225
357
|
);
|
|
226
358
|
}
|
|
227
359
|
|
|
@@ -286,13 +418,22 @@ function caml_binaryen_return(wasm_mod, value) {
|
|
|
286
418
|
}
|
|
287
419
|
|
|
288
420
|
//Provides: caml_binaryen_memory_size
|
|
289
|
-
|
|
290
|
-
|
|
421
|
+
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
422
|
+
function caml_binaryen_memory_size(wasm_mod, memoryName, memoryIs64) {
|
|
423
|
+
return wasm_mod.memory.size(
|
|
424
|
+
caml_jsstring_of_string(memoryName),
|
|
425
|
+
caml_js_from_bool(memoryIs64)
|
|
426
|
+
);
|
|
291
427
|
}
|
|
292
428
|
|
|
293
429
|
//Provides: caml_binaryen_memory_grow
|
|
294
|
-
|
|
295
|
-
|
|
430
|
+
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
431
|
+
function caml_binaryen_memory_grow(wasm_mod, value, memoryName, memoryIs64) {
|
|
432
|
+
return wasm_mod.memory.grow(
|
|
433
|
+
value,
|
|
434
|
+
caml_jsstring_of_string(memoryName),
|
|
435
|
+
caml_js_from_bool(memoryIs64)
|
|
436
|
+
);
|
|
296
437
|
}
|
|
297
438
|
|
|
298
439
|
//Provides: caml_binaryen_nop
|
|
@@ -306,8 +447,34 @@ function caml_binaryen_unreachable(wasm_mod) {
|
|
|
306
447
|
}
|
|
307
448
|
|
|
308
449
|
//Provides: caml_binaryen_memory_init
|
|
309
|
-
|
|
310
|
-
|
|
450
|
+
//Requires: caml_jsstring_of_string
|
|
451
|
+
function caml_binaryen_memory_init(
|
|
452
|
+
wasm_mod,
|
|
453
|
+
segment,
|
|
454
|
+
dest,
|
|
455
|
+
offset,
|
|
456
|
+
size,
|
|
457
|
+
memoryName
|
|
458
|
+
) {
|
|
459
|
+
return wasm_mod.memory.init(
|
|
460
|
+
segment,
|
|
461
|
+
dest,
|
|
462
|
+
offset,
|
|
463
|
+
size,
|
|
464
|
+
caml_jsstring_of_string(memoryName)
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
//Provides: caml_binaryen_memory_init__bytecode
|
|
468
|
+
//Requires: caml_binaryen_memory_init
|
|
469
|
+
function caml_binaryen_memory_init__bytecode() {
|
|
470
|
+
return caml_binaryen_memory_init(
|
|
471
|
+
arguments[0],
|
|
472
|
+
arguments[1],
|
|
473
|
+
arguments[2],
|
|
474
|
+
arguments[3],
|
|
475
|
+
arguments[4],
|
|
476
|
+
arguments[5]
|
|
477
|
+
);
|
|
311
478
|
}
|
|
312
479
|
|
|
313
480
|
//Provides: caml_binaryen_data_drop
|
|
@@ -316,13 +483,45 @@ function caml_binaryen_data_drop(wasm_mod, segment) {
|
|
|
316
483
|
}
|
|
317
484
|
|
|
318
485
|
//Provides: caml_binaryen_memory_copy
|
|
319
|
-
|
|
320
|
-
|
|
486
|
+
//Requires: caml_jsstring_of_string
|
|
487
|
+
function caml_binaryen_memory_copy(
|
|
488
|
+
wasm_mod,
|
|
489
|
+
dest,
|
|
490
|
+
source,
|
|
491
|
+
size,
|
|
492
|
+
dest_memory,
|
|
493
|
+
source_memory
|
|
494
|
+
) {
|
|
495
|
+
return wasm_mod.memory.copy(
|
|
496
|
+
dest,
|
|
497
|
+
source,
|
|
498
|
+
size,
|
|
499
|
+
caml_jsstring_of_string(dest_memory),
|
|
500
|
+
caml_jsstring_of_string(source_memory)
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
//Provides: caml_binaryen_memory_copy__bytecode
|
|
504
|
+
//Requires: caml_binaryen_memory_copy
|
|
505
|
+
function caml_binaryen_memory_copy__bytecode() {
|
|
506
|
+
return caml_binaryen_memory_copy(
|
|
507
|
+
arguments[0],
|
|
508
|
+
arguments[1],
|
|
509
|
+
arguments[2],
|
|
510
|
+
arguments[3],
|
|
511
|
+
arguments[4],
|
|
512
|
+
arguments[5]
|
|
513
|
+
);
|
|
321
514
|
}
|
|
322
515
|
|
|
323
516
|
//Provides: caml_binaryen_memory_fill
|
|
324
|
-
|
|
325
|
-
|
|
517
|
+
//Requires: caml_jsstring_of_string
|
|
518
|
+
function caml_binaryen_memory_fill(wasm_mod, dest, value, size, memoryName) {
|
|
519
|
+
return wasm_mod.memory.fill(
|
|
520
|
+
dest,
|
|
521
|
+
value,
|
|
522
|
+
size,
|
|
523
|
+
caml_jsstring_of_string(memoryName)
|
|
524
|
+
);
|
|
326
525
|
}
|
|
327
526
|
|
|
328
527
|
//Provides: caml_binaryen_tuple_make
|
|
@@ -628,16 +827,6 @@ function caml_binaryen_expression_id_ref_cast() {
|
|
|
628
827
|
function caml_binaryen_expression_id_br_on() {
|
|
629
828
|
return Binaryen.BrOnId;
|
|
630
829
|
}
|
|
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
830
|
//Provides: caml_binaryen_expression_id_struct_new
|
|
642
831
|
//Requires: Binaryen
|
|
643
832
|
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
|
+
}
|