Skip to content

Commit

Permalink
Remove unused set_tag from compiler internals.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed Mar 24, 2023
1 parent 4877a70 commit 18983b1
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 13 deletions.
1 change: 0 additions & 1 deletion jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ and expression_desc =
you have to use [E.tag] in a safe way
*)
| Caml_block_tag of expression
(* | Caml_block_set_tag of expression * expression *)
(* | Caml_block_set_length of expression * expression *)
(* It will just fetch tag, to make it safe, when creating it,
we need apply "|0", we don't do it in the
Expand Down
1 change: 0 additions & 1 deletion jscomp/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
| Length (e, _) | Caml_block_tag e | Typeof e -> no_side_effect e
| Bin (op, a, b) -> op <> Eq && no_side_effect a && no_side_effect b
| Js_not _ | Cond _ | FlatCall _ | Call _ | New _ | Raw_js_code _
(* | Caml_block_set_tag _ *)
(* actually true? *) ->
false
| Await _ -> false
Expand Down
2 changes: 0 additions & 2 deletions jscomp/others/belt_internals.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ module Obj : sig
external field : t -> int -> t = "%obj_field"
external set_field : t -> int -> t -> unit = "%obj_set_field"
external tag : t -> int = "?obj_tag"
(* The compiler ensures (|0) operation *)
external set_tag : t -> int -> unit = "TAG" [@@bs.set]
external repr : 'a -> t = "%identity"
external obj : t -> 'a = "%identity"
external magic : 'a -> 'b = "%identity"
Expand Down
2 changes: 0 additions & 2 deletions jscomp/runtime/bs_stdlib_mini.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ module Obj : sig
external field : t -> int -> t = "%obj_field"
external set_field : t -> int -> t -> unit = "%obj_set_field"
external tag : t -> int = "?obj_tag"
(* The compiler ensures (|0) operation *)
external set_tag : t -> int -> unit = "TAG" [@@bs.set]
external repr : 'a -> t = "%identity"
external obj : t -> 'a = "%identity"
external magic : 'a -> 'b = "%identity"
Expand Down
1 change: 0 additions & 1 deletion jscomp/stdlib-406/camlinternalLazy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ exception Undefined

let%private forward_with_closure (type a ) (blk : a t) (closure : unit -> a [@bs]) : a =
let result = closure () [@bs] in
(* do set_field BEFORE set_tag *)
blk.value <- result;
blk.tag<- true;
result
Expand Down
7 changes: 1 addition & 6 deletions jscomp/stdlib-406/obj.mli
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ external field : t -> int -> t = "%obj_field"
[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.
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
Expand Down

0 comments on commit 18983b1

Please sign in to comment.