From cbec87496b06dd02ade91f67454286b1c743f2ae Mon Sep 17 00:00:00 2001 From: Catherine Gasnier Date: Fri, 7 Mar 2025 06:39:26 -0800 Subject: [PATCH] remove optimized fanout algo Summary: The optimised fanout algo was not pushed to prod due to multiple breakage and disappointing benefits. Let's remove it. Differential Revision: D70704289 fbshipit-source-id: 22248ddaa2fb71ef3fe0d1b7db5a67f10b2fe1b0 --- hphp/hack/src/decl/decl_redecl_service.ml | 2 +- hphp/hack/src/decl/shallow_class_diff.ml | 27 +- hphp/hack/src/decl/shallow_class_diff.mli | 6 +- hphp/hack/src/decl/shallow_class_fanout.ml | 478 +----------------- hphp/hack/src/decl/shallow_decl_compare.ml | 76 +-- hphp/hack/src/decl/shallow_decl_compare.mli | 4 - hphp/hack/src/depgraph/dep/dep.rs | 9 - .../deps/deps_rust/dep_graph_with_delta.rs | 29 +- hphp/hack/src/deps/typing_deps.ml | 28 +- hphp/hack/src/deps/typing_deps.mli | 7 - hphp/hack/src/deps/typing_deps_hash.rs | 2 - .../src/deps/typing_pessimisation_deps.ml | 1 - hphp/hack/src/hh_single_fanout.ml | 11 - hphp/hack/src/hh_single_type_check.ml | 1 - hphp/hack/src/options/saved_state_rollouts.ml | 62 +-- .../hack/src/options/saved_state_rollouts.mli | 5 - hphp/hack/src/options/typecheckerOptions.ml | 11 - .../src/oxidized/gen/saved_state_rollouts.rs | 18 +- .../manual/saved_state_rollouts_impl.rs | 20 - .../gen/saved_state_rollouts.rs | 18 +- hphp/hack/src/providers/provider_utils.ml | 2 +- hphp/hack/src/typing/env/deps.ml | 40 +- hphp/hack/src/typing/env/deps.mli | 3 - hphp/hack/src/typing/env/typing_env.ml | 68 +-- hphp/hack/src/typing/env/typing_env.mli | 9 +- hphp/hack/src/typing/typing_class.ml | 29 +- hphp/hack/src/typing/typing_extends.ml | 6 +- hphp/hack/src/typing/typing_subtype.ml | 44 +- .../added_parent_disjoint_interect1.php.exp | 1 - .../added_parent_disjoint_interect2.php.exp | 1 - .../added_parent_disjoint_interect3.php.exp | 1 - .../added_parent_disjoint_interect4.php.exp | 1 - .../added_parent_error1.php.exp | 1 - 33 files changed, 71 insertions(+), 950 deletions(-) diff --git a/hphp/hack/src/decl/decl_redecl_service.ml b/hphp/hack/src/decl/decl_redecl_service.ml index a73aac5013d83..291b34e29bb1a 100644 --- a/hphp/hack/src/decl/decl_redecl_service.ml +++ b/hphp/hack/src/decl/decl_redecl_service.ml @@ -622,7 +622,7 @@ let redo_type_decl ~bucket_size ~get_classes_in_file:get_classes changes; - let fanout = Shallow_decl_compare.compute_class_fanout ctx changes in + let fanout = Shallow_class_fanout.fanout_of_changes ~ctx changes in Fanout.union fanout fanout_acc in remove_old_defs ctx all_old_defs all_elems; diff --git a/hphp/hack/src/decl/shallow_class_diff.ml b/hphp/hack/src/decl/shallow_class_diff.ml index c2efdbd7dbb8f..2f9b0e6c699b3 100644 --- a/hphp/hack/src/decl/shallow_class_diff.ml +++ b/hphp/hack/src/decl/shallow_class_diff.ml @@ -116,7 +116,6 @@ end impact the constructor. *) let diff_members (type member) - ctx (members_left_right : (member option * member option) SMap.t) (module Member : Member_S with type t = member) (classish_kind : Ast_defs.classish_kind) @@ -158,17 +157,6 @@ let diff_members | (Some old_member, Some new_member) -> let member_changes = Member.diff old_member new_member - |> Option.map ~f:(fun change -> - if - TypecheckerOptions.optimized_member_fanout - (Provider_context.get_tcopt ctx) - && (not Ast_defs.(is_c_trait classish_kind)) - && Member.is_private old_member - && Member.is_private new_member - then - Private_change_not_in_trait - else - change) |> check_module_change_internal old_member new_member |> Option.fold ~init:diff ~f:(fun diff ch -> SMap.add diff ~key:name ~data:ch) @@ -316,7 +304,7 @@ let diff_constructor old_cls new_cls old_cstr new_cstr : member_change option = | (None, Some _) -> Some Added | (Some old_method, Some new_method) -> Method.diff old_method new_method -let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : +let diff_class_members (c1 : shallow_class) (c2 : shallow_class) : ClassDiff.member_diff = let diff = ClassDiff.empty_member_diff in let kind = c2.sc_kind in @@ -331,7 +319,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : let consts = merge_member_lists get_name c1.sc_consts c2.sc_consts in let (consts, constructor_change) = diff_members - ctx consts (module ClassConst : Member_S with type t = shallow_class_const) kind @@ -350,7 +337,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : in let (typeconsts, constructor_change) = diff_members - ctx typeconsts (module TypeConst : Member_S with type t = shallow_typeconst) kind @@ -367,7 +353,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : let props = merge_member_lists get_name c1.sc_props c2.sc_props in let (props, constructor_change) = diff_members - ctx props (module Prop : Member_S with type t = shallow_prop) kind @@ -384,7 +369,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : let sprops = merge_member_lists get_name c1.sc_sprops c2.sc_sprops in let (sprops, constructor_change) = diff_members - ctx sprops (module Prop : Member_S with type t = shallow_prop) kind @@ -401,7 +385,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : let methods = merge_member_lists get_name c1.sc_methods c2.sc_methods in let (methods, constructor_change) = diff_members - ctx methods (module Method : Member_S with type t = shallow_method) kind @@ -420,7 +403,6 @@ let diff_class_members ctx (c1 : shallow_class) (c2 : shallow_class) : in let (smethods, constructor_change) = diff_members - ctx smethods (module Method : Member_S with type t = shallow_method) kind @@ -806,13 +788,12 @@ let same_package let p2 = get_package_for_module info c2.sc_module in Option.equal Package.equal p1 p2 -let diff_class - ctx (info : PackageInfo.t) (c1 : shallow_class) (c2 : shallow_class) : - ClassDiff.t option = +let diff_class (info : PackageInfo.t) (c1 : shallow_class) (c2 : shallow_class) + : ClassDiff.t option = let same_package = same_package info c1 c2 in let class_shell1 = normalize c1 ~same_package and class_shell2 = normalize c2 ~same_package in - let member_diff = diff_class_members ctx c1 c2 in + let member_diff = diff_class_members c1 c2 in if not (equal_shallow_class class_shell1 class_shell2) then Some (Major_change diff --git a/hphp/hack/src/decl/shallow_class_diff.mli b/hphp/hack/src/decl/shallow_class_diff.mli index b28e17b24313e..1468413afffc8 100644 --- a/hphp/hack/src/decl/shallow_class_diff.mli +++ b/hphp/hack/src/decl/shallow_class_diff.mli @@ -10,8 +10,4 @@ open Shallow_decl_defs val diff_class : - Provider_context.t -> - PackageInfo.t -> - shallow_class -> - shallow_class -> - ClassDiff.t option + PackageInfo.t -> shallow_class -> shallow_class -> ClassDiff.t option diff --git a/hphp/hack/src/decl/shallow_class_fanout.ml b/hphp/hack/src/decl/shallow_class_fanout.ml index 0619959e53c47..5e1dd72f7bb9d 100644 --- a/hphp/hack/src/decl/shallow_class_fanout.ml +++ b/hphp/hack/src/decl/shallow_class_fanout.ml @@ -32,35 +32,6 @@ let get_maximum_fanout to_recheck_if_errors = DepSet.make (); } -module FanoutMonad = struct - type t = - | Max_fanout - | Fanout of Fanout.t - - let bind (fanout : t) (f : Fanout.t -> t) : t = - match fanout with - | Max_fanout -> Max_fanout - | Fanout fanout -> f fanout - - let map (fanout : t) (f : Fanout.t -> Fanout.t) : t = - match fanout with - | Max_fanout -> Max_fanout - | Fanout fanout -> Fanout (f fanout) - - let to_fanout ctx changed_class t = - match t with - | Fanout fanout -> fanout - | Max_fanout -> get_maximum_fanout ctx changed_class - - module Infix = struct - let ( >>= ) = bind - - let ( >>| ) = map - end -end - -module FM = FanoutMonad - let class_names_from_deps ~ctx ~get_classes_in_file deps = let filenames = Naming_provider.get_files ctx deps in Relative_path.Set.fold filenames ~init:SSet.empty ~f:(fun file acc -> @@ -75,65 +46,7 @@ let include_fanout_of_dep (mode : Mode.t) (dep : Dep.t) (deps : DepSet.t) : let fanout = Typing_deps.get_ideps_from_hash mode dep in DepSet.union fanout deps -let acc_member_fanout ctx class_dep member change fanout_acc = - match change with - | Private_change_not_in_trait -> fanout_acc - | Added - | Removed - | Changed_inheritance - | Modified _ -> - Typing_deps.get_member_fanout - (Provider_context.get_deps_mode ctx) - ~class_dep - member - fanout_acc - -let acc_member_fanouts ctx class_dep make_member changes fanout_acc = - SMap.fold changes ~init:fanout_acc ~f:(fun name change fanout_acc -> - acc_member_fanout ctx class_dep (make_member name) change fanout_acc) - let get_minor_change_fanout - ~(ctx : Provider_context.t) - (changed_class : changed_class) - (member_diff : ClassDiff.member_diff) - (fanout_acc : Fanout.t) : Fanout.t = - let { consts; typeconsts; props; sprops; methods; smethods; constructor } = - member_diff - in - let { Fanout.changed; to_recheck; to_recheck_if_errors } = fanout_acc in - let acc_fanout = acc_member_fanout ctx changed_class.dep in - let acc_fanouts make_member changes fanout_acc = - acc_member_fanouts ctx changed_class.dep make_member changes fanout_acc - in - let to_recheck = - DepSet.add to_recheck changed_class.dep - |> acc_fanouts Dep.Member.const consts - |> acc_fanouts Dep.Member.const typeconsts - |> acc_fanouts Dep.Member.prop props - |> acc_fanouts Dep.Member.sprop sprops - |> acc_fanouts Dep.Member.method_ methods - |> acc_fanouts Dep.Member.smethod smethods - in - let to_recheck = - Option.fold constructor ~init:to_recheck ~f:(fun to_recheck change -> - acc_fanout Dep.Member.constructor change to_recheck) - in - let to_recheck = - if - SMap.exists consts ~f:(fun _name change -> - method_or_property_change_affects_descendants change) - then - acc_fanout Dep.Member.all (Modified MemberModification.Other) to_recheck - else - to_recheck - in - { - Fanout.changed = DepSet.add changed changed_class.dep; - to_recheck; - to_recheck_if_errors; - } - -let get_minor_change_fanout_legacy ~(ctx : Provider_context.t) (changed_class : changed_class) (member_diff : ClassDiff.member_diff) : Fanout.t = @@ -219,393 +132,12 @@ let get_minor_change_fanout_legacy to_recheck_if_errors = DepSet.make (); } -(** This is all descendants + anything that depends on any descendants. *) - -(** Get the fanout of an added parent. *) -let get_added_parent_fanout - ctx - (changed_class : changed_class) - classish_kind - added_parent_name - fanout_acc : Fanout.t = - match Decl_provider.get_class ctx added_parent_name with - | Decl_entry.NotYetAvailable - | Decl_entry.DoesNotExist -> - fanout_acc - | Decl_entry.Found (cls : Decl_provider.class_decl) -> - let { Fanout.changed; to_recheck; to_recheck_if_errors } = fanout_acc in - let { name = _; diff = _; dep; descendant_deps } = changed_class in - (* The type check performs two categories of checks: - * - function/method body checks - * - wellformedness/hierarchy checks - * - * We need to reason about both to figure out fanouts. - * - * # Hierarchy checks - * - * For hierarchy checks, precise fanout computation is - * tricky because there are a wide variety of checks. - * Most checks only consider information declared in direct parents, - * but some checks use information declared in non-direct ancestors, - * for example: - * - member override checks - * - requirement checks (e.g. `require extends`) - * - constructor consistency checks (using attribute __ConsistentConstruct - * from remote ancestors) - * - dynamic support checks - * - multiple instantiation inheritence checks - * - * Since it's hard to keep track of those checks and more may be added - * in the future, we simply include all descendants in the fanout. - *) - let to_recheck = DepSet.union descendant_deps to_recheck in - (* # Function body checks - * - * Function body checks use two kinds of basic decl facts - * that can be affected by parent changes: - * - subtyping relationships: t1 <: t2 - * - member types: X::m : t - * Adding a parent Y to a type X should: - * - Add new subtyping relationships, but not remove any. - * And therefore there should be no new subtyping errors. - * - For each member m in Y, possibly change the type of X::m. - * The fanout should therefore include the fanout of X::m. - * - * So conclusion: fanout = union over m in Y of fanout(X::m) - * Which is what this function implements - *) - let acc_fanout member = acc_member_fanout ctx dep member Added in - let acc_fanouts make_member members = - acc_member_fanouts - ctx - dep - make_member - (List.map members ~f:(fun m -> (fst m, Added)) |> SMap.of_list) - in - let consts = - Folded_class.consts cls - |> List.filter ~f:(fun (name, _) -> - not @@ String.equal name Naming_special_names.Members.mClass) - in - let to_recheck = - to_recheck - |> acc_fanouts Dep.Member.method_ (Folded_class.methods cls) - |> acc_fanouts Dep.Member.smethod (Folded_class.smethods cls) - |> acc_fanouts Dep.Member.prop (Folded_class.props cls) - |> acc_fanouts Dep.Member.sprop (Folded_class.sprops cls) - |> acc_fanouts Dep.Member.const consts - |> acc_fanouts Dep.Member.const (Folded_class.typeconsts cls) - in - let to_recheck = - let (construct, _consistent_kind) = Folded_class.construct cls in - Option.fold construct ~init:to_recheck ~f:(fun to_recheck _construct -> - acc_fanout Dep.Member.constructor to_recheck) - in - let to_recheck = - if Ast_defs.is_c_enum classish_kind && (not @@ List.is_empty consts) then - acc_fanout Dep.Member.all to_recheck - else - to_recheck - in - (* Caveat: - * Some typing derivations actually use facts like - * 'A is not a subtype of B', for example when inferring that two types - * are disjoint and a refinement results in type 'nothing'. - * These basics facts may be invalidated by adding parents. - * To handle this case, - * - whenever we fact 'A is not a subtype of X' for any X, - * we add a 'NotSubtype' edge from A. - * - when detecting an added parent to A, we gather descendants of - * A via Extends / RequireExtends edges, then follow any NotSubtype - * edge from these descendants and collect these edges' ends to add to - * the fanout. (This is done by the call to get_not_subtype_fanout below) - *) - let to_recheck = - Typing_deps.get_not_subtype_fanout - (Provider_context.get_deps_mode ctx) - ~descendant_deps - to_recheck - in - { - Fanout.changed = DepSet.add changed dep; - to_recheck; - to_recheck_if_errors = - DepSet.union to_recheck_if_errors (get_all_deps ctx changed_class); - } - -let get_added_parents_fanout - ctx (changed_class : changed_class) classish_kind added_parents fanout_acc : - Fanout.t = - SSet.fold - added_parents - ~init:fanout_acc - ~f:(get_added_parent_fanout ctx changed_class classish_kind) - -let get_parent_changes_fanout - ctx - (changed_class : changed_class) - classish_kind - (parent_changes : ClassDiff.parent_changes option) - (fanout_acc : Fanout.t) : FM.t = - match parent_changes with - | None -> FM.Fanout fanout_acc - | Some parent_changes -> - let { - ClassDiff.extends_changes; - implements_changes; - req_extends_changes; - req_implements_changes; - req_constraints_changes; - uses_changes; - xhp_attr_changes; - } = - parent_changes - in - (* If any parent was modified or removed, then some subtyping relationships are invalidated - * and we must return max fanout. - * Otherwise if we're only dealing with added parents, we can calculate a smaller fanout. - * Let's detect removed/modified parents sooner rather than later, by going over the list - * once first, and collect all the added parents at the same occasion. *) - let (added_parents, removed_parents) = - List.fold - [ - extends_changes; - implements_changes; - req_extends_changes; - req_implements_changes; - (* req_constraints_changes; *) - uses_changes; - xhp_attr_changes; - ] - ~init:(SSet.empty, SSet.empty) - ~f:(fun (added_parents, removed_parents) changes -> - Option.fold - changes - ~init:(added_parents, removed_parents) - ~f:(fun - (added_parents, removed_parents) - (change : _ ClassDiff.NamedItemsListChange.t) - -> - let { - ClassDiff.NamedItemsListChange.per_name_changes; - order_change = _; - } = - change - in - SMap.fold - per_name_changes - ~init:(added_parents, removed_parents) - ~f:(fun name change (added_parents, removed_parents) -> - match change with - | ClassDiff.ValueChange.(Modified _ | Removed) -> - let removed_parents = SSet.add removed_parents name in - (added_parents, removed_parents) - | ClassDiff.ValueChange.Added -> - let added_parents = SSet.add added_parents name in - (added_parents, removed_parents)))) - in - if (not (SSet.is_empty removed_parents)) || req_constraints_changes then - FM.Max_fanout - else - FM.Fanout - (get_added_parents_fanout - ctx - changed_class - classish_kind - added_parents - fanout_acc) - -let get_sealed_fanout - ctx - (changed_class : changed_class) - (attribute_change : unit NamedItemsListChange.t ValueChange.t) - (fanout_acc : Fanout.t) : Fanout.t = - let { name; dep; descendant_deps = _; diff = _ } = changed_class in - let { Fanout.changed; to_recheck; to_recheck_if_errors } = fanout_acc in - let changed = DepSet.add changed dep in - let (to_recheck, to_recheck_if_errors) = - match attribute_change with - | ValueChange.Added -> - let to_recheck = - Typing_deps.get_ideps - (Provider_context.get_deps_mode ctx) - (Dep.Extends name) - |> DepSet.union to_recheck - in - (to_recheck, to_recheck_if_errors) - | ValueChange.Removed -> - let to_recheck_if_errors = - Typing_deps.get_ideps - (Provider_context.get_deps_mode ctx) - (Dep.Extends name) - |> DepSet.union to_recheck_if_errors - in - (to_recheck, to_recheck_if_errors) - | ValueChange.Modified allow_list_changes -> - let { NamedItemsListChange.per_name_changes; order_change = _ } = - allow_list_changes - in - SMap.fold - per_name_changes - ~init:(to_recheck, to_recheck_if_errors) - ~f:(fun child_name change (to_recheck, to_recheck_if_errors) -> - let child_dep = Dep.make (Dep.Type child_name) in - match change with - | ValueChange.Added -> - let to_recheck_if_errors = - DepSet.add to_recheck_if_errors child_dep - in - (to_recheck, to_recheck_if_errors) - | ValueChange.Removed - | ValueChange.Modified () -> - let to_recheck = DepSet.add to_recheck child_dep in - (to_recheck, to_recheck_if_errors)) - in - { Fanout.changed; to_recheck; to_recheck_if_errors } - -let get_user_attribute_fanout - ctx changed_class (attribute_name : string) attribute_change fanout_acc : - FM.t = - if String.equal attribute_name Naming_special_names.UserAttributes.uaSealed - then - FM.Fanout (get_sealed_fanout ctx changed_class attribute_change fanout_acc) - else if - List.mem - [ - Naming_special_names.UserAttributes.uaDocs; - Naming_special_names.UserAttributes.uaAutocompleteSortText; - ] - attribute_name - ~equal:String.equal - then - FM.Fanout fanout_acc - else - match - SMap.find_opt Naming_special_names.UserAttributes.as_map attribute_name - with - | Some _ -> FM.Max_fanout - | None -> FM.Fanout fanout_acc - -let get_user_attributes_fanout - ctx - changed_class - (attribute_changes : - unit NamedItemsListChange.t NamedItemsListChange.t option) - (fanout_acc : Fanout.t) : FM.t = - if - TypecheckerOptions.optimized_attribute_fanout - (Provider_context.get_tcopt ctx) - then - match attribute_changes with - | None -> FM.Fanout fanout_acc - | Some attribute_changes -> - let { NamedItemsListChange.per_name_changes; order_change = _ } = - attribute_changes - in - SMap.fold - per_name_changes - ~init:(FM.Fanout fanout_acc) - ~f:(fun attr_name attr_change fanout_acc -> - let open FM.Infix in - fanout_acc - >>= get_user_attribute_fanout ctx changed_class attr_name attr_change) - else - FM.Max_fanout - -let all_or_nothing_bool (has_changed : bool) fanout_acc = - if has_changed then - FM.Max_fanout - else - FM.Fanout fanout_acc - -let all_or_nothing (type change) (change_opt : change option) fanout_acc = - match change_opt with - | None -> FM.Fanout fanout_acc - | Some _ -> FM.Max_fanout - -let get_shell_change_fanout - ctx - (changed_class : changed_class) - (shell_change : ClassDiff.class_shell_change) - (member_diff : ClassDiff.member_diff) - (fanout_acc : Fanout.t) : FM.t = - let { - ClassDiff.old_classish_kind; - parent_changes; - type_parameters_change; - kind_change; - final_change; - abstract_change; - is_xhp_change; - internal_change; - has_xhp_keyword_change; - support_dynamic_type_change; - module_change; - xhp_enum_values_change; - user_attributes_changes; - enum_type_change; - } = - shell_change - in - let open FM.Infix in - fanout_acc - |> all_or_nothing type_parameters_change - >>= all_or_nothing kind_change - >>= all_or_nothing final_change - >>= all_or_nothing abstract_change - >>= all_or_nothing is_xhp_change - >>= all_or_nothing internal_change - >>= all_or_nothing has_xhp_keyword_change - >>= all_or_nothing support_dynamic_type_change - >>= all_or_nothing module_change - >>= all_or_nothing enum_type_change - >>= all_or_nothing_bool xhp_enum_values_change - >>= get_parent_changes_fanout - ctx - changed_class - old_classish_kind - parent_changes - >>= get_user_attributes_fanout ctx changed_class user_attributes_changes - >>| get_minor_change_fanout ~ctx changed_class member_diff - -let get_major_change_fanout - ctx - (changed_class : changed_class) - (change : ClassDiff.MajorChange.t) - fanout_acc : FM.t = - match change with - | ClassDiff.MajorChange.(Added | Removed | Unknown _) -> FM.Max_fanout - | ClassDiff.MajorChange.Modified (shell_change, member_diff) -> - get_shell_change_fanout - ctx - changed_class - shell_change - member_diff - fanout_acc - let get_fanout ~(ctx : Provider_context.t) (changed_class : changed_class) : - FM.t = - let fanout_acc = Fanout.empty in + Fanout.t = match changed_class.diff with - | Major_change change -> - if - TypecheckerOptions.optimized_parent_fanout - (Provider_context.get_tcopt ctx) - then - get_major_change_fanout ctx changed_class change fanout_acc - else - FM.Max_fanout + | Major_change _change -> get_maximum_fanout ctx changed_class | Minor_change minor_change -> - let fanout = - if - TypecheckerOptions.optimized_member_fanout - (Provider_context.get_tcopt ctx) - then - get_minor_change_fanout ~ctx changed_class minor_change fanout_acc - else - get_minor_change_fanout_legacy ~ctx changed_class minor_change - in - FM.Fanout fanout + get_minor_change_fanout ~ctx changed_class minor_change let direct_references_cardinal mode dep : int = Typing_deps.get_ideps_from_hash mode dep |> DepSet.cardinal @@ -681,9 +213,7 @@ let add_fanout ~ctx ((fanout_acc, max_class_fanout_cardinal) : Fanout.t * int) (changed_class : changed_class) : Fanout.t * int = - let fanout = - get_fanout ~ctx changed_class |> FM.to_fanout ctx changed_class - in + let fanout = get_fanout ~ctx changed_class in Log.log_class_fanout ctx ~class_cnt changed_class fanout; let fanout_acc = Fanout.union fanout_acc fanout in let max_class_fanout_cardinal = diff --git a/hphp/hack/src/decl/shallow_decl_compare.ml b/hphp/hack/src/decl/shallow_decl_compare.ml index f8490f54274b8..d613bd05b820d 100644 --- a/hphp/hack/src/decl/shallow_decl_compare.ml +++ b/hphp/hack/src/decl/shallow_decl_compare.ml @@ -15,7 +15,6 @@ module VersionedSSet = Decl_compare.VersionedSSet module Dep = Typing_deps.Dep let diff_class_in_changed_file - ctx (package_info : PackageInfo.t) (old_classes : shallow_class option SMap.t) (new_classes : shallow_class option SMap.t) @@ -24,7 +23,7 @@ let diff_class_in_changed_file let new_class_opt = SMap.find new_classes class_name in match (old_class_opt, new_class_opt) with | (Some old_class, Some new_class) -> - Shallow_class_diff.diff_class ctx package_info old_class new_class + Shallow_class_diff.diff_class package_info old_class new_class | (None, None) -> Some (Major_change (MajorChange.Unknown Neither_found)) | (None, Some _) -> Some (Major_change (MajorChange.Unknown Old_decl_not_found)) @@ -54,74 +53,12 @@ let compute_class_diffs let package_info = Provider_context.get_package_info ctx in SSet.fold kept ~init:acc ~f:(fun cid acc -> let diff = - diff_class_in_changed_file ctx package_info old_classes new_classes cid + diff_class_in_changed_file package_info old_classes new_classes cid in match diff with | Some diff -> (cid, diff) :: acc | None -> acc) -let untag_removed_members_in_depgraph - ~ctx (changes : Shallow_class_fanout.changed_class list) = - let removed_member_deps = - List.fold - changes - ~init:(Typing_deps.DepSet.make ()) - ~f:(fun deps_acc changed_class -> - let { Shallow_class_fanout.name = _; diff; dep; descendant_deps = _ } = - changed_class - in - match diff with - | ClassDiff.(Major_change MajorChange.(Unknown _ | Added | Removed)) -> - deps_acc - | ClassDiff.(Major_change (MajorChange.Modified (_, member_diff))) - | ClassDiff.Minor_change member_diff -> - let { - ClassDiff.consts; - typeconsts; - props; - sprops; - methods; - smethods; - constructor; - } = - member_diff - in - let acc_removed_member member change deps_acc = - match change with - | ClassDiff.Added - | ClassDiff.Modified _ - | ClassDiff.Changed_inheritance - | ClassDiff.Private_change_not_in_trait -> - deps_acc - | ClassDiff.Removed -> - let member_dep = - Typing_deps.Dep.make_member_dep_from_type_dep dep member - in - Typing_deps.DepSet.add deps_acc member_dep - in - let acc_removed_members make_member members deps_acc = - SMap.fold - members - ~init:deps_acc - ~f:(fun member_name change deps_acc -> - acc_removed_member (make_member member_name) change deps_acc) - in - Option.fold constructor ~init:deps_acc ~f:(fun deps_acc change -> - acc_removed_member - Typing_deps.Dep.Member.constructor - change - deps_acc) - |> acc_removed_members Typing_deps.Dep.Member.const consts - |> acc_removed_members Typing_deps.Dep.Member.const typeconsts - |> acc_removed_members Typing_deps.Dep.Member.prop props - |> acc_removed_members Typing_deps.Dep.Member.sprop sprops - |> acc_removed_members Typing_deps.Dep.Member.method_ methods - |> acc_removed_members Typing_deps.Dep.Member.smethod smethods) - in - Typing_deps.remove_declared_tags - (Provider_context.get_deps_mode ctx) - removed_member_deps - let log_changes (changes : (string * ClassDiff.t) list) : unit = let change_count = List.length changes in if List.is_empty changes then @@ -168,12 +105,3 @@ let compute_changes dep = class_dep; descendant_deps; }) - -let compute_class_fanout - (ctx : Provider_context.t) - (changed_classes : Shallow_class_fanout.changed_class list) : Fanout.t = - let fanout = Shallow_class_fanout.fanout_of_changes ~ctx changed_classes in - if TypecheckerOptions.optimized_member_fanout (Provider_context.get_tcopt ctx) - then - untag_removed_members_in_depgraph ~ctx changed_classes; - fanout diff --git a/hphp/hack/src/decl/shallow_decl_compare.mli b/hphp/hack/src/decl/shallow_decl_compare.mli index 84189b2730ef6..c632dfd1b27a4 100644 --- a/hphp/hack/src/decl/shallow_decl_compare.mli +++ b/hphp/hack/src/decl/shallow_decl_compare.mli @@ -12,7 +12,3 @@ val compute_changes : during_init:bool -> class_names:Decl_compare.VersionedSSet.diff -> Shallow_class_fanout.changed_class list - -(** Compare classes in files and deduce fanout. *) -val compute_class_fanout : - Provider_context.t -> Shallow_class_fanout.changed_class list -> Fanout.t diff --git a/hphp/hack/src/depgraph/dep/dep.rs b/hphp/hack/src/depgraph/dep/dep.rs index c69aaebb42b9a..de08b13c93a4f 100644 --- a/hphp/hack/src/depgraph/dep/dep.rs +++ b/hphp/hack/src/depgraph/dep/dep.rs @@ -42,15 +42,6 @@ impl Dep { } } - // Return the 'RequireExtends' dep for a class from its 'Type' dep - pub fn class_to_require_extends(self) -> Self { - Dep(typing_deps_hash::hash2( - DepType::RequireExtends, - self.0, - &[], - )) - } - // Return the 'NotSubtype' dep for a class from its 'Type' dep pub fn class_to_not_subtype(self) -> Self { Dep(typing_deps_hash::hash2(DepType::NotSubtype, self.0, &[])) diff --git a/hphp/hack/src/deps/deps_rust/dep_graph_with_delta.rs b/hphp/hack/src/deps/deps_rust/dep_graph_with_delta.rs index 90f6a8f23c7d6..bedfbf32957b3 100644 --- a/hphp/hack/src/deps/deps_rust/dep_graph_with_delta.rs +++ b/hphp/hack/src/deps/deps_rust/dep_graph_with_delta.rs @@ -131,15 +131,6 @@ impl DepGraphWithDelta { } }) }); - let require_extends_hash = source_class.class_to_require_extends(); - self.iter_dependents_with_duplicates(require_extends_hash, |iter| { - iter.for_each(|dep: Dep| { - if !acc.contains(&dep) { - acc.insert_mut(dep); - queue.push_back(dep); - } - }) - }); } } @@ -173,7 +164,7 @@ impl DepGraphWithDelta { let mut visited = HashSet::default(); self.visit_class_dep_for_member_fanout( - (class_dep, false), + class_dep, member_type, member_name, &mut visited, @@ -197,20 +188,18 @@ impl DepGraphWithDelta { fn visit_class_dep_for_member_fanout( &self, - (class_dep, via_req): (Dep, bool), + class_dep: Dep, member_type: DepType, member_name: &str, - visited: &mut HashSet<(Dep, bool)>, - queue: &mut VecDeque<(Dep, bool)>, + visited: &mut HashSet, + queue: &mut VecDeque, fanout_acc: &mut HashTrieSet, stop_if_declared: bool, ) { - if !visited.insert((class_dep, via_req)) { + if !visited.insert(class_dep) { return; } - if !via_req { - fanout_acc.insert_mut(class_dep); - } + fanout_acc.insert_mut(class_dep); let member_dep = class_dep.member(member_type, member_name); let mut member_is_declared = false; let mut member_deps = HashSet::default(); @@ -232,11 +221,7 @@ impl DepGraphWithDelta { .for_each(|dep| fanout_acc.insert_mut(dep)); let extends_dep_for_class = class_dep.class_to_extends().unwrap(); self.iter_dependents_with_duplicates(extends_dep_for_class, |iter| { - iter.for_each(|dep| queue.push_back((dep, via_req))); - }); - let requires_extends_dep_for_class = class_dep.class_to_require_extends(); - self.iter_dependents_with_duplicates(requires_extends_dep_for_class, |iter| { - iter.for_each(|dep| queue.push_back((dep, true))); + iter.for_each(|dep| queue.push_back(dep)); }); } } diff --git a/hphp/hack/src/deps/typing_deps.ml b/hphp/hack/src/deps/typing_deps.ml index dcd290627497a..d7ada78f7bf26 100644 --- a/hphp/hack/src/deps/typing_deps.ml +++ b/hphp/hack/src/deps/typing_deps.ml @@ -31,7 +31,6 @@ module Dep = struct | Fun : string -> 'a variant | Type : string -> 'a variant | Extends : string -> dependency variant - | RequireExtends : string -> dependency variant | NotSubtype : string -> dependency variant | Const : string * string -> dependency variant | Constructor : string -> dependency variant @@ -58,7 +57,6 @@ module Dep = struct | Constructor s -> Constructor s | AllMembers s -> AllMembers s | Extends s -> Extends s - | RequireExtends s -> RequireExtends s | NotSubtype s -> NotSubtype s | Declares -> Declares @@ -68,7 +66,6 @@ module Dep = struct | KFun [@value 1] | KType [@value 2] | KExtends [@value 3] - | KRequireExtends [@value 4] | KConst [@value 5] | KConstructor [@value 6] | KProp [@value 7] @@ -156,7 +153,6 @@ module Dep = struct | Fun _ -> 1 | Type _ -> 2 | Extends _ -> 3 - | RequireExtends _ -> 4 | NotSubtype _ -> 15 | Const _ -> 5 | Constructor _ -> 6 @@ -175,7 +171,6 @@ module Dep = struct | (Fun x1, Fun x2) | (Type x1, Type x2) | (Extends x1, Extends x2) - | (RequireExtends x1, RequireExtends x2) | (NotSubtype x1, NotSubtype x2) | (Constructor x1, Constructor x2) | (AllMembers x1, AllMembers x2) @@ -193,9 +188,9 @@ module Dep = struct String.compare m1 m2 | (Declares, Declares) -> 0 | ( _, - ( GConst _ | Fun _ | Type _ | Extends _ | RequireExtends _ - | NotSubtype _ | Const _ | Constructor _ | Prop _ | SProp _ | Method _ - | SMethod _ | AllMembers _ | GConstName _ | Module _ | Declares ) ) -> + ( GConst _ | Fun _ | Type _ | Extends _ | NotSubtype _ | Const _ + | Constructor _ | Prop _ | SProp _ | Method _ | SMethod _ | AllMembers _ + | GConstName _ | Module _ | Declares ) ) -> ordinal_variant v1 - ordinal_variant v2 let dep_kind_of_variant : type a. a variant -> dep_kind = function @@ -211,7 +206,6 @@ module Dep = struct | Constructor _ -> KConstructor | AllMembers _ -> KAllMembers | Extends _ -> KExtends - | RequireExtends _ -> KRequireExtends | NotSubtype _ -> KNotSubtype | Module _ -> KModule | Declares -> KDeclares @@ -220,13 +214,6 @@ module Dep = struct let (dep_kind, member_name) = Member.to_dep_kind_and_name member in hash2 (dep_kind_to_enum dep_kind) type_dep member_name - (** Return the 'Extends' dep for a class from its 'Type' dep *) - let extends_of_class class_dep = class_dep lxor 1 - - (** Return the 'RequireExtends' dep for a class from its 'Type' dep *) - let require_extends_of_class class_dep = - hash2 (dep_kind_to_enum KRequireExtends) class_dep "" - (** Return the 'NotSubtype' dep for a class from its 'Type' dep *) let not_subtype_of_class class_dep = hash2 (dep_kind_to_enum KNotSubtype) class_dep "" @@ -240,7 +227,6 @@ module Dep = struct | Module mname -> hash1 (dep_kind_to_enum KModule) mname | Type name1 -> hash1 (dep_kind_to_enum KType) name1 | Extends name1 -> hash1 (dep_kind_to_enum KExtends) name1 - | RequireExtends name1 -> require_extends_of_class (make (Type name1)) | NotSubtype name1 -> not_subtype_of_class (make (Type name1)) (* Deps on members *) | Constructor name1 -> @@ -261,9 +247,6 @@ module Dep = struct let is_class x = x land 1 = 1 - let extends_and_req_extends_of_class class_dep = - (extends_of_class class_dep, require_extends_of_class class_dep) - let compare = Int.compare let extract_name : type a. a variant -> string = function @@ -280,7 +263,6 @@ module Dep = struct | Constructor s | AllMembers s | Extends s - | RequireExtends s | NotSubtype s -> Utils.strip_ns s | Module m -> m @@ -294,7 +276,6 @@ module Dep = struct | Constructor s | AllMembers s | Extends s - | RequireExtends s | NotSubtype s | Module s | Type s @@ -316,7 +297,6 @@ module Dep = struct | Constructor _ | AllMembers _ | Extends _ - | RequireExtends _ | NotSubtype _ | Module _ | Type _ @@ -334,7 +314,6 @@ module Dep = struct | Type s | Const (s, _) | Extends s - | RequireExtends s | NotSubtype s | AllMembers s | Constructor s @@ -376,7 +355,6 @@ module Dep = struct | Constructor _ -> "Constructor" | AllMembers _ -> "AllMembers" | Extends _ -> "Extends" - | RequireExtends _ -> "RequireExtends" | NotSubtype _ -> "NotSubtype" | Module _ -> "Module" | Declares -> "Declares" diff --git a/hphp/hack/src/deps/typing_deps.mli b/hphp/hack/src/deps/typing_deps.mli index 7dab0e116afe2..d94cd1e9bc22a 100644 --- a/hphp/hack/src/deps/typing_deps.mli +++ b/hphp/hack/src/deps/typing_deps.mli @@ -40,9 +40,6 @@ module Dep : sig (** Represents another class depending on a class via an inheritance-like mechanism (`extends`, `implements`, `use`, `require extends`, `require implements`, etc.) *) - | RequireExtends : string -> dependency variant - (** Whenever a type A has `require extends B` or `require implements B` - or `require class B`, we add an edge from `RequireExtends B` to `Type A` *) | NotSubtype : string -> dependency variant (** Whenever we use the fact that 'A is not a subtype of X' to conclude that a def F typechecks, we add an edge from `NotSubtype A` to the variant for F. @@ -82,7 +79,6 @@ module Dep : sig | KFun | KType | KExtends - | KRequireExtends | KConst | KConstructor | KProp @@ -132,9 +128,6 @@ module Dep : sig val is_class : t -> bool - (** Return the 'Extends' and 'RequireExtends' deps for a class from its 'Type' dep *) - val extends_and_req_extends_of_class : t -> t * t - val compare : t -> t -> int val extract_name : 'a variant -> string diff --git a/hphp/hack/src/deps/typing_deps_hash.rs b/hphp/hack/src/deps/typing_deps_hash.rs index a2678c56ced0a..1a3aa8f807105 100644 --- a/hphp/hack/src/deps/typing_deps_hash.rs +++ b/hphp/hack/src/deps/typing_deps_hash.rs @@ -18,7 +18,6 @@ pub enum DepType { Fun = 1, Type = 2, Extends = 3, - RequireExtends = 4, Const = 5, Constructor = 6, Prop = 7, @@ -43,7 +42,6 @@ impl DepType { 1 => Some(DepType::Fun), 2 => Some(DepType::Type), 3 => Some(DepType::Extends), - 4 => Some(DepType::RequireExtends), 5 => Some(DepType::Const), 6 => Some(DepType::Constructor), 7 => Some(DepType::Prop), diff --git a/hphp/hack/src/deps/typing_pessimisation_deps.ml b/hphp/hack/src/deps/typing_pessimisation_deps.ml index 995b33638eabc..7c1776d9734ab 100644 --- a/hphp/hack/src/deps/typing_pessimisation_deps.ml +++ b/hphp/hack/src/deps/typing_pessimisation_deps.ml @@ -260,7 +260,6 @@ let should_ignore_node node = false | Typing_deps.Dep.KType | Typing_deps.Dep.KExtends - | Typing_deps.Dep.KRequireExtends | Typing_deps.Dep.KNotSubtype | Typing_deps.Dep.KAllMembers | Typing_deps.Dep.KGConstName diff --git a/hphp/hack/src/hh_single_fanout.ml b/hphp/hack/src/hh_single_fanout.ml index 7e28e114623b8..389c80c64cb37 100644 --- a/hphp/hack/src/hh_single_fanout.ml +++ b/hphp/hack/src/hh_single_fanout.ml @@ -34,17 +34,6 @@ let tcopt = default with po = popt; tco_allow_all_files_for_module_declarations = true; - tco_saved_state = - { - default_saved_state with - rollouts = - { - Saved_state_rollouts.default with - Saved_state_rollouts.optimized_member_fanout = true; - optimized_parent_fanout = true; - optimized_attribute_fanout = true; - }; - }; } let log_section ~name ~content = diff --git a/hphp/hack/src/hh_single_type_check.ml b/hphp/hack/src/hh_single_type_check.ml index 3ac21ee21e423..2450f8b9379e5 100644 --- a/hphp/hack/src/hh_single_type_check.ml +++ b/hphp/hack/src/hh_single_type_check.ml @@ -1210,7 +1210,6 @@ let test_shallow_class_diff ctx filename = match old_and_new with | (Some c1, Some c2) -> Shallow_class_diff.diff_class - ctx (Provider_context.get_package_info ctx) c1 c2 diff --git a/hphp/hack/src/options/saved_state_rollouts.ml b/hphp/hack/src/options/saved_state_rollouts.ml index 66ed5773b53c4..03efbd11c481c 100644 --- a/hphp/hack/src/options/saved_state_rollouts.ml +++ b/hphp/hack/src/options/saved_state_rollouts.ml @@ -9,12 +9,8 @@ open Hh_prelude type t = { - dummy_one: bool; - dummy_two: bool; - dummy_three: bool; optimized_member_fanout: bool; - optimized_parent_fanout: bool; - optimized_attribute_fanout: bool; + (** optimized_member_fanout is not used but we leave it as a template *) new_naming_table: bool; } [@@deriving eq, show] @@ -29,12 +25,7 @@ type t = { My_flag *) type flag = - | Dummy_one - | Dummy_two - | Dummy_three | Optimized_member_fanout - | Optimized_parent_fanout - | Optimized_attribute_fanout | New_naming_table [@@deriving show { with_path = false }] @@ -74,23 +65,8 @@ let output t = let print_flag flag value = Printf.eprintf "%s = %b\n" (flag_name flag) value in - let { - dummy_one; - dummy_two; - dummy_three; - optimized_member_fanout; - optimized_parent_fanout; - optimized_attribute_fanout; - new_naming_table; - } = - t - in - print_flag Dummy_one dummy_one; - print_flag Dummy_two dummy_two; - print_flag Dummy_three dummy_three; + let { optimized_member_fanout; new_naming_table } = t in print_flag Optimized_member_fanout optimized_member_fanout; - print_flag Optimized_parent_fanout optimized_parent_fanout; - print_flag Optimized_attribute_fanout optimized_attribute_fanout; print_flag New_naming_table new_naming_table; () @@ -99,41 +75,13 @@ let to_bit_array_string t : string = | true -> "1" | false -> "0" in - let { - dummy_one; - dummy_two; - dummy_three; - optimized_member_fanout; - optimized_parent_fanout; - optimized_attribute_fanout; - new_naming_table; - } = - t - in - s dummy_one - ^ s dummy_two - ^ s dummy_three - ^ s optimized_member_fanout - ^ s optimized_parent_fanout - ^ s optimized_attribute_fanout - ^ s new_naming_table + let { optimized_member_fanout; new_naming_table } = t in + s optimized_member_fanout ^ s new_naming_table let to_hh_json t : Hh_json.json = - let { - dummy_one = _; - dummy_two = _; - dummy_three = _; - optimized_member_fanout; - optimized_parent_fanout; - optimized_attribute_fanout; - new_naming_table; - } = - t - in + let { optimized_member_fanout; new_naming_table } = t in Hh_json.JSON_Object [ ("optimized_member_fanout", Hh_json.bool_ optimized_member_fanout); - ("optimized_parent_fanout", Hh_json.bool_ optimized_parent_fanout); - ("optimized_attribute_fanout", Hh_json.bool_ optimized_attribute_fanout); ("new_naming_table", Hh_json.bool_ new_naming_table); ] diff --git a/hphp/hack/src/options/saved_state_rollouts.mli b/hphp/hack/src/options/saved_state_rollouts.mli index 7e84c4a4e8a30..f0c95eb62dd8a 100644 --- a/hphp/hack/src/options/saved_state_rollouts.mli +++ b/hphp/hack/src/options/saved_state_rollouts.mli @@ -9,12 +9,7 @@ type flag_name = string type t = { - dummy_one: bool; (** Some documentation for dummy_one *) - dummy_two: bool; (** Some documentation for dummy_two *) - dummy_three: bool; (** Some documentation for dummy_three *) optimized_member_fanout: bool; - optimized_parent_fanout: bool; - optimized_attribute_fanout: bool; new_naming_table: bool; } [@@deriving eq, show] diff --git a/hphp/hack/src/options/typecheckerOptions.ml b/hphp/hack/src/options/typecheckerOptions.ml index 37847291bbfb2..dad40f0abaf0f 100644 --- a/hphp/hack/src/options/typecheckerOptions.ml +++ b/hphp/hack/src/options/typecheckerOptions.ml @@ -242,17 +242,6 @@ let optimized_member_fanout t = GlobalOptions.(t.tco_saved_state.rollouts) .Saved_state_rollouts.optimized_member_fanout -let optimized_parent_fanout t = - GlobalOptions.(t.tco_saved_state.rollouts) - .Saved_state_rollouts.optimized_parent_fanout - -let optimized_attribute_fanout t = - GlobalOptions.(t.tco_saved_state.rollouts) - .Saved_state_rollouts.optimized_attribute_fanout - -let dummy_one t = - GlobalOptions.(t.tco_saved_state.rollouts).Saved_state_rollouts.dummy_one - let profile_top_level_definitions t = t.GlobalOptions.tco_profile_top_level_definitions diff --git a/hphp/hack/src/oxidized/gen/saved_state_rollouts.rs b/hphp/hack/src/oxidized/gen/saved_state_rollouts.rs index 385b1d2220383..ab0d5a848a2fc 100644 --- a/hphp/hack/src/oxidized/gen/saved_state_rollouts.rs +++ b/hphp/hack/src/oxidized/gen/saved_state_rollouts.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<<6bf34b1048481a6ef1a097e97980512a>> +// @generated SignedSource<> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -38,12 +38,8 @@ use crate::*; #[rust_to_ocaml(attr = "deriving (eq, show)")] #[repr(C)] pub struct SavedStateRollouts { - pub dummy_one: bool, - pub dummy_two: bool, - pub dummy_three: bool, + /// optimized_member_fanout is not used but we leave it as a template pub optimized_member_fanout: bool, - pub optimized_parent_fanout: bool, - pub optimized_attribute_fanout: bool, pub new_naming_table: bool, } @@ -67,18 +63,8 @@ pub struct SavedStateRollouts { #[rust_to_ocaml(attr = "deriving show { with_path = false }")] #[repr(u8)] pub enum Flag { - #[rust_to_ocaml(name = "Dummy_one")] - DummyOne, - #[rust_to_ocaml(name = "Dummy_two")] - DummyTwo, - #[rust_to_ocaml(name = "Dummy_three")] - DummyThree, #[rust_to_ocaml(name = "Optimized_member_fanout")] OptimizedMemberFanout, - #[rust_to_ocaml(name = "Optimized_parent_fanout")] - OptimizedParentFanout, - #[rust_to_ocaml(name = "Optimized_attribute_fanout")] - OptimizedAttributeFanout, #[rust_to_ocaml(name = "New_naming_table")] NewNamingTable, } diff --git a/hphp/hack/src/oxidized/manual/saved_state_rollouts_impl.rs b/hphp/hack/src/oxidized/manual/saved_state_rollouts_impl.rs index e235080f1477d..6c25df4b6a481 100644 --- a/hphp/hack/src/oxidized/manual/saved_state_rollouts_impl.rs +++ b/hphp/hack/src/oxidized/manual/saved_state_rollouts_impl.rs @@ -38,24 +38,14 @@ impl Flag { /// because we want the indices to stay consistent when we remove flags. pub fn rollout_order(&self) -> isize { match self { - Self::DummyOne => 0, - Self::DummyTwo => 1, - Self::DummyThree => 2, Self::OptimizedMemberFanout => 4, - Self::OptimizedParentFanout => 5, - Self::OptimizedAttributeFanout => 6, Self::NewNamingTable => 7, } } pub fn get_current_rollout_flag(current_rollout_flag_index: isize) -> Option { match current_rollout_flag_index { - 0 => Some(Self::DummyOne), - 1 => Some(Self::DummyTwo), - 2 => Some(Self::DummyThree), 4 => Some(Self::OptimizedMemberFanout), - 5 => Some(Self::OptimizedParentFanout), - 6 => Some(Self::OptimizedAttributeFanout), 7 => Some(Self::NewNamingTable), _ => None, } @@ -63,12 +53,7 @@ impl Flag { pub fn flag_name(&self) -> &'static str { match self { - Self::DummyOne => "dummy_one", - Self::DummyTwo => "dummy_two", - Self::DummyThree => "dummy_three", Self::OptimizedMemberFanout => "optimized_member_fanout", - Self::OptimizedParentFanout => "optimized_parent_fanout", - Self::OptimizedAttributeFanout => "optimized_attribute_fanout", Self::NewNamingTable => "new_naming_table", } } @@ -108,12 +93,7 @@ impl SavedStateRollouts { } }; Ok(Self { - dummy_one: get_flag_value(Flag::DummyOne)?, - dummy_two: get_flag_value(Flag::DummyTwo)?, - dummy_three: get_flag_value(Flag::DummyThree)?, optimized_member_fanout: get_flag_value(Flag::OptimizedMemberFanout)?, - optimized_parent_fanout: get_flag_value(Flag::OptimizedParentFanout)?, - optimized_attribute_fanout: get_flag_value(Flag::OptimizedAttributeFanout)?, new_naming_table: get_flag_value(Flag::NewNamingTable)?, }) } diff --git a/hphp/hack/src/oxidized_by_ref/gen/saved_state_rollouts.rs b/hphp/hack/src/oxidized_by_ref/gen/saved_state_rollouts.rs index 310d42dccbe10..50ba69382b1d7 100644 --- a/hphp/hack/src/oxidized_by_ref/gen/saved_state_rollouts.rs +++ b/hphp/hack/src/oxidized_by_ref/gen/saved_state_rollouts.rs @@ -3,7 +3,7 @@ // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. // -// @generated SignedSource<> +// @generated SignedSource<> // // To regenerate this file, run: // hphp/hack/src/oxidized_regen.sh @@ -38,12 +38,8 @@ use crate::*; #[rust_to_ocaml(attr = "deriving (eq, show)")] #[repr(C)] pub struct SavedStateRollouts { - pub dummy_one: bool, - pub dummy_two: bool, - pub dummy_three: bool, + /// optimized_member_fanout is not used but we leave it as a template pub optimized_member_fanout: bool, - pub optimized_parent_fanout: bool, - pub optimized_attribute_fanout: bool, pub new_naming_table: bool, } impl TrivialDrop for SavedStateRollouts {} @@ -69,18 +65,8 @@ arena_deserializer::impl_deserialize_in_arena!(SavedStateRollouts); #[rust_to_ocaml(attr = "deriving show { with_path = false }")] #[repr(u8)] pub enum Flag { - #[rust_to_ocaml(name = "Dummy_one")] - DummyOne, - #[rust_to_ocaml(name = "Dummy_two")] - DummyTwo, - #[rust_to_ocaml(name = "Dummy_three")] - DummyThree, #[rust_to_ocaml(name = "Optimized_member_fanout")] OptimizedMemberFanout, - #[rust_to_ocaml(name = "Optimized_parent_fanout")] - OptimizedParentFanout, - #[rust_to_ocaml(name = "Optimized_attribute_fanout")] - OptimizedAttributeFanout, #[rust_to_ocaml(name = "New_naming_table")] NewNamingTable, } diff --git a/hphp/hack/src/providers/provider_utils.ml b/hphp/hack/src/providers/provider_utils.ml index 548ad6e94d4c1..3661aa437f04f 100644 --- a/hphp/hack/src/providers/provider_utils.ml +++ b/hphp/hack/src/providers/provider_utils.ml @@ -258,7 +258,7 @@ let invalidate_decls_upon_change in match (prev_sc, new_sc) with | (Some prev_sc, Some new_sc) -> - Shallow_class_diff.diff_class ctx package_info prev_sc new_sc + Shallow_class_diff.diff_class package_info prev_sc new_sc |> Option.is_some | _ -> true) in diff --git a/hphp/hack/src/typing/env/deps.ml b/hphp/hack/src/typing/env/deps.ml index 687348428ecf2..e11af050e3496 100644 --- a/hphp/hack/src/typing/env/deps.ml +++ b/hphp/hack/src/typing/env/deps.ml @@ -129,15 +129,10 @@ let make_depend_on_constructor_name env class_name = let make_depend_on_constructor env class_ = if not (Pos_or_decl.is_hhi (Cls.pos class_)) then ( make_depend_on_constructor_name env (Cls.name class_); - if - not - (TypecheckerOptions.optimized_member_fanout - Typing_env_types.(env.genv.tcopt)) - then - Option.iter - (fst (Cls.construct class_)) - ~f:(fun ce -> - make_depend_on_constructor_name env ce.Typing_defs.ce_origin) + Option.iter + (fst (Cls.construct class_)) + ~f:(fun ce -> + make_depend_on_constructor_name env ce.Typing_defs.ce_origin) ) let make_depend_on_module_name env module_name = @@ -148,28 +143,12 @@ let make_depend_on_module env name md = | Some md when Pos_or_decl.is_hhi md.Typing_defs.mdt_pos -> () | _ -> make_depend_on_module_name env name -let make_depend_on_parent env ~skip_constructor_dep ~is_req name class_ = +let make_depend_on_parent env ~skip_constructor_dep name class_ = match class_ with | Decl_entry.Found cd when Pos_or_decl.is_hhi (Cls.pos cd) -> () | _ -> if not skip_constructor_dep then make_depend_on_constructor_name env name; - let dep = - if - TypecheckerOptions.optimized_member_fanout - Typing_env_types.(env.genv.tcopt) - && is_req - then - Dep.RequireExtends name - else - Dep.Extends name - in - add_dependency_edge env dep - -let add_not_subtype_dep env name = - if - TypecheckerOptions.optimized_parent_fanout Typing_env_types.(env.genv.tcopt) - then - add_dependency_edge env (Dep.NotSubtype name) + add_dependency_edge env (Dep.Extends name) let add_member_dep ~is_method ~is_static env (class_ : Cls.t) mid class_elt_opt = @@ -186,12 +165,7 @@ let add_member_dep ~is_method ~is_static env (class_ : Cls.t) mid class_elt_opt if not (Pos_or_decl.is_hhi (Cls.pos class_)) then ( make_depend_on_class_name env (Cls.name class_); add_dep (Cls.name class_); - if - not - (TypecheckerOptions.optimized_member_fanout - Typing_env_types.(env.genv.tcopt)) - then - Option.iter class_elt_opt ~f:(fun ce -> add_dep ce.Typing_defs.ce_origin) + Option.iter class_elt_opt ~f:(fun ce -> add_dep ce.Typing_defs.ce_origin) ); () diff --git a/hphp/hack/src/typing/env/deps.mli b/hphp/hack/src/typing/env/deps.mli index 0c4b77cfe99f8..ba3d4f1559239 100644 --- a/hphp/hack/src/typing/env/deps.mli +++ b/hphp/hack/src/typing/env/deps.mli @@ -45,13 +45,10 @@ val add_member_dep : val make_depend_on_parent : Typing_env_types.env -> skip_constructor_dep:bool -> - is_req:bool -> string -> Folded_class.t Decl_entry.t -> unit -val add_not_subtype_dep : Typing_env_types.env -> string -> unit - val mark_class_constant_declared : Typing_env_types.env -> string -> string -> unit diff --git a/hphp/hack/src/typing/env/typing_env.ml b/hphp/hack/src/typing/env/typing_env.ml index f7ea2b0282bb2..f04912e342d51 100644 --- a/hphp/hack/src/typing/env/typing_env.ml +++ b/hphp/hack/src/typing/env/typing_env.ml @@ -624,63 +624,6 @@ let make_depend_on_current_module env = Typing_env_types.(env.genv.current_module) ~f:(fun (_, mid) -> Deps.make_depend_on_module_name env mid) -let mark_members_declared_in_depgraph env (c : _ Aast.class_) = - let { - c_span = _; - c_annotation = _; - c_mode = _; - c_final = _; - c_is_xhp = _; - c_has_xhp_keyword = _; - c_kind = _; - c_name = (_p, class_name); - c_tparams = _; - c_extends = _; - c_uses = _; - c_xhp_attr_uses = _; - c_xhp_category = _; - c_reqs = _; - c_implements = _; - c_consts; - c_typeconsts; - c_vars; - c_methods; - c_xhp_children = _; - c_xhp_attrs; - c_namespace = _; - c_user_attributes = _; - c_file_attributes = _; - c_docs_url = _; - c_enum = _; - c_doc_comment = _; - c_emit_id = _; - c_internal = _; - c_module = _; - c_package = _; - } = - c - in - List.iter c_consts ~f:(fun { cc_id = (_p, name); _ } -> - Deps.mark_class_constant_declared env class_name name); - List.iter c_typeconsts ~f:(fun { c_tconst_name = (_p, name); _ } -> - Deps.mark_typeconst_declared env class_name name); - List.iter c_vars ~f:(fun { cv_id = (_p, name); cv_is_static; _ } -> - Deps.mark_property_declared env ~is_static:cv_is_static class_name name); - List.iter c_methods ~f:(fun { m_name = (_p, name); m_static; _ } -> - if String.equal Naming_special_names.Members.__construct name then - Deps.mark_constructor_declared env class_name - else - Deps.mark_method_declared env ~is_static:m_static class_name name); - List.iter c_xhp_attrs ~f:(fun (_ty, { cv_id = (_p, name); _ }, _tag, _el) -> - Deps.mark_xhp_attribute_declared env class_name name); - () - -let add_non_external_deps env (c : _ Aast.class_) = - make_depend_on_current_module env; - if TypecheckerOptions.optimized_member_fanout (get_tcopt env) then - mark_members_declared_in_depgraph env c; - () - let set_internal env b = { env with genv = { env.genv with this_internal = b } } let get_internal env = env.genv.this_internal @@ -798,13 +741,13 @@ let get_class (env : env) (name : Decl_provider.type_key) : Cls.t Decl_entry.t = Deps.make_depend_on_class env name res; res -let get_parent env ~skip_constructor_dep ~is_req name : Cls.t Decl_entry.t = +let get_parent env ~skip_constructor_dep name : Cls.t Decl_entry.t = let res = get_class env name in - Deps.make_depend_on_parent env ~skip_constructor_dep ~is_req name res; + Deps.make_depend_on_parent env ~skip_constructor_dep name res; res -let add_parent_dep env ~skip_constructor_dep ~is_req name : unit = - let _ = get_parent env ~skip_constructor_dep ~is_req name in +let add_parent_dep env ~skip_constructor_dep name : unit = + let _ = get_parent env ~skip_constructor_dep name in () let get_class_or_typedef env x : @@ -965,9 +908,6 @@ let get_construct env class_ = Deps.make_depend_on_constructor env class_; Cls.construct class_ -let add_not_subtype_dep env type_name : unit = - Deps.add_not_subtype_dep env type_name - let get_return env = env.genv.return let set_return env x = diff --git a/hphp/hack/src/typing/env/typing_env.mli b/hphp/hack/src/typing/env/typing_env.mli index 58b70c6b504b8..d50202653829e 100644 --- a/hphp/hack/src/typing/env/typing_env.mli +++ b/hphp/hack/src/typing/env/typing_env.mli @@ -135,8 +135,7 @@ val env_with_constructor_droot_member : env -> env (** Get class declaration from the appropriate backend and add dependency. *) val get_class : env -> type_key -> class_decl Decl_entry.t -val add_parent_dep : - env -> skip_constructor_dep:bool -> is_req:bool -> string -> unit +val add_parent_dep : env -> skip_constructor_dep:bool -> string -> unit (** Get function declaration from the appropriate backend and add dependency. *) val get_fun : @@ -301,12 +300,6 @@ val set_current_package_membership : module *) val make_depend_on_current_module : Typing_env_types.env -> unit -(** Update the dep graph with info inherent to the class, - e.g. its kind, module, declared members. *) -val add_non_external_deps : Typing_env_types.env -> Nast.class_ -> unit - -val add_not_subtype_dep : Typing_env_types.env -> string -> unit - val get_internal : env -> bool val get_support_dynamic_type : env -> bool diff --git a/hphp/hack/src/typing/typing_class.ml b/hphp/hack/src/typing/typing_class.ml index 66fb95f00dd6d..0f7b13495eed9 100644 --- a/hphp/hack/src/typing/typing_class.ml +++ b/hphp/hack/src/typing/typing_class.ml @@ -591,14 +591,11 @@ let rec check_implements_or_extends_unique impl ~env = (** Add a dependency to constructors or produce an error if not a Tapply. *) let check_is_tapply_add_constructor_extends_dep - env - ?(skip_constructor_dep = false) - (deps : ((pos * _) * decl_ty) list) - ~is_req = + env ?(skip_constructor_dep = false) (deps : ((pos * _) * decl_ty) list) = List.iter deps ~f:(fun ((p, _dep_hint), dep) -> match get_node dep with | Tapply ((_, class_name), _) -> - Env.add_parent_dep env ~skip_constructor_dep ~is_req class_name + Env.add_parent_dep env ~skip_constructor_dep class_name | Tgeneric _ -> Typing_error_utils.add_typing_error ~env @@ -1671,25 +1668,21 @@ let check_parents_are_tapply_add_constructor_deps } = parents in - check_is_tapply_add_constructor_extends_dep env ~is_req:false extends; + check_is_tapply_add_constructor_extends_dep env extends; check_is_tapply_add_constructor_extends_dep env implements ~skip_constructor_dep: - (not (Ast_defs.is_c_trait c.c_kind || Ast_defs.is_c_abstract c.c_kind)) - ~is_req:false; - check_is_tapply_add_constructor_extends_dep env ~is_req:false uses; - check_is_tapply_add_constructor_extends_dep env ~is_req:true req_class; - check_is_tapply_add_constructor_extends_dep env ~is_req:true req_this_as; - check_is_tapply_add_constructor_extends_dep env ~is_req:true req_extends; - check_is_tapply_add_constructor_extends_dep env ~is_req:true req_implements; - Option.iter - enum_includes - ~f:(check_is_tapply_add_constructor_extends_dep env ~is_req:false); + (not (Ast_defs.is_c_trait c.c_kind || Ast_defs.is_c_abstract c.c_kind)); + check_is_tapply_add_constructor_extends_dep env uses; + check_is_tapply_add_constructor_extends_dep env req_class; + check_is_tapply_add_constructor_extends_dep env req_this_as; + check_is_tapply_add_constructor_extends_dep env req_extends; + check_is_tapply_add_constructor_extends_dep env req_implements; + Option.iter enum_includes ~f:(check_is_tapply_add_constructor_extends_dep env); check_is_tapply_add_constructor_extends_dep env xhp_attr_uses - ~is_req:false ~skip_constructor_dep:true; () @@ -1961,7 +1954,7 @@ let class_def ctx (c : _ class_) = let env = Env.set_support_dynamic_type env (Cls.get_support_dynamic_type tc) in - Env.add_non_external_deps env c; + Env.make_depend_on_current_module env; Typing_helpers.add_decl_errors ~env (Cls.decl_errors tc); Some (class_def_ env c tc) diff --git a/hphp/hack/src/typing/typing_extends.ml b/hphp/hack/src/typing/typing_extends.ml index 3ff3f53d91b2f..7df4dd4d4d89f 100644 --- a/hphp/hack/src/typing/typing_extends.ml +++ b/hphp/hack/src/typing/typing_extends.ml @@ -643,11 +643,7 @@ let add_pessimisation_dependency let add_member_dep env class_ parent_class (member_kind, member_name, member_origin) = let origin_pos = Cls.pos parent_class in - if - (not - (TypecheckerOptions.optimized_member_fanout @@ Typing_env.get_tcopt env)) - && not (Pos_or_decl.is_hhi origin_pos) - then ( + if not (Pos_or_decl.is_hhi origin_pos) then ( let dep = match member_kind with | MemberKind.Method -> Dep.Method (member_origin, member_name) diff --git a/hphp/hack/src/typing/typing_subtype.ml b/hphp/hack/src/typing/typing_subtype.ml index 35d837c350e17..4d3b7ee7d87e0 100644 --- a/hphp/hack/src/typing/typing_subtype.ml +++ b/hphp/hack/src/typing/typing_subtype.ml @@ -573,35 +573,21 @@ module Subtype_negation = struct else match (Env.get_class env c1, Env.get_class env c2) with | (Decl_entry.Found c1_def, Decl_entry.Found c2_def) -> - let is_disjoint = - if Cls.final c1_def then - (* if c1 is final, then c3 would have to be equal to c1 *) - not (Cls.has_ancestor c1_def c2) - else if Cls.final c2_def then - (* if c2 is final, then c3 would have to be equal to c2 *) - not (Cls.has_ancestor c2_def c1) - else - (* Given two non-final classes, if either is an interface or trait, then - there could be a c3, and so we consider the classes to not be disjoint. - However, if they are both classes, then c3 must be either c1 or c2 since - we don't have multiple inheritance. *) - (not (is_interface_or_trait c1_def)) - && (not (is_interface_or_trait c2_def)) - && (not (Cls.has_ancestor c2_def c1)) - && not (Cls.has_ancestor c1_def c2) - in - if is_disjoint then ( - (* We've used the facts that 'c1 is not a subtype of c2' - * and 'c2 is not a subtype of c1' to conclude that a type is nothing - * and therefore a bunch of things typecheck. - * If these facts get invalidated by a decl change, - * e.g. adding c2 as a parent of c1, we'd therefore need - * to recheck the current def. *) - Typing_env.add_not_subtype_dep env c1; - Typing_env.add_not_subtype_dep env c2; - () - ); - is_disjoint + if Cls.final c1_def then + (* if c1 is final, then c3 would have to be equal to c1 *) + not (Cls.has_ancestor c1_def c2) + else if Cls.final c2_def then + (* if c2 is final, then c3 would have to be equal to c2 *) + not (Cls.has_ancestor c2_def c1) + else + (* Given two non-final classes, if either is an interface or trait, then + there could be a c3, and so we consider the classes to not be disjoint. + However, if they are both classes, then c3 must be either c1 or c2 since + we don't have multiple inheritance. *) + (not (is_interface_or_trait c1_def)) + && (not (is_interface_or_trait c2_def)) + && (not (Cls.has_ancestor c2_def c1)) + && not (Cls.has_ancestor c1_def c2) | _ -> (* This is a decl error that should have already been caught *) false diff --git a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect1.php.exp b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect1.php.exp index 15145c6d0ced4..2fe3e2f996adc 100644 --- a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect1.php.exp +++ b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect1.php.exp @@ -1,4 +1,3 @@ Fun f Type A -f.php -- diff --git a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect2.php.exp b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect2.php.exp index f971c2c7452c0..c803b5f2467f3 100644 --- a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect2.php.exp +++ b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect2.php.exp @@ -1,4 +1,3 @@ Fun f Type B -f.php -- diff --git a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect3.php.exp b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect3.php.exp index 42b58c80b3b49..bf035734b0312 100644 --- a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect3.php.exp +++ b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect3.php.exp @@ -1,5 +1,4 @@ Fun f Type A Type C -f.php -- diff --git a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect4.php.exp b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect4.php.exp index 7d9b360974c9b..020a01d460ab7 100644 --- a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect4.php.exp +++ b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_disjoint_interect4.php.exp @@ -2,5 +2,4 @@ Type A Type C Type Ta Type Tb -tb.php -- diff --git a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_error1.php.exp b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_error1.php.exp index c4d83f2bbe61e..fbc5132dfe557 100644 --- a/hphp/hack/test/fanout/series_of_repo_changes/added_parent_error1.php.exp +++ b/hphp/hack/test/fanout/series_of_repo_changes/added_parent_error1.php.exp @@ -1,4 +1,3 @@ Type A Type B -f.php --