[infer][java] load the global type environment at most once per process

Summary: The Java frontend creates a single `tenv` file per `javac` invocation, but the code loading the `tenv` for a given Java procedure in the backend was not taking advantage of it. Also, with the lazy dynamic dispatch algorithm, the procedure name can be created on-demand and therefore defeat the approach to load the tenv by looking at the call graph to associate existing procedure names to the corresponding serialized tenv file. This diff should also fix this last point.

Reviewed By: sblackshear

Differential Revision: D4969254

fbshipit-source-id: 66ed318
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent 78a7865f2a
commit b790ac8c14

@ -161,8 +161,22 @@ let file_data_to_cfg file_data =
then file_data.cfg <- Cfg.load_cfg_from_file file_data.cfg_file; then file_data.cfg <- Cfg.load_cfg_from_file file_data.cfg_file;
file_data.cfg file_data.cfg
let java_global_tenv =
lazy
(match Tenv.load_from_file DB.global_tenv_fname with
| None ->
failwithf
"Could not load the global tenv at path %s@."
(DB.filename_to_string DB.global_tenv_fname)
| Some tenv -> tenv)
(** return the type environment associated to the procedure *) (** return the type environment associated to the procedure *)
let get_tenv exe_env proc_name = let get_tenv exe_env proc_name =
match proc_name with
| Typ.Procname.Java _ ->
Lazy.force java_global_tenv
| _ ->
begin
match get_file_data exe_env proc_name with match get_file_data exe_env proc_name with
| Some file_data -> ( | Some file_data -> (
match file_data_to_tenv file_data with match file_data_to_tenv file_data with
@ -174,6 +188,7 @@ let get_tenv exe_env proc_name =
) )
| None -> | None ->
failwithf "get_tenv: file_data not found for %a" Typ.Procname.pp proc_name failwithf "get_tenv: file_data not found for %a" Typ.Procname.pp proc_name
end
(** return the cfg associated to the procedure *) (** return the cfg associated to the procedure *)
let get_cfg exe_env pname = let get_cfg exe_env pname =

Loading…
Cancel
Save