Skip to content

Commit

Permalink
flambda-backend: Remove Obj.set_tag and Obj.truncate (ocaml-flambda#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshinwell authored Jul 6, 2021
1 parent d9017ae commit 8a87272
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
2 changes: 0 additions & 2 deletions stdlib/obj.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ external magic : 'a -> 'b = "%identity"
external is_int : t -> bool = "%obj_is_int"
let [@inline always] is_block a = not (is_int a)
external tag : t -> int = "caml_obj_tag" [@@noalloc]
external set_tag : t -> int -> unit = "caml_obj_set_tag"
external size : t -> int = "%obj_size"
external reachable_words : t -> int = "caml_obj_reachable_words"
external field : t -> int -> t = "%obj_field"
Expand All @@ -47,7 +46,6 @@ external set_raw_field : t -> int -> raw_data -> unit

external new_block : int -> int -> t = "caml_obj_block"
external dup : t -> t = "caml_obj_dup"
external truncate : t -> int -> unit = "caml_obj_truncate"
external add_offset : t -> Int32.t -> t = "caml_obj_add_offset"
external with_tag : int -> t -> t = "caml_obj_with_tag"

Expand Down
14 changes: 3 additions & 11 deletions stdlib/obj.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,16 @@ external field : t -> int -> t = "%obj_field"

(** When using flambda:
[set_field] MUST NOT be called on immutable blocks. (Blocks allocated
in C stubs, or with [new_block] below, are always considered mutable.)
The same goes for [set_double_field] and [set_tag]. However, for
[set_tag], in the case of immutable blocks where the middle-end optimizers
never see code that discriminates on their tag (for example records), the
operation should be safe. Such uses are nonetheless discouraged.
[set_field] and [set_double_field] MUST NOT be called on immutable
blocks. (Blocks allocated in C stubs, or with [new_block] below,
are always considered mutable.)
For experts only:
[set_field] et al can be made safe by first wrapping the block in
{!Sys.opaque_identity}, so any information about its contents will not
be propagated.
*)
external set_field : t -> int -> t -> unit = "%obj_set_field"
external set_tag : t -> int -> unit = "caml_obj_set_tag"
[@@ocaml.deprecated "Use with_tag instead."]

val [@inline always] double_field : t -> int -> float (* @since 3.11.2 *)
val [@inline always] set_double_field : t -> int -> float -> unit
Expand All @@ -75,8 +69,6 @@ external set_raw_field : t -> int -> raw_data -> unit

external new_block : int -> int -> t = "caml_obj_block"
external dup : t -> t = "caml_obj_dup"
external truncate : t -> int -> unit = "caml_obj_truncate"
[@@ocaml.deprecated]
external add_offset : t -> Int32.t -> t = "caml_obj_add_offset"
(* @since 3.12.0 *)
external with_tag : int -> t -> t = "caml_obj_with_tag"
Expand Down

0 comments on commit 8a87272

Please sign in to comment.