From 045094d3edcc96c501d4220c4061e53e9613ffa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= Date: Thu, 13 Jul 2023 16:42:55 +0200 Subject: [PATCH] Wasm runtime file --- lib/dune | 5 ++++- lib/runtime.wat | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 lib/runtime.wat diff --git a/lib/dune b/lib/dune index 9e7ced6..33e95aa 100644 --- a/lib/dune +++ b/lib/dune @@ -8,7 +8,10 @@ (:standard (:include cflags.sexp)))) (js_of_ocaml - (javascript_files runtime.js))) + (javascript_files runtime.js)) + (wasm_of_ocaml + (javascript_files runtime.js) + (wasm_files runtime.wat))) (rule (targets cflags.sexp) diff --git a/lib/runtime.wat b/lib/runtime.wat new file mode 100644 index 0000000..2fdcf55 --- /dev/null +++ b/lib/runtime.wat @@ -0,0 +1,38 @@ +(module + (import "env" "caml_bigstring_blit_ba_to_ba" + (func $bigstringaf_blit_to_bigstring + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (param (ref eq)) (result (ref eq)))) + (import "env" "caml_bigstring_blit_bytes_to_ba" + (func $bigstringaf_blit_from_bytes + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (param (ref eq)) (result (ref eq)))) + (import "env" "caml_bigstring_blit_ba_to_bytes" + (func $bigstringaf_blit_to_bytes + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (param (ref eq)) (result (ref eq)))) + (import "env" "caml_bigstring_memcmp" + (func $bigstringaf_memcmp_bigstring + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (param (ref eq)) (result (ref eq)))) + (import "env" "caml_bigstring_memcmp_string" + (func $bigstringaf_memcmp_string + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (param (ref eq)) (result (ref eq)))) + (import "env" "caml_bigstring_memchr" + (func $caml_bigstring_memchr + (param (ref eq)) (param (ref eq)) (param (ref eq)) (param (ref eq)) + (result (ref eq)))) + + (export "bigstringaf_blit_to_bytes" (func $bigstringaf_blit_to_bytes)) + (export "bigstringaf_blit_to_bigstring" (func $bigstringaf_blit_to_bigstring)) + (export "bigstringaf_blit_from_bytes" (func $bigstringaf_blit_from_bytes)) + (export "bigstringaf_memcmp_bigstring" (func $bigstringaf_memcmp_bigstring)) + (export "bigstringaf_memcmp_string" (func $bigstringaf_memcmp_string)) + + (func (export "bigstringaf_memchr") + (param $ba (ref eq)) (param $off (ref eq)) (param $chr (ref eq)) + (param $len (ref eq)) (result (ref eq)) + (return_call $caml_bigstring_memchr + (local.get $ba) (local.get $chr) (local.get $off) (local.get $len))) +)