Skip to content

Commit aec61ab

Browse files
v0.18~preview.130.31+242
1 parent afb2fd6 commit aec61ab

File tree

112 files changed

+6094
-3742
lines changed

Some content is hidden

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

112 files changed

+6094
-3742
lines changed

base.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ depends: [
2020
"sexplib0"
2121
"dune" {>= "3.17.0"}
2222
"dune-configurator"
23-
"ppxlib" {>= "0.33.0"}
23+
"ppxlib" {>= "0.33.0" & < "0.36.0"}
2424
]
2525
available: arch != "arm32" & arch != "x86_32"
2626
synopsis: "Full standard library replacement for OCaml"

src/array.ml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ include Array0
55
type 'a t = 'a array
66
[@@deriving compare ~localize, globalize, sexp ~localize, sexp_grammar]
77

8+
[@@@warning "-incompatible-with-upstream"]
9+
810
(* This module implements a new in-place, constant heap sorting algorithm to replace the
911
one used by the standard libraries. Its only purpose is to be faster (hopefully
1012
strictly faster) than the base sort and stable_sort.
@@ -34,7 +36,7 @@ type 'a t = 'a array
3436
- http://www.sorting-algorithms.com/quick-sort-3-way *)
3537

3638
module%template.portable
37-
[@modality p] Sorter (S : sig
39+
[@kind k = (value, immediate, immediate64)] [@modality p] Sorter (S : sig
3840
type 'a t
3941

4042
val get : 'a t -> int -> 'a
@@ -279,7 +281,8 @@ struct
279281
end
280282
[@@inline]
281283

282-
module%template Sort = Sorter [@modality portable] (struct
284+
module%template [@kind k = (value, immediate, immediate64)] Sort =
285+
Sorter [@kind k] [@modality portable] (struct
283286
type nonrec 'a t = 'a t
284287

285288
let get = unsafe_get
@@ -922,6 +925,11 @@ let sub t ~pos ~len = sub t ~pos ~len
922925
let invariant invariant_a t = iter t ~f:invariant_a
923926

924927
module Private = struct
925-
module Sort = Sort
926-
module%template.portable [@modality p] Sorter = Sorter [@modality p]
928+
module%template [@kind k = (value, immediate, immediate64)] Sort = Sort [@kind k]
929+
930+
module%template.portable
931+
[@kind k = (value, immediate, immediate64)] [@modality p] Sorter =
932+
Sorter
933+
[@kind k]
934+
[@modality p]
927935
end

src/array_intf.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
open! Import
44

5+
[@@@warning "-incompatible-with-upstream"]
6+
57
module Definitions = struct
68
module type Public = sig
79
type 'a t
@@ -311,7 +313,8 @@ module type Array = sig
311313
end
312314
end
313315

314-
module%template.portable Sorter (S : sig
316+
module%template.portable
317+
[@kind k = (value, immediate, immediate64)] Sorter (S : sig
315318
type 'a t
316319

317320
val get : 'a t -> int -> 'a

src/atomic.ml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ module Compare_failed_or_set_here = struct
77
[@@deriving sexp_of ~localize]
88
end
99

10-
type 'a t = 'a Stdlib.Atomic.t
10+
type 'a t = 'a Basement.Portable_atomic.t
1111

12-
let make = Stdlib.Atomic.make
13-
let make_alone = Stdlib.Atomic.make_contended
12+
let make = Basement.Portable_atomic.make
13+
14+
let make_alone =
15+
if Basement.Stdlib_shim.runtime5 ()
16+
then Basement.Portable_atomic.make_contended
17+
else
18+
(* [caml_atomic_make_contended] is not supported on runtime4; we can just fall back to
19+
regular make, which is semantically correct and we shouldn't be as worried about
20+
false sharing on single-core applications anyway. *)
21+
make
22+
;;
1423

1524
external get : ('a t[@local_opt]) -> 'a = "%atomic_load"
1625
external exchange : ('a t[@local_opt]) -> 'a -> 'a = "%atomic_exchange"
@@ -30,13 +39,17 @@ external compare_exchange
3039
-> 'a
3140
= "caml_atomic_compare_exchange_stub"
3241

42+
external is_runtime5 : unit -> bool = "caml_is_runtime5_stub"
43+
44+
let cpu_relax = if is_runtime5 () then Stdlib.Domain.cpu_relax else Fn.id
45+
3346
let rec update_and_return t ~pure_f =
3447
let old = get t in
3548
let new_ = pure_f old in
3649
match compare_and_set t ~if_phys_equal_to:old ~replace_with:new_ with
3750
| Set_here -> old
3851
| Compare_failed ->
39-
Stdlib.Domain.cpu_relax ();
52+
cpu_relax ();
4053
update_and_return t ~pure_f
4154
;;
4255

src/atomic.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module Compare_failed_or_set_here : sig
3535
[@@deriving sexp_of ~localize]
3636
end
3737

38-
type !'a t = 'a Stdlib.Atomic.t
38+
type !'a t = 'a Basement.Portable_atomic.t
3939

4040
[%%rederive: type nonrec !'a t = 'a t [@@deriving sexp_of]]
4141
[%%rederive: type nonrec !'a t = 'a t [@@deriving of_sexp]]

0 commit comments

Comments
 (0)