Ondemand: optim

Reviewed By: jvillard

Differential Revision: D7397164

fbshipit-source-id: 4e5a8bc
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 82a264ff9f
commit 77f5e6f08b

@ -144,11 +144,7 @@ let iterate_callbacks (exe_env: Exe_env.t) =
SourceFiles.proc_names_of_source exe_env.source_file
in
if Config.dump_duplicate_symbols then dump_duplicate_procs exe_env procs_to_analyze ;
let analyze_proc_name pname =
Option.iter
~f:(fun pdesc -> ignore (Ondemand.analyze_proc_desc pdesc))
(Ondemand.get_proc_desc pname)
in
let analyze_proc_name pname = ignore (Ondemand.analyze_proc_name pname : Specs.summary option) in
List.iter ~f:analyze_proc_name procs_to_analyze ;
(* Invoke cluster callbacks. *)
iterate_cluster_callbacks procs_to_analyze exe_env get_proc_desc ;

@ -168,25 +168,29 @@ let run_proc_analysis analyze_proc ~caller_pdesc callee_pdesc =
log_error_and_continue exn initial_summary (FKcrash (Exn.to_string exn))
let analyze_proc_desc ?caller_pdesc callee_pdesc =
let analyze_proc ?caller_pdesc callee_pdesc =
let callbacks = Option.value_exn !callbacks_ref in
Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc)
let analyze_proc_desc ~caller_pdesc callee_pdesc =
let callee_pname = Procdesc.get_proc_name callee_pdesc in
if is_active callee_pname then None
else
let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option =
let callbacks = Option.value_exn !callbacks_ref in
let proc_attributes = Procdesc.get_attributes callee_pdesc in
if should_be_analyzed callee_pname proc_attributes then
Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc)
analyze_proc ~caller_pdesc callee_pdesc
else Specs.get_summary callee_pname
in
Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option
(** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered
during the analysis of curr_pname *)
(** analyze_proc_name ?caller_pdesc proc_name performs an on-demand analysis of proc_name triggered
during the analysis of caller_pdesc *)
let analyze_proc_name ?caller_pdesc callee_pname =
if is_active callee_pname then None
else
@ -197,7 +201,7 @@ let analyze_proc_name ?caller_pdesc callee_pname =
if procedure_should_be_analyzed callee_pname then
match callbacks.get_proc_desc callee_pname with
| Some callee_pdesc ->
analyze_proc_desc ?caller_pdesc callee_pdesc
analyze_proc ?caller_pdesc callee_pdesc
| None ->
Specs.get_summary callee_pname
else Specs.get_summary callee_pname

@ -20,7 +20,7 @@ type callbacks = {analyze_ondemand: analyze_ondemand; get_proc_desc: get_proc_de
val get_proc_desc : get_proc_desc
(** Find a proc desc for the procedure, perhaps loading it from disk. *)
val analyze_proc_desc : ?caller_pdesc:Procdesc.t -> Procdesc.t -> Specs.summary option
val analyze_proc_desc : caller_pdesc:Procdesc.t -> Procdesc.t -> Specs.summary option
(** [analyze_proc_desc ~caller_pdesc callee_pdesc] performs an on-demand analysis of callee_pdesc
triggered during the analysis of caller_pdesc *)

Loading…
Cancel
Save