Skip to content

Remove obsolete pack-related code #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 5 additions & 41 deletions middle_end/flambda2/identifiers/continuation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ end
module Data = struct
type t =
{ compilation_unit : Compilation_unit.t;
previous_compilation_units : Compilation_unit.t list;
name : string;
name_stamp : int;
sort : Sort.t
Expand All @@ -64,8 +63,7 @@ module Data = struct
let flags = continuation_flags

let [@ocamlformat "disable"] print ppf
{ compilation_unit; name; name_stamp; sort;
previous_compilation_units = _; } =
{ compilation_unit; name; name_stamp; sort; } =
Format.fprintf ppf "@[<hov 1>(\
@[<hov 1>(compilation_unit@ %a)@]@ \
@[<hov 1>(name@ %s)@]@ \
Expand All @@ -77,42 +75,29 @@ module Data = struct
name_stamp
Sort.print sort

let hash
{ compilation_unit;
previous_compilation_units;
name = _;
name_stamp;
sort = _
} =
Hashtbl.hash
( List.map Compilation_unit.hash
(compilation_unit :: previous_compilation_units),
name_stamp )
let hash { compilation_unit; name = _; name_stamp; sort = _ } =
Hashtbl.hash (Compilation_unit.hash compilation_unit, name_stamp)

let equal t1 t2 =
if t1 == t2
then true
else
let { compilation_unit = compilation_unit1;
name_stamp = name_stamp1;
previous_compilation_units = previous_compilation_units1;
name = _;
sort = _
} =
t1
in
let { compilation_unit = compilation_unit2;
name_stamp = name_stamp2;
previous_compilation_units = previous_compilation_units2;
name = _;
sort = _
} =
t2
in
Int.equal name_stamp1 name_stamp2
&& Compilation_unit.equal compilation_unit1 compilation_unit2
&& List.equal Compilation_unit.equal previous_compilation_units1
previous_compilation_units2
end

type t = Id.t
Expand All @@ -131,24 +116,14 @@ let create ?sort ?name () : t =
let sort = Option.value sort ~default:Sort.Normal_or_exn in
let name = Option.value name ~default:"k" in
let compilation_unit = Compilation_unit.get_current_exn () in
let previous_compilation_units = [] in
let name_stamp = next_stamp () in
let data : Data.t =
{ compilation_unit; previous_compilation_units; name; name_stamp; sort }
in
let data : Data.t = { compilation_unit; name; name_stamp; sort } in
Table.add !grand_table_of_continuations data

let find_data t = Table.find !grand_table_of_continuations t

let rename t =
let { Data.name;
sort;
name_stamp = _;
compilation_unit = _;
previous_compilation_units = _
} =
find_data t
in
let { Data.name; sort; name_stamp = _; compilation_unit = _ } = find_data t in
create ~sort ~name ()

let name t = (find_data t).name
Expand Down Expand Up @@ -187,14 +162,3 @@ module Map = Tree.Map
let export t = find_data t

let import data = Table.add !grand_table_of_continuations data

let map_compilation_unit f (data : Data.t) : Data.t =
let new_compilation_unit = f data.compilation_unit in
if Compilation_unit.equal new_compilation_unit data.compilation_unit
then data
else
{ data with
compilation_unit = new_compilation_unit;
previous_compilation_units =
data.compilation_unit :: data.previous_compilation_units
}
3 changes: 0 additions & 3 deletions middle_end/flambda2/identifiers/continuation.mli
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ val export : t -> exported

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported

val initialise : unit -> unit

val reset : unit -> unit
61 changes: 4 additions & 57 deletions middle_end/flambda2/identifiers/int_ids.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,15 @@ end
module Variable_data = struct
type t =
{ compilation_unit : Compilation_unit.t;
previous_compilation_units : Compilation_unit.t list;
name : string;
name_stamp : int;
user_visible : bool
}

let flags = var_flags

let [@ocamlformat "disable"] print ppf { compilation_unit; previous_compilation_units = _;
name; name_stamp; user_visible; } =
let [@ocamlformat "disable"] print ppf { compilation_unit; name; name_stamp;
user_visible; } =
Format.fprintf ppf "@[<hov 1>(\
@[<hov 1>(compilation_unit@ %a)@]@ \
@[<hov 1>(name@ %s)@]@ \
Expand All @@ -161,54 +160,29 @@ module Variable_data = struct
name_stamp
user_visible

let hash
{ compilation_unit;
previous_compilation_units;
name = _;
name_stamp;
user_visible = _
} =
let compilation_unit_hashes =
List.fold_left
(fun hash compilation_unit ->
hash2 hash (Compilation_unit.hash compilation_unit))
(Compilation_unit.hash compilation_unit)
previous_compilation_units
in
hash2 compilation_unit_hashes (Hashtbl.hash name_stamp)
let hash { compilation_unit; name = _; name_stamp; user_visible = _ } =
hash2 (Compilation_unit.hash compilation_unit) (Hashtbl.hash name_stamp)

let equal t1 t2 =
if t1 == t2
then true
else
let { compilation_unit = compilation_unit1;
previous_compilation_units = previous_compilation_units1;
name = _;
name_stamp = name_stamp1;
user_visible = _
} =
t1
in
let { compilation_unit = compilation_unit2;
previous_compilation_units = previous_compilation_units2;
name = _;
name_stamp = name_stamp2;
user_visible = _
} =
t2
in
let rec previous_compilation_units_match l1 l2 =
match l1, l2 with
| [], [] -> true
| [], _ :: _ | _ :: _, [] -> false
| unit1 :: tl1, unit2 :: tl2 ->
Compilation_unit.equal unit1 unit2
&& previous_compilation_units_match tl1 tl2
in
Int.equal name_stamp1 name_stamp2
&& Compilation_unit.equal compilation_unit1 compilation_unit2
&& previous_compilation_units_match previous_compilation_units1
previous_compilation_units2
end

module Symbol0 = Flambda2_import.Symbol
Expand Down Expand Up @@ -340,10 +314,6 @@ module Const = struct
let export t = find_data t

let import (data : exported) = create data

let map_compilation_unit _f data =
(* No compilation unit in the data *)
data
end

module Variable = struct
Expand Down Expand Up @@ -377,7 +347,6 @@ module Variable = struct
in
let data : Variable_data.t =
{ compilation_unit = Compilation_unit.get_current_exn ();
previous_compilation_units = [];
name;
name_stamp;
user_visible = Option.is_some user_visible
Expand Down Expand Up @@ -419,17 +388,6 @@ module Variable = struct
let export t = find_data t

let import (data : exported) = Table.add !grand_table_of_variables data

let map_compilation_unit f (data : exported) : exported =
let new_compilation_unit = f data.compilation_unit in
if Compilation_unit.equal new_compilation_unit data.compilation_unit
then data
else
{ data with
compilation_unit = new_compilation_unit;
previous_compilation_units =
data.compilation_unit :: data.previous_compilation_units
}
end

module Symbol = struct
Expand Down Expand Up @@ -505,9 +463,6 @@ module Symbol = struct
let export t = find_data t

let import (data : exported) = Table.add !grand_table_of_symbols data

let map_compilation_unit f (data : exported) : exported =
Symbol0.with_compilation_unit data (f (Symbol0.compilation_unit data))
end

module Name = struct
Expand Down Expand Up @@ -709,11 +664,6 @@ module Simple = struct
that the real import functions (in Renaming) are responsible for
importing the underlying name/const. *)
Table.add !grand_table_of_simples data

let map_compilation_unit _f data =
(* The compilation unit is not associated with the simple directly, only
with the underlying name, which has its own entry. *)
data
end

module Code_id = struct
Expand Down Expand Up @@ -794,9 +744,6 @@ module Code_id = struct
let export t = find_data t

let import (data : exported) = Table.add !grand_table_of_code_ids data

let map_compilation_unit f (data : exported) : exported =
{ data with compilation_unit = f data.compilation_unit }
end

module Code_id_or_symbol = struct
Expand Down
15 changes: 0 additions & 15 deletions middle_end/flambda2/identifiers/int_ids.mli
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ module Const : sig
val export : t -> exported

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported
end

module Variable : sig
Expand All @@ -102,9 +99,6 @@ module Variable : sig
val export : t -> exported

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported
end

module Symbol : sig
Expand Down Expand Up @@ -133,9 +127,6 @@ module Symbol : sig

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported

val external_symbols_compilation_unit : unit -> Compilation_unit.t
end

Expand Down Expand Up @@ -198,9 +189,6 @@ module Simple : sig
val export : t -> exported

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported
end

module Code_id : sig
Expand Down Expand Up @@ -235,9 +223,6 @@ module Code_id : sig
val export : t -> exported

val import : exported -> t

val map_compilation_unit :
(Compilation_unit.t -> Compilation_unit.t) -> exported -> exported
end

module Code_id_or_symbol : sig
Expand Down
8 changes: 0 additions & 8 deletions middle_end/symbol_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,4 @@ module Flambda = struct
let for_code_of_closure closure_id =
Symbol.for_name (Closure_id.get_compilation_unit closure_id)
(Closure_id.unique_name closure_id)

(* CR-soon lmaurer: Be rid of this when we have prefixes set correctly to begin
with *)
let import_for_pack symbol ~pack =
let compilation_unit =
CU.with_for_pack_prefix (Symbol.compilation_unit symbol) pack
in
Symbol.with_compilation_unit symbol compilation_unit
end
2 changes: 0 additions & 2 deletions middle_end/symbol_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ module Flambda : sig
val for_variable : Variable.t -> Symbol.t
val for_closure : Closure_id.t -> Symbol.t
val for_code_of_closure : Closure_id.t -> Symbol.t

val import_for_pack : Symbol.t -> pack:Compilation_unit.Prefix.t -> Symbol.t
end
10 changes: 0 additions & 10 deletions ocaml/middle_end/symbol_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

[@@@ocaml.warning "+a-9-30-40-41-42"]

module CU = Compilation_unit

module Flambda = struct
let for_variable var =
Symbol.for_name (Variable.get_compilation_unit var) (Variable.unique_name var)
Expand All @@ -29,12 +27,4 @@ module Flambda = struct
let for_code_of_closure closure_id =
Symbol.for_name (Closure_id.get_compilation_unit closure_id)
(Closure_id.unique_name closure_id)

(* CR-soon lmaurer: Be rid of this when we have prefixes set correctly to begin
with *)
let import_for_pack symbol ~pack =
let compilation_unit =
CU.with_for_pack_prefix (Symbol.compilation_unit symbol) pack
in
Symbol.with_compilation_unit symbol compilation_unit
end
2 changes: 0 additions & 2 deletions ocaml/middle_end/symbol_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ module Flambda : sig
val for_variable : Variable.t -> Symbol.t
val for_closure : Closure_id.t -> Symbol.t
val for_code_of_closure : Closure_id.t -> Symbol.t

val import_for_pack : Symbol.t -> pack:Compilation_unit.Prefix.t -> Symbol.t
end
6 changes: 0 additions & 6 deletions ocaml/utils/symbol.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ let linkage_name_for_ocamlobjinfo t =

let compilation_unit t = t.compilation_unit

let with_compilation_unit t compilation_unit = { t with compilation_unit }

(* CR-someday lmaurer: Would be nicer to have some of this logic in
[Linkage_name]; among other things, we could then define
[Linkage_name.for_current_unit] *)
Expand Down Expand Up @@ -121,10 +119,6 @@ let for_compilation_unit compilation_unit =
let for_current_unit () =
for_compilation_unit (CU.get_current_exn ())

let import_for_pack t ~pack =
let compilation_unit = CU.with_for_pack_prefix t.compilation_unit pack in
{ t with compilation_unit; }

let const_label = ref 0

let for_new_const_in_current_unit () =
Expand Down
4 changes: 0 additions & 4 deletions ocaml/utils/symbol.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ val for_compilation_unit : Compilation_unit.t -> t
val for_current_unit : unit -> t
val for_new_const_in_current_unit : unit -> t

val import_for_pack : t -> pack:Compilation_unit.Prefix.t -> t

val compilation_unit : t -> Compilation_unit.t

val with_compilation_unit : t -> Compilation_unit.t -> t

val linkage_name : t -> Linkage_name.t

(** Linkage names displayed in ocamlobjinfo are formatted differently. *)
Expand Down