File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,26 @@ external magic : 'a -> 'b = "%identity"
24
24
external is_block : t -> bool = " caml_obj_is_block"
25
25
external is_int : t -> bool = " %obj_is_int"
26
26
external tag : t -> int = " caml_obj_tag"
27
- external set_tag : t -> int -> unit = " caml_obj_set_tag"
28
27
external size : t -> int = " %obj_size"
29
28
external field : t -> int -> t = " %obj_field"
30
29
31
30
(* * When using flambda:
31
+
32
32
[set_field] MUST NOT be called on immutable blocks. (Blocks allocated
33
- in C stubs, or with [new_block] below, are always considered mutable.) *)
33
+ in C stubs, or with [new_block] below, are always considered mutable.)
34
+
35
+ The same goes for [set_double_field] and [set_tag]. However, for
36
+ [set_tag], in the case of immutable blocks where the middle-end optimizers
37
+ never see code that discriminates on their tag (for example records), the
38
+ operation should be safe. Such uses are nonetheless discouraged.
39
+
40
+ For experts only:
41
+ [set_field] can be made safe by first wrapping the block in
42
+ [Sys.opaque_identity], so any information about its contents will not
43
+ be propagated.
44
+ *)
34
45
external set_field : t -> int -> t -> unit = " %obj_set_field"
46
+ external set_tag : t -> int -> unit = " caml_obj_set_tag"
35
47
36
48
val double_field : t -> int -> float (* @since 3.11.2 *)
37
49
val set_double_field : t -> int -> float -> unit (* @since 3.11.2 *)
You can’t perform that action at this time.
0 commit comments