From 65dd303415d1fe4caac40dddc05499df67d1a745 Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Fri, 4 Sep 2020 03:19:31 -0700 Subject: [PATCH] [cost] Add new experimental cost kind Reviewed By: ngorogiannis Differential Revision: D23502703 fbshipit-source-id: f27353c7e --- infer/src/base/costKind.ml | 23 ++++++++++++++++++++--- infer/src/base/costKind.mli | 2 +- infer/src/cost/costDomain.mli | 9 +++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/infer/src/base/costKind.ml b/infer/src/base/costKind.ml index d2bb0c228..59ff40e10 100644 --- a/infer/src/base/costKind.ml +++ b/infer/src/base/costKind.ml @@ -7,20 +7,35 @@ open! IStd module F = Format -type t = OperationCost | AllocationCost [@@deriving compare] +type t = OperationCost | AllocationCost | AutoreleasepoolSize [@@deriving compare] + +let to_issue_string = function + | OperationCost -> + "EXECUTION_TIME" + | AllocationCost -> + "ALLOCATION" + | AutoreleasepoolSize -> + "AUTORELEASEPOOL_SIZE" -let to_issue_string = function OperationCost -> "EXECUTION_TIME" | AllocationCost -> "ALLOCATION" let to_complexity_string = function | AllocationCost -> "Allocation complexity" + | AutoreleasepoolSize -> + "Autoreleasepool size" | OperationCost -> "Time complexity" let pp f k = let k_str = - match k with OperationCost -> "Execution Cost" | AllocationCost -> "Allocation Cost" + match k with + | OperationCost -> + "Execution Cost" + | AllocationCost -> + "Allocation Cost" + | AutoreleasepoolSize -> + "Autoreleasepool Size" in F.pp_print_string f k_str @@ -30,6 +45,8 @@ let to_json_cost_info c = function c.Jsonbug_t.exec_cost | AllocationCost -> assert false + | AutoreleasepoolSize -> + assert false type kind_spec = {kind: t; (* for non-diff analysis *) top_and_unreachable: bool} diff --git a/infer/src/base/costKind.mli b/infer/src/base/costKind.mli index b1367114f..0d8ea5837 100644 --- a/infer/src/base/costKind.mli +++ b/infer/src/base/costKind.mli @@ -7,7 +7,7 @@ open! IStd -type t = OperationCost | AllocationCost [@@deriving compare] +type t = OperationCost | AllocationCost | AutoreleasepoolSize [@@deriving compare] type kind_spec = {kind: t; (* for non-diff analysis *) top_and_unreachable: bool} diff --git a/infer/src/cost/costDomain.mli b/infer/src/cost/costDomain.mli index bf24fb833..822199ec1 100644 --- a/infer/src/cost/costDomain.mli +++ b/infer/src/cost/costDomain.mli @@ -65,7 +65,7 @@ val get_operation_cost : t -> BasicCostWithReason.t val map : f:(BasicCostWithReason.t -> BasicCostWithReason.t) -> t -> t val zero_record : t -(** Map representing cost record \{OperationCost:0; AllocationCost:0\} *) +(** Map representing cost record \{OperationCost:0; AllocationCost:0; AutoreleasepoolSize:0\} *) val mult_by : t -> nb_exec:BasicCost.t -> t (** Special map where each element is multiplied by the number of executions *) @@ -74,10 +74,11 @@ val plus : t -> t -> t (** Union of two maps where common costs are added together *) val unit_cost_atomic_operation : t -(** Map representing cost record \{OperationCost:1; AllocationCost:0\} *) +(** Map representing cost record \{OperationCost:1; AllocationCost:0; AutoreleasepoolSize:0\} *) val unit_cost_allocation : t -(** Map representing cost record \{OperationCost:0; AllocationCost:1\} *) +(** Map representing cost record \{OperationCost:0; AllocationCost:1; AutoreleasepoolSize:0\} *) val of_operation_cost : BasicCost.t -> t -(** Map representing cost record \{OperationCost:operation_cost; AllocationCost:0\} *) +(** Map representing cost record \{OperationCost:operation_cost; AllocationCost:0; + AutoreleasepoolSize:0\} *)