[cost] Check if callee is actually defined

Summary:
The autorelease pool size checker increases the size when an non-arc-compiled function calls
arc-compiled function.  However, if the callee is declared in arc-compiled code and its body is not
actually captured or compiled, we should not increase the autorelease pool size.

Reviewed By: ezgicicek

Differential Revision: D24569661

fbshipit-source-id: 2fd707096
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 5066944b76
commit 15c1f816dc

@ -23,6 +23,7 @@ type extras_WorstCaseCost =
; get_node_nb_exec: Node.t -> BasicCost.t ; get_node_nb_exec: Node.t -> BasicCost.t
; get_summary: Procname.t -> CostDomain.summary option ; get_summary: Procname.t -> CostDomain.summary option
; get_formals: Procname.t -> (Pvar.t * Typ.t) list option ; get_formals: Procname.t -> (Pvar.t * Typ.t) list option
; get_proc_desc: Procname.t -> Procdesc.t option
; proc_resolve_attributes: Procname.t -> ProcAttributes.t option } ; proc_resolve_attributes: Procname.t -> ProcAttributes.t option }
let instantiate_cost ?get_closure_callee_cost ~default_closure_cost integer_type_widths let instantiate_cost ?get_closure_callee_cost ~default_closure_cost integer_type_widths
@ -54,10 +55,11 @@ module InstrBasicCostWithReason = struct
List.exists prefixes ~f:(fun prefix -> String.is_prefix method_name ~prefix) List.exists prefixes ~f:(fun prefix -> String.is_prefix method_name ~prefix)
let is_objc_call_from_no_arc_to_arc {proc_resolve_attributes} caller_pdesc callee_pname = let is_objc_call_from_no_arc_to_arc {get_proc_desc} caller_pdesc callee_pname =
(not (Procdesc.is_objc_arc_on caller_pdesc)) Option.exists (get_proc_desc callee_pname) ~f:(fun callee_pdesc ->
&& Option.exists (proc_resolve_attributes callee_pname) Procdesc.is_defined callee_pdesc
~f:(fun {ProcAttributes.is_objc_arc_on} -> is_objc_arc_on) && (not (Procdesc.is_objc_arc_on caller_pdesc))
&& Procdesc.is_objc_arc_on callee_pdesc )
let dispatch_operation tenv callee_pname callee_cost_opt fun_arg_list model_env ret inferbo_mem = let dispatch_operation tenv callee_pname callee_cost_opt fun_arg_list model_env ret inferbo_mem =
@ -400,6 +402,7 @@ let checker ({InterproceduralAnalysis.proc_desc; exe_env; analyze_dependency} as
; get_node_nb_exec ; get_node_nb_exec
; get_summary ; get_summary
; get_formals ; get_formals
; get_proc_desc= AnalysisCallbacks.get_proc_desc
; proc_resolve_attributes= AnalysisCallbacks.proc_resolve_attributes } ; proc_resolve_attributes= AnalysisCallbacks.proc_resolve_attributes }
in in
AnalysisCallbacks.html_debug_new_node_session (NodeCFG.start_node node_cfg) AnalysisCallbacks.html_debug_new_node_session (NodeCFG.start_node node_cfg)

Loading…
Cancel
Save