Skip to content

Commit d8b1d58

Browse files
committed
remove Pstring_get_{16,32,64}
1 parent 82ef29c commit d8b1d58

20 files changed

+57
-185
lines changed

jscomp/core/js_long.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ let compare (args : J.expression list) =
167167

168168
(* let of_string (args : J.expression list) =
169169
int64_call "of_string" args *)
170-
let get64 = int64_call "get64"
170+
(* let get64 = int64_call "get64" *)
171171
let float_of_bits = int64_call "float_of_bits"
172172
let bits_of_float = int64_call "bits_of_float"
173173
let min args =

jscomp/core/js_long.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ val compare : int64_call
6363
(* val of_string : int64_call *)
6464
val float_of_bits : int64_call
6565
val bits_of_float : int64_call
66-
val get64 : int64_call
66+
(* val get64 : int64_call *)

jscomp/core/lam_analysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ let rec no_side_effects (lam : Lam.t) : bool =
191191
(* size of the nth dimension of a big array *)
192192
| Pbigarraydim _
193193
(* load/set 16,32,64 bits from a string: (unsafe)*)
194-
| Pstring_load_16 _
194+
(* | Pstring_load_16 _
195195
| Pstring_load_32 _
196-
| Pstring_load_64 _
196+
| Pstring_load_64 _ *)
197197
(* | Pstring_set_16 _
198198
| Pstring_set_32 _
199199
| Pstring_set_64 _ *)

jscomp/core/lam_compile_primitive.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,12 @@ let translate loc
686686
E.runtime_call Js_runtime_modules.int32 "caml_int32_bswap" args
687687
| Pbbswap Lambda.Pint64
688688
-> Js_long.swap args
689-
| Pstring_load_16 unsafe
689+
(* | Pstring_load_16 unsafe
690690
-> E.runtime_call Js_runtime_modules.string "caml_string_get16" args
691691
| Pstring_load_32 unsafe
692692
-> E.runtime_call Js_runtime_modules.string "caml_string_get32" args
693693
| Pstring_load_64 unsafe
694-
-> Js_long.get64 args
694+
-> Js_long.get64 args *)
695695

696696
| Plazyforce
697697
(* let parm = Ident.create "prim" in

jscomp/core/lam_convert.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,13 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
364364
| Plsrbint x -> prim ~primitive:(Plsrbint x) ~args loc
365365
| Pasrbint x -> prim ~primitive:(Pasrbint x) ~args loc
366366
| Pbigarraydim x -> prim ~primitive:(Pbigarraydim x) ~args loc
367-
| Pstring_load_16 x -> prim ~primitive:(Pstring_load_16 x) ~args loc
368-
| Pstring_load_32 x -> prim ~primitive:(Pstring_load_32 x) ~args loc
369-
| Pstring_load_64 x -> prim ~primitive:(Pstring_load_64 x) ~args loc
367+
| Pstring_load_16 _
368+
| Pstring_load_32 _
369+
| Pstring_load_64 _
370370
| Pstring_set_16 _
371371
| Pstring_set_32 _
372-
| Pstring_set_64 _ -> assert false
372+
| Pstring_set_64 _ ->
373+
Location.raise_errorf ~loc "unsupported primitive"
373374
| Pbigstring_load_16 x -> prim ~primitive:(Pbigstring_load_16 x) ~args loc
374375
| Pbigstring_load_32 x -> prim ~primitive:(Pbigstring_load_32 x) ~args loc
375376
| Pbigstring_load_64 x -> prim ~primitive:(Pbigstring_load_64 x) ~args loc

jscomp/core/lam_dispatch_primitive.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ let translate loc (prim_name : string)
552552
call Js_runtime_modules.char
553553
| "caml_string_get"
554554
->
555-
call Js_runtime_modules.string
555+
E.runtime_call Js_runtime_modules.string "get" args
556556
| "bytes_to_string"
557557
| "bytes_of_string"
558558
| "caml_blit_string"

jscomp/core/lam_primitive.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ type t =
116116
(* size of the nth dimension of a big array *)
117117
| Pbigarraydim of int
118118
(* load/set 16,32,64 bits from a string: (unsafe)*)
119-
| Pstring_load_16 of bool
119+
(* | Pstring_load_16 of bool
120120
| Pstring_load_32 of bool
121-
| Pstring_load_64 of bool
121+
| Pstring_load_64 of bool *)
122122
(* | Pstring_set_16 of bool
123123
| Pstring_set_32 of bool
124124
| Pstring_set_64 of bool *)
@@ -315,9 +315,9 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
315315
| Pcvtbint (boxed_integer, boxed_integer1) -> (match rhs with Pcvtbint (boxed_integer10, boxed_integer11) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer10 && Lam_compat.eq_boxed_integer boxed_integer1 boxed_integer11 | _ -> false )
316316
| Pbintcomp (boxed_integer , comparison) -> (match rhs with Pbintcomp(boxed_integer1, comparison1) -> Lam_compat.eq_boxed_integer boxed_integer boxed_integer1 && Lam_compat.eq_comparison comparison comparison1 | _ -> false)
317317
| Pbigarraydim dim -> (match rhs with Pbigarraydim dim1 -> dim = dim1 | _ -> false )
318-
| Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
318+
(* | Pstring_load_16 str -> (match rhs with Pstring_load_16 str1 -> str = str1 | _ -> false )
319319
| Pstring_load_32 b -> (match rhs with Pstring_load_32 b1 -> b = b1 | _ -> false )
320-
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false )
320+
| Pstring_load_64 b -> (match rhs with Pstring_load_64 b1 -> b = b1 | _ -> false ) *)
321321
(* | Pstring_set_16 b -> (match rhs with Pstring_set_16 b1 -> b = b1 | _ -> false )
322322
| Pstring_set_32 b -> (match rhs with Pstring_set_32 b1 -> b = b1 | _ -> false )
323323
| Pstring_set_64 b -> (match rhs with Pstring_set_64 b1 -> b = b1 | _ -> false ) *)

jscomp/core/lam_primitive.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ type t =
111111
(* size of the nth dimension of a big array *)
112112
| Pbigarraydim of int
113113
(* load/set 16,32,64 bits from a string: (unsafe)*)
114-
| Pstring_load_16 of bool
114+
(* | Pstring_load_16 of bool
115115
| Pstring_load_32 of bool
116-
| Pstring_load_64 of bool
116+
| Pstring_load_64 of bool *)
117117
(* | Pstring_set_16 of bool
118118
| Pstring_set_32 of bool
119119
| Pstring_set_64 of bool *)

jscomp/core/lam_print.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
268268
| Pbigarrayset(unsafe, n, kind, layout) ->
269269
print_bigarray "set" unsafe kind ppf layout
270270
| Pbigarraydim(n) -> fprintf ppf "Bigarray.dim_%i" n
271-
| Pstring_load_16(unsafe) ->
271+
(* | Pstring_load_16(unsafe) ->
272272
if unsafe then fprintf ppf "string.unsafe_get16"
273273
else fprintf ppf "string.get16"
274274
| Pstring_load_32(unsafe) ->
@@ -277,7 +277,7 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
277277
| Pstring_load_64(unsafe) ->
278278
if unsafe then fprintf ppf "string.unsafe_get64"
279279
else fprintf ppf "string.get64"
280-
(* | Pstring_set_16(unsafe) ->
280+
(* | Pstring_set_16(unsafe) -> *)
281281
if unsafe then fprintf ppf "string.unsafe_set16"
282282
else fprintf ppf "string.set16"
283283
| Pstring_set_32(unsafe) ->

jscomp/runtime/caml_array.ml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
external caml_array_dup : 'a array -> (_ [@bs.as 0]) -> 'a array =
2727
"slice" [@@bs.send]
2828

29+
let (.!()) = Caml_array_extern.unsafe_get
30+
let (.!()<-) = Caml_array_extern.unsafe_set
31+
2932
let caml_array_sub (x : 'a array) (offset : int) (len : int) =
3033
let result = Caml_array_extern.new_uninitialized len in
3134
let j = {contents = 0} and i = {contents = offset} in
3235
while j.contents < len do
33-
Caml_array_extern.unsafe_set result j.contents (Caml_array_extern.unsafe_get x i.contents);
36+
result.!(j.contents) <- x.!(i.contents);
3437
j.contents <- j.contents + 1;
3538
i.contents <- i.contents + 1;
3639
done;
@@ -50,7 +53,7 @@ let rec fill arr i l =
5053
let k = {contents = i} in
5154
let j = {contents = 0} in
5255
while j.contents < l do
53-
Caml_array_extern.unsafe_set arr k.contents (Caml_array_extern.unsafe_get x j.contents);
56+
arr.!(k.contents) <- x .!(j.contents);
5457
k.contents <- k.contents + 1;
5558
j.contents <- j.contents + 1;
5659
done;
@@ -65,35 +68,35 @@ let caml_array_concat (l : 'a array list) : 'a array =
6568
let caml_array_set xs index newval =
6669
if index <0 || index >= Caml_array_extern.length xs
6770
then raise (Invalid_argument "index out of bounds")
68-
else Caml_array_extern.unsafe_set xs index newval
71+
else xs.!( index)<- newval
6972

7073
let caml_array_get xs index =
7174
if index <0 || index >= Caml_array_extern.length xs then
7275
raise (Invalid_argument "index out of bounds")
73-
else Caml_array_extern.unsafe_get xs index
76+
else xs.!( index)
7477

7578

7679
let caml_make_vect len init =
7780
let b = Caml_array_extern.new_uninitialized len in
7881
for i = 0 to len - 1 do
79-
Caml_array_extern.unsafe_set b i init
82+
b.!(i) <- init
8083
done;
8184
b
8285

8386
let caml_make_float_vect len =
8487
let b = Caml_array_extern.new_uninitialized len in
8588
for i = 0 to len - 1 do
86-
Caml_array_extern.unsafe_set b i 0.
89+
b.!(i) <- 0.
8790
done;
8891
b
8992

9093
let caml_array_blit a1 i1 a2 i2 len =
9194
if i2 <= i1 then
9295
for j = 0 to len - 1 do
93-
Caml_array_extern.unsafe_set a2 (j+i2) (Caml_array_extern.unsafe_get a1 (j+i1))
96+
a2.! (j+i2) <- a1.! (j+i1)
9497
done
9598
else
9699
for j = len - 1 downto 0 do
97-
Caml_array_extern.unsafe_set a2 (j+i2) (Caml_array_extern.unsafe_get a1 (j+i1))
100+
a2 .!(j+i2) <- a1.! (j+i1)
98101
done
99102

0 commit comments

Comments
 (0)