Skip to content

Commit cde9ab0

Browse files
committed
remove %bswap_16 which is rarely used
1 parent 56d084c commit cde9ab0

13 files changed

+7
-678
lines changed

jscomp/core/lam_analysis.ml

-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ let rec no_side_effects (lam : Lam.t) : bool =
8484
end
8585

8686
| Pcreate_extension _
87-
(* | Pcreate_exception _ *)
8887
| Pjs_typeof
8988
| Pis_null
9089
| Pis_not_none
@@ -162,7 +161,6 @@ let rec no_side_effects (lam : Lam.t) : bool =
162161
| Pstringadd
163162
| Pjs_function_length
164163
| Pcaml_obj_length
165-
(* | Pjs_is_instance_array *)
166164
| Pwrap_exn
167165
| Praw_js_code {code_info = Exp (Js_function _ | Js_literal _) | Stmt Js_stmt_comment}
168166
-> true
@@ -185,7 +183,6 @@ let rec no_side_effects (lam : Lam.t) : bool =
185183
(* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *)
186184
| Parraysets
187185
(* byte swap *)
188-
| Pbswap16
189186
| Pbbswap _
190187
| Parraysetu
191188
| Poffsetref _

jscomp/core/lam_compile_primitive.ml

-3
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,6 @@ let translate loc
616616
->
617617
Lam_dispatch_primitive.translate loc "caml_obj_dup" args
618618
(* check dubug mode *)
619-
| Pbswap16
620-
->
621-
E.runtime_call Js_runtime_modules.int32 "caml_bswap16" args
622619
| Pbbswap Lambda.Pnativeint
623620
| Pbbswap Lambda.Pint32
624621
->

jscomp/core/lam_convert.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,6 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
353353
| Psubfloat -> prim ~primitive:Psubfloat ~args loc
354354
| Pmulfloat -> prim ~primitive:Pmulfloat ~args loc
355355
| Pdivfloat -> prim ~primitive:Pdivfloat ~args loc
356-
357-
| Pbswap16 -> prim ~primitive:Pbswap16 ~args loc
358356
| Pintcomp x -> prim ~primitive:(Pintcomp x) ~args loc
359357
| Poffsetint x -> prim ~primitive:(Poffsetint x) ~args loc
360358
| Poffsetref x -> prim ~primitive:(Poffsetref x) ~args loc
@@ -427,6 +425,8 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : Lam.t =
427425
| Popaque -> Ext_list.singleton_exn args
428426
| Psetfield_computed _ ->
429427
prim ~primitive:Psetfield_computed ~args loc
428+
429+
| Pbswap16
430430
| Pduparray _ -> assert false
431431
(* Does not exist since we compile array in js backend unlike native backend *)
432432

jscomp/core/lam_primitive.ml

+1-4
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ type t =
112112

113113
(* Compile time constants *)
114114
| Pctconst of Lam_compat.compile_time_constant
115-
(* byte swap *)
116-
| Pbswap16
117-
| Pbbswap of Lam_compat.boxed_integer
115+
| Pbbswap of Lam_compat.boxed_integer
118116
(* Integer to external pointer *)
119117

120118
| Pdebugger
@@ -239,7 +237,6 @@ let eq_primitive_approx ( lhs : t) (rhs : t) =
239237
| Pdebugger -> rhs = Pdebugger
240238
| Pinit_mod -> rhs = Pinit_mod
241239
| Pupdate_mod -> rhs = Pupdate_mod
242-
| Pbswap16 -> rhs = Pbswap16
243240
| Pjs_function_length -> rhs = Pjs_function_length
244241
(* | Pjs_string_of_small_array -> rhs = Pjs_string_of_small_array *)
245242
(* | Pjs_is_instance_array -> rhs = Pjs_is_instance_array *)

jscomp/core/lam_primitive.mli

-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ type t =
108108

109109
(* Compile time constants *)
110110
| Pctconst of Lam_compat.compile_time_constant
111-
(* byte swap *)
112-
| Pbswap16
113111
| Pbbswap of Lam_compat.boxed_integer
114112
(* Integer to external pointer *)
115113

jscomp/core/lam_print.ml

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ let primitive ppf (prim : Lam_primitive.t) = match prim with
240240
| Pbintcomp(bi, Cgt) -> print_boxed_integer ">" ppf bi
241241
| Pbintcomp(bi, Cle) -> print_boxed_integer "<=" ppf bi
242242
| Pbintcomp(bi, Cge) -> print_boxed_integer ">=" ppf bi
243-
| Pbswap16 -> fprintf ppf "bswap16"
244243
| Pbbswap(bi) -> print_boxed_integer "bswap" ppf bi
245244

246245

jscomp/runtime/caml_int32.ml

-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ let mod_ (x : nativeint) (y:nativeint) =
3838
else Caml_nativeint_extern.rem x y
3939

4040

41-
let caml_bswap16 (x : nativeint) =
42-
let open Caml_nativeint_extern in
43-
logor (shift_left (logand x 0x00ffn) 8)
44-
(shift_right_logical (logand x 0xff00n) 8)
4541

4642
let caml_int32_bswap (x : nativeint) =
4743
let open Caml_nativeint_extern in

jscomp/runtime/caml_int32.mli

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ val div : nativeint -> nativeint -> nativeint
2828

2929
val mod_ : nativeint -> nativeint -> nativeint
3030

31-
val caml_bswap16 : nativeint -> nativeint
3231

3332
val caml_int32_bswap : nativeint -> nativeint
3433

jscomp/test/build.ninja

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ build test/string_unicode_test.cmi test/string_unicode_test.cmj : cc test/string
562562
build test/stringmatch_test.cmi test/stringmatch_test.cmj : cc test/stringmatch_test.ml | $stdlib
563563
build test/submodule.cmi test/submodule.cmj : cc test/submodule.ml | $stdlib
564564
build test/submodule_call.cmi test/submodule_call.cmj : cc test/submodule_call.ml | test/submodule.cmj $stdlib
565-
build test/swap_test.cmi test/swap_test.cmj : cc test/swap_test.ml | test/mt.cmj $stdlib
565+
build test/swap_test.cmi test/swap_test.cmj : cc test/swap_test.ml | $stdlib
566566
build test/switch_case_test.cmi test/switch_case_test.cmj : cc test/switch_case_test.ml | test/mt.cmj $stdlib
567567
build test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj : cc test/tailcall_inline_test.ml | test/mt.cmj $stdlib
568568
build test/test.cmi test/test.cmj : cc test/test.ml | $stdlib

0 commit comments

Comments
 (0)