Skip to content

Commit

Permalink
Rename conversion instructions extern.{in,ex}ternalize
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Jul 19, 2024
1 parent 3ef1eff commit 7cc2831
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions runtime/wasm/bigarray.wat
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
(local $len i32)
(local.set $data
(call $ta_normalize
(ref.as_non_null (extern.externalize (call $unwrap (local.get 0))))))
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0))))))
(local.set $kind (call $ta_kind (local.get $data)))
(if (i32.lt_s (local.get $kind) (i32.const 0))
(then
Expand All @@ -777,7 +777,7 @@

(func (export "caml_ba_to_typed_array") (param (ref eq)) (result (ref eq))
(call $wrap
(extern.internalize
(any.convert_extern
(struct.get $bigarray $ba_data
(ref.cast (ref $bigarray) (local.get 0))))))

Expand Down Expand Up @@ -2102,7 +2102,7 @@
(local $a (ref extern)) (local $len i32) (local $i i32)
(local $s (ref $string))
(local.set $a
(ref.as_non_null (extern.externalize (call $unwrap (local.get 0)))))
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0)))))
(local.set $len (call $ta_length (local.get $a)))
(local.set $s (array.new $string (i32.const 0) (local.get $len)))
(loop $loop
Expand Down
16 changes: 8 additions & 8 deletions runtime/wasm/jslib.wat
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
(local.set 1 (call $caml_jsbytes_of_string (local.get 1)))))
(return_call $wrap
(call $get
(ref.as_non_null (extern.externalize (call $unwrap (local.get 0))))
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0))))
(call $unwrap (local.get 1)))))

(func (export "caml_js_set")
Expand Down Expand Up @@ -291,7 +291,7 @@
(i32.add (local.get $i) (i32.const 1)))))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br $loop))))
(return (struct.new $js (extern.internalize (local.get $a'))))))
(return (struct.new $js (any.convert_extern (local.get $a'))))))
(local.set $fa (ref.cast (ref $float_array) (local.get $va)))
(local.set $l (array.len (local.get $fa)))
(local.set $a' (call $new_array (local.get $l)))
Expand All @@ -304,7 +304,7 @@
(array.get $float_array (local.get $fa) (local.get $i))))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br $loop))))
(struct.new $js (extern.internalize (local.get $a'))))
(struct.new $js (any.convert_extern (local.get $a'))))

(func (export "caml_js_to_array")
(param (ref eq)) (result (ref eq))
Expand All @@ -313,7 +313,7 @@
(local $fa (ref $float_array))
(local $i i32) (local $l i32)
(local.set $a
(ref.as_non_null (extern.externalize (call $unwrap (local.get 0)))))
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0)))))
(local.set $l (call $array_length (local.get $a)))
(if (local.get $l)
(then
Expand Down Expand Up @@ -591,7 +591,7 @@
(local.set $l (array.get $block (local.get $b) (i32.const 2)))
(local.set $i (i32.add (local.get $i) (i32.const 1)))
(br $loop))))
(struct.new $js (extern.internalize (local.get $a))))
(struct.new $js (any.convert_extern (local.get $a))))

(func (export "caml_list_of_js_array")
(param (ref eq)) (result (ref eq))
Expand All @@ -600,7 +600,7 @@
(local $len i32)
(local $a (ref extern))
(local.set $a
(ref.as_non_null (extern.externalize (call $unwrap (local.get 0)))))
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0)))))
(local.set $len (call $array_length (local.get $a)))
(local.set $i (i32.const 0))
(local.set $l (ref.i31 (i32.const 0)))
Expand All @@ -625,7 +625,7 @@

(func (export "caml_wrap_exception") (param externref) (result (ref eq))
(local $exn anyref)
(local.set $exn (extern.internalize (local.get 0)))
(local.set $exn (any.convert_extern (local.get 0)))
;; ZZZ special case for stack overflows?
(block $undef
(return
Expand All @@ -643,7 +643,7 @@
(call $caml_jsstring_of_string
(array.new_data $string $toString
(i32.const 0) (i32.const 8))))
(extern.internalize (call $new_array (i32.const 0))))))))
(any.convert_extern (call $new_array (i32.const 0))))))))

(func (export "caml_js_error_option_of_exception")
(param (ref eq)) (result (ref eq))
Expand Down
10 changes: 5 additions & 5 deletions runtime/wasm/jsstring.wat
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
(func (export "jsstring_compare")
(param $s anyref) (param $s' anyref) (result i32)
(return_call $compare_strings
(extern.externalize (local.get $s))
(extern.externalize (local.get $s'))))
(extern.convert_any (local.get $s))
(extern.convert_any (local.get $s'))))

(func (export "jsstring_test") (param $s anyref) (result i32)
(return_call $is_string (extern.externalize (local.get $s))))
(return_call $is_string (extern.convert_any (local.get $s))))

(export "jsstring_hash" (func $hash_string))

Expand All @@ -78,7 +78,7 @@
(if (global.get $builtins_available)
(then
(return
(extern.internalize
(any.convert_extern
(call $decodeStringFromUTF8Array (local.get $s)
(local.get $pos)
(i32.add (local.get $pos) (local.get $len)))))))
Expand All @@ -93,7 +93,7 @@
(if (global.get $builtins_available)
(then
(return_call $encodeStringToUTF8Array
(extern.externalize (local.get $s)))))
(extern.convert_any (local.get $s)))))
(return_call $string_of_jsstring_fallback (local.get $s)))

;; Fallback implementation of string conversion functions
Expand Down
2 changes: 1 addition & 1 deletion runtime/wasm/sys.wat
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
(call $caml_raise_sys_error
(call $caml_string_of_jsstring
(call $caml_js_meth_call
(call $wrap (extern.internalize (local.get $exn)))
(call $wrap (any.convert_extern (local.get $exn)))
(array.new_data $string $toString (i32.const 0) (i32.const 8))
(array.new_fixed $block 1 (ref.i31 (i32.const 0)))))))
)

0 comments on commit 7cc2831

Please sign in to comment.