Skip to content

Commit 4587ff5

Browse files
committed
Wasm runtime changes
So that we can later implement `-enable use-js-string` without breaking compatibility with the zarith_stubs_js Wasm runtime file.
1 parent 8a54f80 commit 4587ff5

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

runtime/wasm/effect.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(func $caml_fresh_oo_id (param (ref eq)) (result (ref eq))))
2525
(import "obj" "cont_tag" (global $cont_tag i32))
2626
(import "stdlib" "caml_named_value"
27-
(func $caml_named_value (param (ref $string)) (result (ref null eq))))
27+
(func $caml_named_value (param (ref eq)) (result (ref null eq))))
2828
(import "fail" "ocaml_exception" (tag $ocaml_exception (param (ref eq))))
2929
(import "fail" "javascript_exception"
3030
(tag $javascript_exception (param externref)))

runtime/wasm/jslib.wat

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
(import "fail" "caml_failwith_tag"
7878
(func $caml_failwith_tag (result (ref eq))))
7979
(import "stdlib" "caml_named_value"
80-
(func $caml_named_value (param (ref $string)) (result (ref null eq))))
80+
(func $caml_named_value (param (ref eq)) (result (ref null eq))))
8181
(import "obj" "caml_callback_1"
8282
(func $caml_callback_1
8383
(param (ref eq)) (param (ref eq)) (result (ref eq))))
@@ -89,6 +89,9 @@
8989
(func $jsstring_of_string (param (ref $string)) (result anyref)))
9090
(import "jsstring" "string_of_jsstring"
9191
(func $string_of_jsstring (param anyref) (result (ref $string))))
92+
(import "jsstring" "jsstring_of_substring"
93+
(func $jsstring_of_substring
94+
(param (ref $string) i32 i32) (result anyref)))
9295
(import "int32" "caml_copy_int32"
9396
(func $caml_copy_int32 (param i32) (result (ref eq))))
9497
(import "int32" "Int32_val"
@@ -459,6 +462,16 @@
459462
(local.set $s (ref.cast (ref $string) (local.get 0)))
460463
(return (struct.new $js (call $jsstring_of_string (local.get $s)))))
461464

465+
(func (export "caml_jsstring_of_substring")
466+
(param $s (ref eq)) (param $i (ref eq)) (param $l (ref eq))
467+
(result (ref eq))
468+
(return
469+
(struct.new $js
470+
(call $jsstring_of_substring
471+
(ref.cast (ref $string) (local.get $s))
472+
(i31.get_u (ref.cast (ref i31) (local.get $i)))
473+
(i31.get_u (ref.cast (ref i31) (local.get $l)))))))
474+
462475
(func $caml_jsbytes_of_string (export "caml_jsbytes_of_string")
463476
(param (ref eq)) (result (ref eq))
464477
(local $s (ref $string))

runtime/wasm/stdlib.wat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
(br $loop))))
8080

8181
(func $caml_named_value (export "caml_named_value")
82-
(param $s (ref $string)) (result (ref null eq))
82+
(param $s (ref eq)) (result (ref null eq))
8383
(block $not_found
8484
(return
8585
(struct.get $assoc 1

tools/ci_setup.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ let () =
266266
let branch =
267267
if is_forked nm
268268
then
269-
if List.mem nm [ "bonsai"; "virtual_dom"; "async_js" ]
269+
if List.mem nm [ "bonsai"; "virtual_dom"; "async_js"; "zarith_stubs_js" ]
270270
then Some "jsoo-6"
271271
else Some "wasm"
272272
else None

0 commit comments

Comments
 (0)