Skip to content

Commit 6eba90d

Browse files
flambda-backend: Move unboxed types modules to stdlib_upstream_compatible (#2588)
* Move unboxed types to `stdlib_upstream_compatible` * Search-and-replace moved modules in tests * Disable upstream compatibility warnings on external declarations * Fix includes * Promote changed tests * Modify `lib-extensions` tests --------- Co-authored-by: Diana Kalinichenko <dkalinichenko@janestreet.com>
1 parent 3d71567 commit 6eba90d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1479
-1472
lines changed

otherlibs/stable/dune

-8
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,10 @@
4444
(deps
4545
(glob_files ../stdlib_stable/*.{ml,mli}))
4646
(targets
47-
float_u.ml
48-
float_u.mli
4947
iarray.ml
5048
iarray.mli
5149
iarrayLabels.ml
5250
iarrayLabels.mli
53-
int32_u.ml
54-
int32_u.mli
55-
int64_u.ml
56-
int64_u.mli
57-
nativeint_u.ml
58-
nativeint_u.mli
5951
stable.ml
6052
stable.mli)
6153
(action
-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
module Float_u = Float_u
2-
module Int32_u = Int32_u
3-
module Int64_u = Int64_u
4-
module Nativeint_u = Nativeint_u
51
module Iarray = Iarray
62
module IarrayLabels = IarrayLabels
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
module Float_u = Float_u
2-
module Int32_u = Int32_u
3-
module Int64_u = Int64_u
4-
module Nativeint_u = Nativeint_u
51
module Iarray = Iarray
62
module IarrayLabels = IarrayLabels

otherlibs/stdlib_stable/float_u.ml renamed to otherlibs/stdlib_upstream_compatible/float_u.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ open! Stdlib
1919

2020
type t = float#
2121

22-
external to_float : t -> (float[@local_opt]) = "%box_float"
22+
external to_float : t -> (float[@local_opt]) = "%box_float" [@@warning "-187"]
2323

24-
external of_float : (float[@local_opt]) -> t = "%unbox_float"
24+
external of_float : (float[@local_opt]) -> t = "%unbox_float" [@@warning "-187"]
2525

2626
(* CR layouts: Investigate whether it's worth making these things externals.
2727
Are there situations where the middle-end won't inline them and remove the

otherlibs/stdlib_stable/float_u.mli renamed to otherlibs/stdlib_upstream_compatible/float_u.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ type t = float#
5151
[infinity]) when we we support [float64]s in structures. *)
5252

5353
(* Unboxed-specific stuff at the top. *)
54-
external to_float : t -> (float[@local_opt]) = "%box_float"
54+
external to_float : t -> (float[@local_opt]) = "%box_float" [@@warning "-187"]
5555
(** Box a [float#] *)
5656

57-
external of_float : (float[@local_opt]) -> t = "%unbox_float"
57+
external of_float : (float[@local_opt]) -> t = "%unbox_float" [@@warning "-187"]
5858
(** Unbox a boxed [float] *)
5959

6060
(* Below here, everything also appears in [Float], though most things are

otherlibs/stdlib_stable/int32_u.ml renamed to otherlibs/stdlib_upstream_compatible/int32_u.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ open! Stdlib
1919

2020
type t = int32#
2121

22-
external to_int32 : t -> (int32[@local_opt]) = "%box_int32"
22+
external to_int32 : t -> (int32[@local_opt]) = "%box_int32" [@@warning "-187"]
2323

24-
external of_int32 : (int32[@local_opt]) -> t = "%unbox_int32"
24+
external of_int32 : (int32[@local_opt]) -> t = "%unbox_int32" [@@warning "-187"]
2525

2626
let[@inline always] neg x = of_int32 (Int32.neg (to_int32 x))
2727

otherlibs/stdlib_stable/int32_u.mli renamed to otherlibs/stdlib_upstream_compatible/int32_u.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ type t = int32#
4343
*)
4444

4545
(* Unboxed-specific stuff at the top. *)
46-
external to_int32 : t -> (int32[@local_opt]) = "%box_int32"
46+
external to_int32 : t -> (int32[@local_opt]) = "%box_int32" [@@warning "-187"]
4747
(** Box a [int32#] *)
4848

49-
external of_int32 : (int32[@local_opt]) -> t = "%unbox_int32"
49+
external of_int32 : (int32[@local_opt]) -> t = "%unbox_int32" [@@warning "-187"]
5050
(** Unbox a boxed [int32] *)
5151

5252
(* Below here, everything also appears in [Int32], though most things are

otherlibs/stdlib_stable/int64_u.ml renamed to otherlibs/stdlib_upstream_compatible/int64_u.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ open! Stdlib
1919

2020
type t = int64#
2121

22-
external to_int64 : t -> (int64[@local_opt]) = "%box_int64"
22+
external to_int64 : t -> (int64[@local_opt]) = "%box_int64" [@@warning "-187"]
2323

24-
external of_int64 : (int64[@local_opt]) -> t = "%unbox_int64"
24+
external of_int64 : (int64[@local_opt]) -> t = "%unbox_int64" [@@warning "-187"]
2525

2626
let[@inline always] neg x = of_int64 (Int64.neg (to_int64 x))
2727

otherlibs/stdlib_stable/int64_u.mli renamed to otherlibs/stdlib_upstream_compatible/int64_u.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ type t = int64#
4343
*)
4444

4545
(* Unboxed-specific stuff at the top. *)
46-
external to_int64 : t -> (int64[@local_opt]) = "%box_int64"
46+
external to_int64 : t -> (int64[@local_opt]) = "%box_int64" [@@warning "-187"]
4747
(** Box a [int64#] *)
4848

49-
external of_int64 : (int64[@local_opt]) -> t = "%unbox_int64"
49+
external of_int64 : (int64[@local_opt]) -> t = "%unbox_int64" [@@warning "-187"]
5050
(** Unbox a boxed [int64] *)
5151

5252
(* Below here, everything also appears in [Int64], though most things are

otherlibs/stdlib_stable/nativeint_u.ml renamed to otherlibs/stdlib_upstream_compatible/nativeint_u.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ open! Stdlib
1919

2020
type t = nativeint#
2121

22-
external to_nativeint : t -> (nativeint[@local_opt]) = "%box_nativeint"
22+
external to_nativeint : t -> (nativeint[@local_opt]) = "%box_nativeint" [@@warning "-187"]
2323

2424
external of_nativeint : (nativeint[@local_opt]) -> t =
25-
"%unbox_nativeint"
25+
"%unbox_nativeint" [@@warning "-187"]
2626

2727
let[@inline always] neg x = of_nativeint (Nativeint.neg (to_nativeint x))
2828

otherlibs/stdlib_stable/nativeint_u.mli renamed to otherlibs/stdlib_upstream_compatible/nativeint_u.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ type t = nativeint#
4444
*)
4545

4646
(* Unboxed-specific stuff at the top. *)
47-
external to_nativeint : t -> (nativeint[@local_opt]) = "%box_nativeint"
47+
external to_nativeint : t -> (nativeint[@local_opt]) = "%box_nativeint" [@@warning "-187"]
4848
(** Box a [nativeint#] *)
4949

5050
external of_nativeint : (nativeint[@local_opt]) -> t =
51-
"%unbox_nativeint"
51+
"%unbox_nativeint" [@@warning "-187"]
5252
(** Unbox a boxed [nativeint] *)
5353

5454
(* Below here, everything also appears in [Nativeint], though most things are
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Float_u = Float_u
2+
module Int32_u = Int32_u
3+
module Int64_u = Int64_u
4+
module Nativeint_u = Nativeint_u
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Float_u = Float_u
2+
module Int32_u = Int32_u
3+
module Int64_u = Int64_u
4+
module Nativeint_u = Nativeint_u

otherlibs/upstream_compatible/dune

+11-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@
4444
(rule
4545
(deps
4646
(glob_files ../stdlib_upstream_compatible/*.{ml,mli}))
47-
(targets upstream_compatible.ml upstream_compatible.mli)
47+
(targets
48+
float_u.ml
49+
float_u.mli
50+
int32_u.ml
51+
int32_u.mli
52+
int64_u.ml
53+
int64_u.mli
54+
nativeint_u.ml
55+
nativeint_u.mli
56+
upstream_compatible.ml
57+
upstream_compatible.mli)
4858
(action
4959
(bash
5060
"cp ../stdlib_upstream_compatible/*.{ml,mli} .; mv stdlib_upstream_compatible.ml upstream_compatible.ml; mv stdlib_upstream_compatible.mli upstream_compatible.mli")))

testsuite/tests/mixed-blocks/constructor_args.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
flags = "-extension layouts_beta -extension small_numbers";
33
include beta;
44
flambda2;
5-
include stable;
5+
include stdlib_upstream_compatible;
66
{
77
native;
88
}{
@@ -15,10 +15,10 @@
1515

1616
module Float32_u = Beta.Float32_u
1717
module Float32 = Beta.Float32
18-
module Float_u = Stable.Float_u
19-
module Int32_u = Stable.Int32_u
20-
module Int64_u = Stable.Int64_u
21-
module Nativeint_u = Stable.Nativeint_u
18+
module Float_u = Stdlib_upstream_compatible.Float_u
19+
module Int32_u = Stdlib_upstream_compatible.Int32_u
20+
module Int64_u = Stdlib_upstream_compatible.Int64_u
21+
module Nativeint_u = Stdlib_upstream_compatible.Nativeint_u
2222

2323
let print_floatu prefix x = Printf.printf "%s: %.2f\n" prefix (Float_u.to_float x)
2424
let print_float prefix x = Printf.printf "%s: %.2f\n" prefix x

testsuite/tests/mixed-blocks/generate_mixed_blocks_code.ml

+9-9
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ let type_to_field_integrity_check type_ ~access1 ~access2 ~message =
233233
| Str -> "check_string", None
234234
| Imm -> "check_int", None
235235
| Float -> "check_float", None
236-
| Float64 -> "check_float", Some "Stable.Float_u.to_float"
236+
| Float64 -> "check_float", Some "Stdlib_upstream_compatible.Float_u.to_float"
237237
| Float32 -> "check_float32", Some "Beta.Float32_u.to_float32"
238-
| Bits32 -> "check_int32", Some "Stable.Int32_u.to_int32"
239-
| Bits64 -> "check_int64", Some "Stable.Int64_u.to_int64"
240-
| Word -> "check_int", Some "Stable.Nativeint_u.to_int"
238+
| Bits32 -> "check_int32", Some "Stdlib_upstream_compatible.Int32_u.to_int32"
239+
| Bits64 -> "check_int64", Some "Stdlib_upstream_compatible.Int64_u.to_int64"
240+
| Word -> "check_int", Some "Stdlib_upstream_compatible.Nativeint_u.to_int"
241241
in
242242
let transform access =
243243
match transformation with
@@ -567,7 +567,7 @@ let main n ~bytecode =
567567
line {|(* TEST
568568
flags = "-extension layouts_beta -extension small_numbers";
569569
include beta;
570-
include stable;|};
570+
include stdlib_upstream_compatible;|};
571571
if bytecode then (
572572
line {| bytecode;|};
573573
) else (
@@ -582,11 +582,11 @@ let main n ~bytecode =
582582
line {|let create_int () = Random.int 0x3FFF_FFFF|};
583583
line {|let create_float () = Random.float Float.max_float|};
584584
line {|let create_float32 () = Beta.Float32.of_float (Random.float Float.max_float)|};
585-
line {|let create_float_u () = Stable.Float_u.of_float (create_float ())|};
585+
line {|let create_float_u () = Stdlib_upstream_compatible.Float_u.of_float (create_float ())|};
586586
line {|let create_float32_u () = Beta.Float32_u.of_float32 (create_float32 ())|};
587-
line {|let create_int32_u () = Stable.Int32_u.of_int32 (Random.int32 0x7FFF_FFFFl)|};
588-
line {|let create_int64_u () = Stable.Int64_u.of_int64 (Random.int64 0x7FFF_FFFF_FFFF_FFFFL)|};
589-
line {|let create_nativeint_u () = Stable.Nativeint_u.of_nativeint (Random.nativeint 0x7FFF_FFFF_FFFF_FFFFn)|};
587+
line {|let create_int32_u () = Stdlib_upstream_compatible.Int32_u.of_int32 (Random.int32 0x7FFF_FFFFl)|};
588+
line {|let create_int64_u () = Stdlib_upstream_compatible.Int64_u.of_int64 (Random.int64 0x7FFF_FFFF_FFFF_FFFFL)|};
589+
line {|let create_nativeint_u () = Stdlib_upstream_compatible.Nativeint_u.of_nativeint (Random.nativeint 0x7FFF_FFFF_FFFF_FFFFn)|};
590590
line
591591
{|let check_gen ~equal ~to_string ~message y1 y2 =
592592
if equal y1 y2 then () else

0 commit comments

Comments
 (0)