Skip to content

Commit afb2a38

Browse files
authored
Backport lazy from OCaml 5 to runtime4 (#2038)
1 parent 8f5ff52 commit afb2a38

File tree

18 files changed

+311
-483
lines changed

18 files changed

+311
-483
lines changed

backend/cmm_helpers.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@ let get_header ptr dbg =
826826
data race on headers. This saves performance with ThreadSanitizer
827827
instrumentation by avoiding to instrument header loads. *)
828828
Cop
829-
( (if Config.runtime5 then mk_load_immut Word_int else mk_load_mut Word_int),
829+
( mk_load_mut Word_int,
830+
(* CR xclerc: consider whether that could be changed to mk_load_immut *)
830831
[Cop (Cadda, [ptr; Cconst_int (-size_int, dbg)], dbg)],
831832
dbg )
832833

middle_end/flambda2/terms/flambda_primitive.mli

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,14 @@ type unary_primitive =
327327
| Obj_dup (** Corresponds to [Obj.dup]; see the documentation in obj.mli. *)
328328
| Get_header
329329
(** Get the header of a block. This primitive is invalid if provided with
330-
an immediate value.
330+
an immediate value. It should also not be used to read tags above
331+
[No_scan_tag].
331332
Note: The GC color bits in the header are not reliable except for
332-
checking if the value is locally allocated *)
333+
checking if the value is locally allocated
334+
Invariant: never read the tag of a possibly-lazy value from
335+
ocamlopt-generated code. Tag reads that are allowed to be lazy tags
336+
(by the type system) should always go through caml_obj_tag, which is
337+
opaque to the compiler. *)
333338
| Atomic_load of Block_access_field_kind.t
334339

335340
(** Whether a comparison is to yield a boolean result, as given by a particular

0 commit comments

Comments
 (0)