Skip to content

Commit e2ef90b

Browse files
committed
Wasm runtime: rename type $string to $bytes
1 parent 7192c28 commit e2ef90b

30 files changed

+708
-708
lines changed

runtime/wasm/array.wat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
(func $caml_invalid_argument (param (ref eq))))
2121

2222
(type $block (array (mut (ref eq))))
23-
(type $string (array (mut i8)))
23+
(type $bytes (array (mut i8)))
2424
(type $float (struct (field f64)))
2525
(type $float_array (array (mut f64)))
2626

@@ -36,7 +36,7 @@
3636
(if (i32.lt_s (local.get $sz) (i32.const 0))
3737
(then
3838
(call $caml_invalid_argument
39-
(array.new_data $string $Array_make
39+
(array.new_data $bytes $Array_make
4040
(i32.const 0) (i32.const 10)))))
4141
(if (i32.eqz (local.get $sz)) (then (return (global.get $empty_array))))
4242
(drop (block $not_float (result (ref eq))
@@ -58,7 +58,7 @@
5858
(if (i32.lt_s (local.get $sz) (i32.const 0))
5959
(then
6060
(call $caml_invalid_argument
61-
(array.new_data $string $Array_make
61+
(array.new_data $bytes $Array_make
6262
(i32.const 0) (i32.const 10)))))
6363
(if (i32.eqz (local.get $sz)) (then (return (global.get $empty_array))))
6464
(local.set $f
@@ -75,7 +75,7 @@
7575
(if (i32.lt_s (local.get $sz) (i32.const 0))
7676
(then
7777
(call $caml_invalid_argument
78-
(array.new_data $string $Array_make
78+
(array.new_data $bytes $Array_make
7979
(i32.const 0) (i32.const 10)))))
8080
(if (i32.eqz (local.get $sz)) (then (return (global.get $empty_array))))
8181
(array.new $float_array (f64.const 0) (local.get $sz)))

runtime/wasm/backtrace.wat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
(func $caml_invalid_argument (param (ref eq))))
2121

2222
(type $block (array (mut (ref eq))))
23-
(type $string (array (mut i8)))
23+
(type $bytes (array (mut i8)))
2424

2525
(func (export "caml_get_exception_raw_backtrace")
2626
(param (ref eq)) (result (ref eq))
@@ -44,7 +44,7 @@
4444
(func (export "caml_raw_backtrace_slot")
4545
(param (ref eq) (ref eq)) (result (ref eq))
4646
(call $caml_invalid_argument
47-
(array.new_data $string $raw_backtrace_slot_err
47+
(array.new_data $bytes $raw_backtrace_slot_err
4848
(i32.const 0) (i32.const 52)))
4949
(ref.i31 (i32.const 0)))
5050

runtime/wasm/bigarray.wat

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
(param (ref extern)) (param i32) (param i32) (result (ref extern))))
7272
(import "bindings" "ta_blit_from_string"
7373
(func $ta_blit_from_string
74-
(param (ref $string)) (param i32) (param (ref extern)) (param i32)
74+
(param (ref $bytes)) (param i32) (param (ref extern)) (param i32)
7575
(param i32)))
7676
(import "bindings" "ta_blit_to_string"
7777
(func $ta_blit_to_string
78-
(param (ref extern)) (param i32) (param (ref $string)) (param i32)
78+
(param (ref extern)) (param i32) (param (ref $bytes)) (param i32)
7979
(param i32)))
8080
(import "fail" "caml_bound_error" (func $caml_bound_error))
8181
(import "fail" "caml_raise_out_of_memory" (func $caml_raise_out_of_memory))
@@ -126,7 +126,7 @@
126126
(func $caml_deserialize_int_8 (param (ref eq)) (result i64)))
127127

128128
(type $block (array (mut (ref eq))))
129-
(type $string (array (mut i8)))
129+
(type $bytes (array (mut i8)))
130130
(type $float (struct (field f64)))
131131
(type $float_array (array (mut f64)))
132132

@@ -141,7 +141,7 @@
141141
(type $dup (func (param (ref eq)) (result (ref eq))))
142142
(type $custom_operations
143143
(struct
144-
(field $id (ref $string))
144+
(field $id (ref $bytes))
145145
(field $compare (ref null $compare))
146146
(field $compare_ext (ref null $compare))
147147
(field $hash (ref null $hash))
@@ -153,7 +153,7 @@
153153

154154
(global $bigarray_ops (export "bigarray_ops") (ref $custom_operations)
155155
(struct.new $custom_operations
156-
(array.new_fixed $string 9 ;; "_bigarr02"
156+
(array.new_fixed $bytes 9 ;; "_bigarr02"
157157
(i32.const 95) (i32.const 98) (i32.const 105) (i32.const 103)
158158
(i32.const 97) (i32.const 114) (i32.const 114) (i32.const 48)
159159
(i32.const 50))
@@ -591,7 +591,7 @@
591591
(if (call $caml_deserialize_uint_1 (local.get $s))
592592
(then
593593
(call $caml_failwith
594-
(array.new_data $string $intern_overflow
594+
(array.new_data $bytes $intern_overflow
595595
(i32.const 0) (i32.const 56))))))
596596
;; int32
597597
(loop $loop
@@ -716,7 +716,7 @@
716716
(if (i32.gt_u (local.get $num_dims) (global.get $CAML_BA_MAX_NUM_DIMS))
717717
(then
718718
(call $caml_invalid_argument
719-
(array.new_data $string $ba_create_bad_dims
719+
(array.new_data $bytes $ba_create_bad_dims
720720
(i32.const 0) (i32.const 41)))))
721721
(local.set $dim
722722
(array.new $int_array (i32.const 0) (local.get $num_dims)))
@@ -732,7 +732,7 @@
732732
(if (i32.lt_s (local.get $n) (i32.const 0))
733733
(then
734734
(call $caml_invalid_argument
735-
(array.new_data $string $ba_create_negative_dim
735+
(array.new_data $bytes $ba_create_negative_dim
736736
(i32.const 0) (i32.const 35)))))
737737
(array.set $int_array
738738
(local.get $dim) (local.get $i) (local.get $n))
@@ -761,15 +761,15 @@
761761
(if (i32.lt_s (local.get $kind) (i32.const 0))
762762
(then
763763
(call $caml_invalid_argument
764-
(array.new_data $string $ta_unsupported_kind
764+
(array.new_data $bytes $ta_unsupported_kind
765765
(i32.const 0) (i32.const 41)))))
766766
(if (i32.eq (local.get $kind) (i32.const 13)) ;; Uint8ClampedArray
767767
(then (local.set $kind (i32.const 3))))
768768
(local.set $len (call $ta_length (local.get $data)))
769769
(if (i32.lt_s (local.get $len) (i32.const 0))
770770
(then
771771
(call $caml_invalid_argument
772-
(array.new_data $string $ta_too_large
772+
(array.new_data $bytes $ta_too_large
773773
(i32.const 0) (i32.const 34)))))
774774
(struct.new $bigarray
775775
(global.get $bigarray_ops)
@@ -956,7 +956,7 @@
956956
(local.set $i (i31.get_s (ref.cast (ref i31) (local.get 1))))
957957
(if (i32.ge_u (local.get $i) (array.len (local.get $dim)))
958958
(then (call $caml_invalid_argument
959-
(array.new_data $string $Bigarray_dim
959+
(array.new_data $bytes $Bigarray_dim
960960
(i32.const 0) (i32.const 12)))))
961961
(ref.i31 (array.get $int_array (local.get $dim) (local.get $i))))
962962

@@ -1321,7 +1321,7 @@
13211321
(struct.get $bigarray $ba_num_dims (local.get $b)))
13221322
(then
13231323
(call $caml_invalid_argument
1324-
(array.new_data $string $too_many_indices
1324+
(array.new_data $bytes $too_many_indices
13251325
(i32.const 0) (i32.const 32)))))
13261326
(local.set $sub_dim
13271327
(array.new $int_array (i32.const 0)
@@ -1438,7 +1438,7 @@
14381438
(local.get $changed_dim))))
14391439
(then
14401440
(call $caml_invalid_argument
1441-
(array.new_data $string $bad_subarray
1441+
(array.new_data $bytes $bad_subarray
14421442
(i32.const 0) (i32.const 27)))))
14431443
(local.set $new_dim
14441444
(array.new $int_array (i32.const 0) (local.get $num_dims)))
@@ -1562,7 +1562,7 @@
15621562
(struct.get $bigarray $ba_num_dims (local.get $src)))
15631563
(then
15641564
(call $caml_invalid_argument
1565-
(array.new_data $string $dim_mismatch
1565+
(array.new_data $bytes $dim_mismatch
15661566
(i32.const 0) (i32.const 33)))))
15671567
(local.set $sdim (struct.get $bigarray $ba_dim (local.get $src)))
15681568
(local.set $ddim (struct.get $bigarray $ba_dim (local.get $dst)))
@@ -1574,7 +1574,7 @@
15741574
(array.get $int_array (local.get $ddim) (local.get $i)))
15751575
(then
15761576
(call $caml_invalid_argument
1577-
(array.new_data $string $dim_mismatch
1577+
(array.new_data $bytes $dim_mismatch
15781578
(i32.const 0) (i32.const 33)))))
15791579
(local.set $i (i32.add (local.get $i) (i32.const 1)))
15801580
(br $loop))))
@@ -1599,7 +1599,7 @@
15991599
(if (i32.gt_u (local.get $num_dims) (global.get $CAML_BA_MAX_NUM_DIMS))
16001600
(then
16011601
(call $caml_invalid_argument
1602-
(array.new_data $string $bad_number_dim
1602+
(array.new_data $bytes $bad_number_dim
16031603
(i32.const 0) (i32.const 42)))))
16041604
(local.set $num_elts (i64.const 1))
16051605
(local.set $dim (array.new $int_array (i32.const 0) (local.get $num_dims)))
@@ -1614,7 +1614,7 @@
16141614
(if (i32.lt_s (local.get $d) (i32.const 0))
16151615
(then
16161616
(call $caml_invalid_argument
1617-
(array.new_data $string $negative_dim
1617+
(array.new_data $bytes $negative_dim
16181618
(i32.const 0) (i32.const 36)))))
16191619
(array.set $int_array (local.get $dim) (local.get $i)
16201620
(local.get $d))
@@ -1631,7 +1631,7 @@
16311631
(struct.get $bigarray $ba_dim (local.get $b))))
16321632
(then
16331633
(call $caml_invalid_argument
1634-
(array.new_data $string $size_mismatch
1634+
(array.new_data $bytes $size_mismatch
16351635
(i32.const 0) (i32.const 31)))))
16361636
(struct.new $bigarray
16371637
(global.get $bigarray_ops)
@@ -2025,11 +2025,11 @@
20252025
(param (ref eq)) (result (ref eq))
20262026
;; used to convert a typed array to a string
20272027
(local $a (ref extern)) (local $len i32)
2028-
(local $s (ref $string))
2028+
(local $s (ref $bytes))
20292029
(local.set $a
20302030
(ref.as_non_null (extern.convert_any (call $unwrap (local.get 0)))))
20312031
(local.set $len (call $ta_length (local.get $a)))
2032-
(local.set $s (array.new $string (i32.const 0) (local.get $len)))
2032+
(local.set $s (array.new $bytes (i32.const 0) (local.get $len)))
20332033
(call $ta_blit_to_string
20342034
(local.get $a) (i32.const 0) (local.get $s) (i32.const 0)
20352035
(local.get $len))
@@ -2040,8 +2040,8 @@
20402040
(param (ref eq)) (result (ref eq))
20412041
;; Convert a string to a typed array
20422042
(local $ta (ref extern)) (local $len i32)
2043-
(local $s (ref $string))
2044-
(local.set $s (ref.cast (ref $string) (local.get 0)))
2043+
(local $s (ref $bytes))
2044+
(local.set $s (ref.cast (ref $bytes) (local.get 0)))
20452045
(local.set $len (array.len (local.get $s)))
20462046
(local.set $ta
20472047
(call $ta_create
@@ -2083,13 +2083,13 @@
20832083

20842084
(func (export "string_set")
20852085
(param $s externref) (param $i i32) (param $v i32)
2086-
(array.set $string
2087-
(ref.cast (ref null $string) (any.convert_extern (local.get $s)))
2086+
(array.set $bytes
2087+
(ref.cast (ref null $bytes) (any.convert_extern (local.get $s)))
20882088
(local.get $i) (local.get $v)))
20892089

20902090
(func (export "string_get")
20912091
(param $s externref) (param $i i32) (result i32)
2092-
(array.get $string
2093-
(ref.cast (ref null $string) (any.convert_extern (local.get $s)))
2092+
(array.get $bytes
2093+
(ref.cast (ref null $bytes) (any.convert_extern (local.get $s)))
20942094
(local.get $i)))
20952095
)

runtime/wasm/bigstring.wat

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@
5050
(func $ta_bytes (param anyref) (result anyref)))
5151
(import "bindings" "ta_blit_from_string"
5252
(func $ta_blit_from_string
53-
(param (ref $string)) (param i32) (param (ref extern)) (param i32)
53+
(param (ref $bytes)) (param i32) (param (ref extern)) (param i32)
5454
(param i32)))
5555
(import "bindings" "ta_blit_to_string"
5656
(func $ta_blit_to_string
57-
(param (ref extern)) (param i32) (param (ref $string)) (param i32)
57+
(param (ref extern)) (param i32) (param (ref $bytes)) (param i32)
5858
(param i32)))
5959
(import "hash" "caml_hash_mix_int"
6060
(func $caml_hash_mix_int (param i32) (param i32) (result i32)))
6161

62-
(type $string (array (mut i8)))
62+
(type $bytes (array (mut i8)))
6363

6464
(func (export "caml_hash_mix_bigstring")
6565
(param $h i32) (param $b (ref eq)) (result i32)
@@ -104,7 +104,7 @@
104104
(param $bs (ref eq)) (result (ref eq))
105105
(return_call $caml_js_get
106106
(call $caml_ba_to_typed_array (local.get $bs))
107-
(array.new_data $string $buffer (i32.const 0) (i32.const 6))))
107+
(array.new_data $bytes $buffer (i32.const 0) (i32.const 6))))
108108

109109
(export "bigstring_to_typed_array" (func $caml_ba_to_typed_array))
110110

@@ -160,10 +160,10 @@
160160
(local $i i32) (local $pos1 i32) (local $pos2 i32) (local $len i32)
161161
(local $c1 i32) (local $c2 i32)
162162
(local $d1 (ref extern))
163-
(local $s2 (ref $string))
163+
(local $s2 (ref $bytes))
164164
(local.set $d1 (call $caml_ba_get_data (local.get $s1)))
165165
(local.set $pos1 (i31.get_s (ref.cast (ref i31) (local.get $vpos1))))
166-
(local.set $s2 (ref.cast (ref $string) (local.get $vs2)))
166+
(local.set $s2 (ref.cast (ref $bytes) (local.get $vs2)))
167167
(local.set $pos2 (i31.get_s (ref.cast (ref i31) (local.get $vpos2))))
168168
(local.set $len (i31.get_s (ref.cast (ref i31) (local.get $vlen))))
169169
(loop $loop
@@ -173,7 +173,7 @@
173173
(call $ta_get_ui8 (local.get $d1)
174174
(i32.add (local.get $pos1) (local.get $i))))
175175
(local.set $c2
176-
(array.get_u $string (local.get $s2)
176+
(array.get_u $bytes (local.get $s2)
177177
(i32.add (local.get $pos2) (local.get $i))))
178178
(local.set $i (i32.add (local.get $i) (i32.const 1)))
179179
(br_if $loop (i32.eq (local.get $c1) (local.get $c2)))
@@ -233,9 +233,9 @@
233233
(param $ba2 (ref eq)) (param $vpos2 (ref eq))
234234
(param $vlen (ref eq)) (result (ref eq))
235235
(local $pos1 i32) (local $pos2 i32) (local $len i32)
236-
(local $s1 (ref $string))
236+
(local $s1 (ref $bytes))
237237
(local $d2 (ref extern))
238-
(local.set $s1 (ref.cast (ref $string) (local.get $str1)))
238+
(local.set $s1 (ref.cast (ref $bytes) (local.get $str1)))
239239
(local.set $pos1 (i31.get_s (ref.cast (ref i31) (local.get $vpos1))))
240240
(local.set $d2 (call $caml_ba_get_data (local.get $ba2)))
241241
(local.set $pos2 (i31.get_s (ref.cast (ref i31) (local.get $vpos2))))
@@ -252,10 +252,10 @@
252252
(param $vlen (ref eq)) (result (ref eq))
253253
(local $pos1 i32) (local $pos2 i32) (local $len i32)
254254
(local $d1 (ref extern))
255-
(local $s2 (ref $string))
255+
(local $s2 (ref $bytes))
256256
(local.set $d1 (call $caml_ba_get_data (local.get $ba1)))
257257
(local.set $pos1 (i31.get_s (ref.cast (ref i31) (local.get $vpos1))))
258-
(local.set $s2 (ref.cast (ref $string) (local.get $str2)))
258+
(local.set $s2 (ref.cast (ref $bytes) (local.get $str2)))
259259
(local.set $pos2 (i31.get_s (ref.cast (ref i31) (local.get $vpos2))))
260260
(local.set $len (i31.get_s (ref.cast (ref i31) (local.get $vlen))))
261261
(call $ta_blit_to_string

0 commit comments

Comments
 (0)