Skip to content

Commit ce58545

Browse files
authored
flambda-backend: Revert "Move unboxed definitions from Stdlib to Stable" (#2580)
Revert "Move unboxed definitions from `Stdlib` to `Stable` (#2555)" This reverts commit 5dfa476.
1 parent 4f44650 commit ce58545

Some content is hidden

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

64 files changed

+1543
-1467
lines changed

Makefile.common-jst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ dune_config_targets = \
113113
$(ocamldir)/duneconf/dirs-to-ignore.inc \
114114
$(ocamldir)/duneconf/jst-extra.inc \
115115
dune-project \
116+
$(ocamldir)/stdlib/ocaml_compiler_internal_params \
116117
$(ocamldir)/dune.runtime_selection \
117118
$(ocamldir)/otherlibs/dune
118119

@@ -199,6 +200,12 @@ _install: compiler
199200
install: _install
200201
mkdir -p '$(prefix)'
201202
rsync --chmod=u+rw,go+r -rl _install/ '$(prefix)'
203+
rm -f '$(prefix)/lib/ocaml/ocaml_compiler_internal_params'
204+
# rm `ocaml_compiler_internal_params`, which is used to compile the
205+
# stdlib `Float_u` module with `-extension layouts_alpha`, because we
206+
# don't want user programs that happened to be named
207+
# `ocaml/stdlib/float_u.ml` to get the flag automatically.
208+
202209

203210
# Same as above, but relies on a successfull earlier _install
204211
install_for_opam:

otherlibs/stable/stable.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
module Float_u = Float_u
2-
module Int32_u = Int32_u
3-
module Int64_u = Int64_u
4-
module Nativeint_u = Nativeint_u
1+
module Float_u = Stdlib__Float_u
52
module Iarray = Stdlib__Iarray
63
module IarrayLabels = Stdlib__IarrayLabels

otherlibs/stable/stable.mli

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
module Float_u = Float_u
2-
module Int32_u = Int32_u
3-
module Int64_u = Int64_u
4-
module Nativeint_u = Nativeint_u
1+
module Float_u = Stdlib__Float_u
52
module Iarray = Stdlib__Iarray
63
module IarrayLabels = Stdlib__IarrayLabels

stdlib/.depend

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ stdlib__Float.cmx : float.ml \
358358
stdlib__Float.cmi : float.mli \
359359
stdlib.cmi \
360360
stdlib__Seq.cmi
361+
stdlib__Float_u.cmo : float_u.ml \
362+
stdlib.cmi \
363+
stdlib__Float.cmi \
364+
stdlib__Float_u.cmi
365+
stdlib__Float_u.cmx : float_u.ml \
366+
stdlib.cmx \
367+
stdlib__Float.cmx \
368+
stdlib__Float_u.cmi
369+
stdlib__Float_u.cmi : float_u.mli \
370+
stdlib.cmi
361371
stdlib__Format.cmo : format.ml \
362372
stdlib__String.cmi \
363373
stdlib.cmi \
@@ -512,6 +522,16 @@ stdlib__Int32.cmx : int32.ml \
512522
stdlib__Int32.cmi
513523
stdlib__Int32.cmi : int32.mli \
514524
stdlib.cmi
525+
stdlib__Int32_u.cmo : int32_u.ml \
526+
stdlib.cmi \
527+
stdlib__Int32.cmi \
528+
stdlib__Int32_u.cmi
529+
stdlib__Int32_u.cmx : int32_u.ml \
530+
stdlib.cmx \
531+
stdlib__Int32.cmx \
532+
stdlib__Int32_u.cmi
533+
stdlib__Int32_u.cmi : int32_u.mli \
534+
stdlib.cmi
515535
stdlib__Int64.cmo : int64.ml \
516536
stdlib.cmi \
517537
stdlib__Int64.cmi
@@ -520,6 +540,20 @@ stdlib__Int64.cmx : int64.ml \
520540
stdlib__Int64.cmi
521541
stdlib__Int64.cmi : int64.mli \
522542
stdlib.cmi
543+
stdlib__Int64_u.cmo : int64_u.ml \
544+
stdlib__Nativeint_u.cmi \
545+
stdlib__Int32_u.cmi \
546+
stdlib.cmi \
547+
stdlib__Int64.cmi \
548+
stdlib__Int64_u.cmi
549+
stdlib__Int64_u.cmx : int64_u.ml \
550+
stdlib__Nativeint_u.cmx \
551+
stdlib__Int32_u.cmx \
552+
stdlib.cmx \
553+
stdlib__Int64.cmx \
554+
stdlib__Int64_u.cmi
555+
stdlib__Int64_u.cmi : int64_u.mli \
556+
stdlib.cmi
523557
stdlib__Lazy.cmo : lazy.ml \
524558
stdlib.cmi \
525559
stdlib__Obj.cmi \
@@ -635,6 +669,18 @@ stdlib__Nativeint.cmx : nativeint.ml \
635669
stdlib__Nativeint.cmi
636670
stdlib__Nativeint.cmi : nativeint.mli \
637671
stdlib.cmi
672+
stdlib__Nativeint_u.cmo : nativeint_u.ml \
673+
stdlib__Int32_u.cmi \
674+
stdlib.cmi \
675+
stdlib__Nativeint.cmi \
676+
stdlib__Nativeint_u.cmi
677+
stdlib__Nativeint_u.cmx : nativeint_u.ml \
678+
stdlib__Int32_u.cmx \
679+
stdlib.cmx \
680+
stdlib__Nativeint.cmx \
681+
stdlib__Nativeint_u.cmi
682+
stdlib__Nativeint_u.cmi : nativeint_u.mli \
683+
stdlib.cmi
638684
stdlib__Obj.cmo : obj.ml \
639685
stdlib__Sys.cmi \
640686
stdlib.cmi \

stdlib/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,30 @@ stdlib.cmx: stdlib.ml
207207
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) \
208208
-pp "$(AWK) -f ./expand_module_aliases.awk" -c $<
209209

210+
211+
# special cases to add the extension flag when compiling float_u etc.
212+
# CR layouts: eventually these can be just [-extension layouts]
213+
stdlib__%_u.cmi:
214+
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha \
215+
-o $@ -c $(filter %.mli, $^)
216+
217+
stdlib__%_u.cmo:
218+
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha \
219+
-o $@ -c $(filter %.ml, $^)
220+
221+
stdlib__%_u.cmx:
222+
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) -extension layouts_alpha \
223+
-o $@ -c $(filter %.ml, $^)
224+
225+
%_u.cmi: %_u.mli
226+
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha -c $<
227+
228+
%_u.cmo: %_u.ml
229+
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha -c $<
230+
231+
%_u.cmx: %_u.ml
232+
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) -extension layouts_alpha -c $<
233+
210234
%.cmi: %.mli
211235
$(V_OCAMLC)$(CAMLC) $(COMPFLAGS) -c $<
212236

stdlib/StdlibModules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ STDLIB_MODULE_BASENAMES = \
5959
array \
6060
iarray \
6161
float \
62+
float_u \
6263
int32 \
64+
int32_u \
6365
nativeint \
66+
nativeint_u \
6467
int64 \
68+
int64_u \
6569
lexing \
6670
parsing \
6771
set \

stdlib/dune

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
(install
5858
(files
5959
Makefile.config
60+
ocaml_compiler_internal_params
6061
camlheader
6162
camlheaderd
6263
camlheaderi
@@ -121,6 +122,8 @@
121122
filename.mli
122123
float.ml
123124
float.mli
125+
float_u.ml
126+
float_u.mli
124127
format.ml
125128
format.mli
126129
fun.ml
@@ -139,8 +142,12 @@
139142
int.mli
140143
int32.ml
141144
int32.mli
145+
int32_u.ml
146+
int32_u.mli
142147
int64.ml
143148
int64.mli
149+
int64_u.ml
150+
int64_u.mli
144151
lazy.ml
145152
lazy.mli
146153
lexing.ml
@@ -159,6 +166,8 @@
159166
mutex.mli
160167
nativeint.ml
161168
nativeint.mli
169+
nativeint_u.ml
170+
nativeint_u.mli
162171
obj.ml
163172
obj.mli
164173
oo.ml
@@ -268,6 +277,9 @@
268277
.stdlib.objs/byte/stdlib__Float.cmi
269278
.stdlib.objs/byte/stdlib__Float.cmt
270279
.stdlib.objs/byte/stdlib__Float.cmti
280+
.stdlib.objs/byte/stdlib__Float_u.cmi
281+
.stdlib.objs/byte/stdlib__Float_u.cmt
282+
.stdlib.objs/byte/stdlib__Float_u.cmti
271283
.stdlib.objs/byte/stdlib__Format.cmi
272284
.stdlib.objs/byte/stdlib__Format.cmt
273285
.stdlib.objs/byte/stdlib__Format.cmti
@@ -295,9 +307,15 @@
295307
.stdlib.objs/byte/stdlib__Int32.cmi
296308
.stdlib.objs/byte/stdlib__Int32.cmt
297309
.stdlib.objs/byte/stdlib__Int32.cmti
310+
.stdlib.objs/byte/stdlib__Int32_u.cmi
311+
.stdlib.objs/byte/stdlib__Int32_u.cmt
312+
.stdlib.objs/byte/stdlib__Int32_u.cmti
298313
.stdlib.objs/byte/stdlib__Int64.cmi
299314
.stdlib.objs/byte/stdlib__Int64.cmt
300315
.stdlib.objs/byte/stdlib__Int64.cmti
316+
.stdlib.objs/byte/stdlib__Int64_u.cmi
317+
.stdlib.objs/byte/stdlib__Int64_u.cmt
318+
.stdlib.objs/byte/stdlib__Int64_u.cmti
301319
.stdlib.objs/byte/stdlib__Lazy.cmi
302320
.stdlib.objs/byte/stdlib__Lazy.cmt
303321
.stdlib.objs/byte/stdlib__Lazy.cmti
@@ -325,6 +343,9 @@
325343
.stdlib.objs/byte/stdlib__Nativeint.cmi
326344
.stdlib.objs/byte/stdlib__Nativeint.cmt
327345
.stdlib.objs/byte/stdlib__Nativeint.cmti
346+
.stdlib.objs/byte/stdlib__Nativeint_u.cmi
347+
.stdlib.objs/byte/stdlib__Nativeint_u.cmt
348+
.stdlib.objs/byte/stdlib__Nativeint_u.cmti
328349
.stdlib.objs/byte/stdlib__Obj.cmi
329350
.stdlib.objs/byte/stdlib__Obj.cmt
330351
.stdlib.objs/byte/stdlib__Obj.cmti
@@ -435,10 +456,12 @@
435456
.stdlib.objs/native/stdlib__StdLabels.cmx
436457
.stdlib.objs/native/stdlib__Weak.cmx
437458
.stdlib.objs/native/stdlib__Float.cmx
459+
.stdlib.objs/native/stdlib__Float_u.cmx
438460
.stdlib.objs/native/stdlib__Fun.cmx
439461
.stdlib.objs/native/stdlib__Bigarray.cmx
440462
.stdlib.objs/native/stdlib__Array.cmx
441463
.stdlib.objs/native/stdlib__Int32.cmx
464+
.stdlib.objs/native/stdlib__Int32_u.cmx
442465
.stdlib.objs/native/stdlib__Lexing.cmx
443466
.stdlib.objs/native/stdlib__ArrayLabels.cmx
444467
.stdlib.objs/native/stdlib__Obj.cmx
@@ -459,6 +482,7 @@
459482
.stdlib.objs/native/stdlib__Ephemeron.cmx
460483
.stdlib.objs/native/stdlib__String.cmx
461484
.stdlib.objs/native/stdlib__Nativeint.cmx
485+
.stdlib.objs/native/stdlib__Nativeint_u.cmx
462486
.stdlib.objs/native/stdlib__Set.cmx
463487
.stdlib.objs/native/stdlib__ListLabels.cmx
464488
.stdlib.objs/native/stdlib__Bool.cmx
@@ -467,6 +491,7 @@
467491
.stdlib.objs/native/stdlib__Random.cmx
468492
.stdlib.objs/native/stdlib__Int.cmx
469493
.stdlib.objs/native/stdlib__Int64.cmx
494+
.stdlib.objs/native/stdlib__Int64_u.cmx
470495
.stdlib.objs/native/stdlib__Scanf.cmx
471496
.stdlib.objs/native/stdlib__Printf.cmx
472497
.stdlib.objs/native/stdlib__Complex.cmx
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

otherlibs/stable/int64_u.ml renamed to stdlib/int64_u.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ let[@inline always] of_nativeint x = of_int64 (Int64.of_nativeint x)
8484

8585
let[@inline always] to_nativeint x = Int64.to_nativeint (to_int64 x)
8686

87-
let[@inline always] of_int32_u x = of_int64 (Int64.of_int32 (Int32_u.to_int32 x))
87+
let[@inline always] of_int32_u x = of_int64 (Int64.of_int32 (Stdlib__Int32_u.to_int32 x))
8888

89-
let[@inline always] to_int32_u x = Int32_u.of_int32 (Int64.to_int32 (to_int64 x))
89+
let[@inline always] to_int32_u x = Stdlib__Int32_u.of_int32 (Int64.to_int32 (to_int64 x))
9090

9191
let[@inline always] of_nativeint_u x =
92-
of_int64 (Int64.of_nativeint (Nativeint_u.to_nativeint x))
92+
of_int64 (Int64.of_nativeint (Stdlib__Nativeint_u.to_nativeint x))
9393

9494
let[@inline always] to_nativeint_u x =
95-
Nativeint_u.of_nativeint (Int64.to_nativeint (to_int64 x))
95+
Stdlib__Nativeint_u.of_nativeint (Int64.to_nativeint (to_int64 x))
9696

9797
let[@inline always] bits_of_float x = of_int64 (Int64.bits_of_float x)
9898

File renamed without changes.

otherlibs/stable/nativeint_u.ml renamed to stdlib/nativeint_u.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ let[@inline always] of_int32 x = of_nativeint (Nativeint.of_int32 x)
9797
let[@inline always] to_int32 x = Nativeint.to_int32 (to_nativeint x)
9898

9999
let[@inline always] of_int32_u x =
100-
of_nativeint (Nativeint.of_int32 (Int32_u.to_int32 x))
100+
of_nativeint (Nativeint.of_int32 (Stdlib__Int32_u.to_int32 x))
101101

102102
let[@inline always] to_int32_u x =
103-
Int32_u.of_int32 (Nativeint.to_int32 (to_nativeint x))
103+
Stdlib__Int32_u.of_int32 (Nativeint.to_int32 (to_nativeint x))
104104

105105
let[@inline always] of_string x = of_nativeint (Nativeint.of_string x)
106106

File renamed without changes.

stdlib/ocaml_compiler_internal_params

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ocaml/stdlib/float_u.mli : extension = layouts_alpha
2+
ocaml/stdlib/float_u.ml : extension = layouts_alpha
3+
stdlib/float_u.mli : extension = layouts_alpha
4+
stdlib/float_u.ml : extension = layouts_alpha
5+
ocaml/stdlib/nativeint_u.mli : extension = layouts_alpha
6+
ocaml/stdlib/nativeint_u.ml : extension = layouts_alpha
7+
ocaml/stdlib/int32_u.mli : extension = layouts_alpha
8+
ocaml/stdlib/int32_u.ml : extension = layouts_alpha
9+
ocaml/stdlib/int64_u.mli : extension = layouts_alpha
10+
ocaml/stdlib/int64_u.ml : extension = layouts_alpha

testsuite/tests/mixed-blocks/constructor_args.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
flags = "-extension layouts_beta -extension small_numbers";
33
include beta;
44
flambda2;
5-
include stable;
65
{
76
native;
87
}{
@@ -14,10 +13,10 @@
1413
(* Prelude: Functions on unboxed numbers *)
1514

1615
module Float32_u = Beta.Float32_u
17-
module Float_u = Stable.Float_u
18-
module Int32_u = Stable.Int32_u
19-
module Int64_u = Stable.Int64_u
20-
module Nativeint_u = Stable.Nativeint_u
16+
module Float_u = Stdlib__Float_u
17+
module Int32_u = Stdlib__Int32_u
18+
module Int64_u = Stdlib__Int64_u
19+
module Nativeint_u = Stdlib__Nativeint_u
2120

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

testsuite/tests/mixed-blocks/generate_mixed_blocks_code.ml

Lines changed: 9 additions & 10 deletions
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__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__Int32_u.to_int32"
239+
| Bits64 -> "check_int64", Some "Stdlib__Int64_u.to_int64"
240+
| Word -> "check_int", Some "Stdlib__Nativeint_u.to_int"
241241
in
242242
let transform access =
243243
match transformation with
@@ -566,8 +566,7 @@ let main n ~bytecode =
566566
in
567567
line {|(* TEST
568568
flags = "-extension layouts_beta -extension small_numbers";
569-
include beta;
570-
include stable;|};
569+
include beta;|};
571570
if bytecode then (
572571
line {| bytecode;|};
573572
) else (
@@ -582,11 +581,11 @@ let main n ~bytecode =
582581
line {|let create_int () = Random.int 0x3FFF_FFFF|};
583582
line {|let create_float () = Random.float Float.max_float|};
584583
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 ())|};
584+
line {|let create_float_u () = Stdlib__Float_u.of_float (create_float ())|};
586585
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)|};
586+
line {|let create_int32_u () = Stdlib__Int32_u.of_int32 (Random.int32 0x7FFF_FFFFl)|};
587+
line {|let create_int64_u () = Stdlib__Int64_u.of_int64 (Random.int64 0x7FFF_FFFF_FFFF_FFFFL)|};
588+
line {|let create_nativeint_u () = Stdlib__Nativeint_u.of_nativeint (Random.nativeint 0x7FFF_FFFF_FFFF_FFFFn)|};
590589
line
591590
{|let check_gen ~equal ~to_string ~message y1 y2 =
592591
if equal y1 y2 then () else

0 commit comments

Comments
 (0)