[cost] Extend cost_item json format to print autoreleasepool_size

Summary:
This diff extends the cost_item json format to print the autoreleasepool_size field.  Not yet, there
is no semantics for that code kind, so the results will always be zero with no traces.

Reviewed By: ezgicicek

Differential Revision: D23540665

fbshipit-source-id: 94442e376
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 5406fa3224
commit 4dbfb72260

@ -0,0 +1,4 @@
\[EXPERIMENTAL\] Infer reports this issue when the ObjC autoreleasepool's size complexity of a
program increases in degree: e.g. from constant to linear or from logarithmic to quadratic. This
issue type is only reported in differential mode: i.e when we are comparing the analysis results of
two runs of infer on a file.

@ -0,0 +1,8 @@
\[EXPERIMENTAL\] Infer reports this issue when the ObjC autoreleasepool's complexity of the
procedure increases in degree **and** the procedure runs on the UI (main) thread.
Infer considers a method as running on the UI thread whenever:
- The method, one of its overrides, its class, or an ancestral class, is annotated with `@UiThread`.
- The method, or one of its overrides is annotated with `@OnEvent`, `@OnClick`, etc.
- The method or its callees call a `Litho.ThreadUtils` method such as `assertMainThread`.

@ -0,0 +1,2 @@
\[EXPERIMENTAL\] This issue type indicates that the program's execution doesn't reach the exit
node. Hence, we cannot compute a static bound of ObjC autoreleasepool's size for the procedure.

@ -0,0 +1,2 @@
\[EXPERIMENTAL\] This warning indicates that Infer was not able to determine a static upper bound on
the ObjC autoreleasepool's size in the procedure. By default, this issue type is disabled.

@ -366,6 +366,10 @@ OPTIONS
ARRAY_OUT_OF_BOUNDS_L2 (disabled by default),
ARRAY_OUT_OF_BOUNDS_L3 (disabled by default),
ASSIGN_POINTER_WARNING (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT (disabled by default),
Abduction_case_not_implemented (enabled by default),
Array_of_pointsto (enabled by default),
Assert_failure (enabled by default),
@ -445,6 +449,7 @@ OPTIONS
INFERBO_ALLOC_IS_ZERO (enabled by default),
INFERBO_ALLOC_MAY_BE_BIG (enabled by default),
INFERBO_ALLOC_MAY_BE_NEGATIVE (enabled by default),
INFINITE_AUTORELEASEPOOL_SIZE (disabled by default),
INFINITE_EXECUTION_TIME (disabled by default),
INHERENTLY_DANGEROUS_FUNCTION (enabled by default),
INSECURE_INTENT_HANDLING (enabled by default),

@ -85,6 +85,10 @@ OPTIONS
ARRAY_OUT_OF_BOUNDS_L2 (disabled by default),
ARRAY_OUT_OF_BOUNDS_L3 (disabled by default),
ASSIGN_POINTER_WARNING (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT (disabled by default),
Abduction_case_not_implemented (enabled by default),
Array_of_pointsto (enabled by default),
Assert_failure (enabled by default),
@ -164,6 +168,7 @@ OPTIONS
INFERBO_ALLOC_IS_ZERO (enabled by default),
INFERBO_ALLOC_MAY_BE_BIG (enabled by default),
INFERBO_ALLOC_MAY_BE_NEGATIVE (enabled by default),
INFINITE_AUTORELEASEPOOL_SIZE (disabled by default),
INFINITE_EXECUTION_TIME (disabled by default),
INHERENTLY_DANGEROUS_FUNCTION (enabled by default),
INSECURE_INTENT_HANDLING (enabled by default),

@ -366,6 +366,10 @@ OPTIONS
ARRAY_OUT_OF_BOUNDS_L2 (disabled by default),
ARRAY_OUT_OF_BOUNDS_L3 (disabled by default),
ASSIGN_POINTER_WARNING (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE (enabled by default),
AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD (enabled by
default),
AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT (disabled by default),
Abduction_case_not_implemented (enabled by default),
Array_of_pointsto (enabled by default),
Assert_failure (enabled by default),
@ -445,6 +449,7 @@ OPTIONS
INFERBO_ALLOC_IS_ZERO (enabled by default),
INFERBO_ALLOC_MAY_BE_BIG (enabled by default),
INFERBO_ALLOC_MAY_BE_NEGATIVE (enabled by default),
INFINITE_AUTORELEASEPOOL_SIZE (disabled by default),
INFINITE_EXECUTION_TIME (disabled by default),
INHERENTLY_DANGEROUS_FUNCTION (enabled by default),
INSECURE_INTENT_HANDLING (enabled by default),

@ -90,6 +90,7 @@ type cost_item = {
procedure_id : string;
is_on_ui_thread : bool;
exec_cost : cost_info;
autoreleasepool_size : cost_info;
}
type costs_report = cost_item list

@ -223,7 +223,15 @@ end = struct
; ( "EXECUTION_TIME_UNREACHABLE_AT_EXIT"
, [%blob "../../documentation/issues/EXECUTION_TIME_UNREACHABLE_AT_EXIT.md"] )
; ("INFINITE_EXECUTION_TIME", [%blob "../../documentation/issues/INFINITE_EXECUTION_TIME.md"])
]
; ( "AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE"
, [%blob "../../documentation/issues/AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE.md"] )
; ( "AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD"
, [%blob "../../documentation/issues/AUTORELEASEPOOL_SIZE_COMPLEXITY_INCREASE_UI_THREAD.md"]
)
; ( "AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT"
, [%blob "../../documentation/issues/AUTORELEASEPOOL_SIZE_UNREACHABLE_AT_EXIT.md"] )
; ( "INFINITE_AUTORELEASEPOOL_SIZE"
, [%blob "../../documentation/issues/INFINITE_AUTORELEASEPOOL_SIZE.md"] ) ]
(** cost issues are already registered below.*)

@ -46,9 +46,11 @@ let to_json_cost_info c = function
| AllocationCost ->
assert false
| AutoreleasepoolSize ->
assert false
c.Jsonbug_t.autoreleasepool_size
type kind_spec = {kind: t; (* for non-diff analysis *) top_and_unreachable: bool}
let enabled_cost_kinds = [{kind= OperationCost; top_and_unreachable= true}]
let enabled_cost_kinds =
[ {kind= OperationCost; top_and_unreachable= true}
; {kind= AutoreleasepoolSize; top_and_unreachable= false} ]

@ -267,7 +267,9 @@ module JsonCostsPrinter = MakeJsonListPrinter (struct
; procedure_name= Procname.get_method proc_name
; procedure_id= procedure_id_of_procname proc_name
; is_on_ui_thread
; exec_cost= cost_info (CostDomain.get_cost_kind CostKind.OperationCost post).cost }
; exec_cost= cost_info (CostDomain.get_cost_kind CostKind.OperationCost post).cost
; autoreleasepool_size=
cost_info (CostDomain.get_cost_kind CostKind.AutoreleasepoolSize post).cost }
in
Some (Jsonbug_j.string_of_cost_item cost_item)
| _ ->

@ -1 +1 @@
{"top":{"current":2,"previous":1},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":6,"previous":5},{"degree":100,"current":2,"previous":3},{"degree":101,"current":2,"previous":0},{"degree":200,"current":1,"previous":2}]}
{"top":{"current":2,"previous":1},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":19,"previous":16},{"degree":100,"current":2,"previous":3},{"degree":101,"current":2,"previous":0},{"degree":200,"current":1,"previous":2}]}

@ -1 +1 @@
{"top":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":3,"previous":4},{"degree":100,"current":4,"previous":1},{"degree":200,"current":0,"previous":1}]}
{"top":{"current":0,"previous":0},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":10,"previous":10},{"degree":100,"current":4,"previous":1},{"degree":200,"current":0,"previous":1}]}
Loading…
Cancel
Save