From 009ae6ed58c161239dc8a706a20559a3576a419f Mon Sep 17 00:00:00 2001 From: Henri Verroken Date: Thu, 16 Sep 2021 04:41:36 -0700 Subject: [PATCH] Refactor: remove now unused Old/New Summary: In the previous diff (D30886288), I removed `NoCache`'s reliance on the somewhat confusing `New/Old` modules. Since they are now no longer used, let's remove them. Reviewed By: ljw1004 Differential Revision: D30886402 fbshipit-source-id: 34567a45c2c6b0c22c71ef57e6dc3203f06647df --- hphp/hack/src/heap/sharedMem.ml | 112 --------------------------------------- hphp/hack/src/heap/sharedMem.mli | 48 +++-------------- 2 files changed, 8 insertions(+), 152 deletions(-) diff --git a/hphp/hack/src/heap/sharedMem.ml b/hphp/hack/src/heap/sharedMem.ml index 870eb6c1149..41198917b52 100644 --- a/hphp/hack/src/heap/sharedMem.ml +++ b/hphp/hack/src/heap/sharedMem.ml @@ -986,118 +986,6 @@ functor end (*****************************************************************************) -(* Module used to access "new" values (as opposed to old ones). - * There are several cases where we need to compare the old and the new - * representation of objects (to determine what has changed). - * The "old" representation is the value that was bound to that key in the - * last round of type-checking. - * Despite the fact that the same storage is used under the hood, it's good - * to separate the two interfaces to make sure we never mix old and new - * values. - *) -(*****************************************************************************) - -module New : functor (Raw : Raw) (Key : Key) (Value : Value.Type) -> sig - (* Adds a binding to the table, the table is left unchanged if the - * key was already bound. - *) - val add : Key.t -> Value.t -> unit - - val get : Key.t -> Value.t option - - val remove : Key.t -> unit - - val mem : Key.t -> bool - - (* Binds the key to the old one. - * If 'mykey' is bound to 'myvalue', oldifying 'mykey' makes 'mykey' - * accessible to the "Old" module, in other words: "Old.mem mykey" returns - * true and "New.mem mykey" returns false after oldifying. - *) - val oldify : Key.t -> unit - - module WithLocalChanges : module type of WithLocalChanges (Raw) (Key) (Value) -end = -functor - (Raw : Raw) - (Key : Key) - (Value : Value.Type) - -> - struct - module WithLocalChanges = WithLocalChanges (Raw) (Key) (Value) - - let add key value = WithLocalChanges.add (Key.md5 key) value - - let mem key = WithLocalChanges.mem (Key.md5 key) - - let get key = - let key = Key.md5 key in - if WithLocalChanges.mem key then - Some (WithLocalChanges.get key) - else - None - - let remove key = - let key = Key.md5 key in - if WithLocalChanges.mem key then ( - WithLocalChanges.remove key; - assert (not (WithLocalChanges.mem key)) - ) else - () - - let oldify key = - if mem key then - let old_key = Key.to_old key in - WithLocalChanges.move (Key.md5 key) (Key.md5_old old_key) - else - () - end - -(* Same as new, but for old values *) -module Old : functor - (Raw : Raw) - (Key : Key) - (Value : Value.Type) - (_ : module type of WithLocalChanges (Raw) (Key) (Value)) - -> sig - val get : Key.old -> Value.t option - - val remove : Key.old -> unit - - val mem : Key.old -> bool - - (* Takes an old value and moves it back to a "new" one *) - val revive : Key.old -> unit -end = -functor - (Raw : Raw) - (Key : Key) - (Value : Value.Type) - (WithLocalChanges : module type of WithLocalChanges (Raw) (Key) (Value)) - -> - struct - let get key = - let key = Key.md5_old key in - if WithLocalChanges.mem key then - Some (WithLocalChanges.get key) - else - None - - let mem key = WithLocalChanges.mem (Key.md5_old key) - - let remove key = if mem key then WithLocalChanges.remove (Key.md5_old key) - - let revive key = - if mem key then ( - let new_key = Key.new_from_old key in - let new_key = Key.md5 new_key in - let old_key = Key.md5_old key in - if WithLocalChanges.mem new_key then WithLocalChanges.remove new_key; - WithLocalChanges.move old_key new_key - ) - end - -(*****************************************************************************) (* The signatures of what we are actually going to expose to the user *) (*****************************************************************************) diff --git a/hphp/hack/src/heap/sharedMem.mli b/hphp/hack/src/heap/sharedMem.mli index 6e4c9bf9a61..760383d9198 100644 --- a/hphp/hack/src/heap/sharedMem.mli +++ b/hphp/hack/src/heap/sharedMem.mli @@ -316,52 +316,15 @@ module WithLocalChanges (Raw : Raw) (Key : Key) (Value : Value.Type) : sig end end -(** Heap used to access "new" values (as opposed to "old" ones). +(** A heap for a user-defined type. + + Each heap supports "old" and "new" values. There are several cases where we need to compare the old and the new representations of objects to determine what has changed. The "old" representation is the value that was bound to that key in the last round of type-checking. *) -module New (Raw : Raw) (Key : Key) (Value : Value.Type) : sig - (** Adds a binding to the table. - - Note: the table is left unchanged if the key was already bound! - TODO(hverr): this will no longer be true with sharded hash tables. *) - val add : Key.t -> Value.t -> unit - - val get : Key.t -> Value.t option - - val remove : Key.t -> unit - - val mem : Key.t -> bool - - (** Marks the value bound to this key as "old". - - In pratice, the value will be moved to the same key, prefixed with - the old-prefix. *) - val oldify : Key.t -> unit - - module WithLocalChanges : module type of WithLocalChanges (Raw) (Key) (Value) -end - -(** Same as [New] but for old values. *) -module Old - (Raw : Raw) - (Key : Key) - (Value : Value.Type) - (_ : module type of WithLocalChanges (Raw) (Key) (Value)) : sig - val get : Key.old -> Value.t option - - val remove : Key.old -> unit - - val mem : Key.old -> bool - - (** Takes an old value and moves it back to a "new" one *) - val revive : Key.old -> unit -end - -(** A heap for a user-defined type. *) module type NoCache = sig type key @@ -371,6 +334,11 @@ module type NoCache = sig module KeyMap : WrappedMap.S with type key = key + (** Adds a binding to the table. + + Note: TODO(hverr), currently the semantics of inserting a value for a key + that's already in the heap are unclear and depend on whether you have a + local-changes stack or not. *) val add : key -> value -> unit val get : key -> value option -- 2.11.4.GIT