[racerd] optimise add_callee_accesses

Summary:
This function is used to adapt the callee summary at a call site. It did two things for every domain element in the callee summary:
- A linear search through the list of actuals.
- For each such actual, it would (repeatedly) compute its ownership (!).

For large summaries this can be substantial. The right way is to precompute the ownership for all actuals once and then simply retrieve it (via an array).

Reviewed By: jberdine

Differential Revision: D20564447

fbshipit-source-id: 1ca3121c2
master
Nikos Gorogiannis 5 years ago committed by Facebook GitHub Bot
parent a2428a11e3
commit beaed4d820

@ -118,19 +118,16 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let add_callee_accesses formals (caller_astate : Domain.t) callee_accesses locks threads actuals let add_callee_accesses formals (caller_astate : Domain.t) callee_accesses locks threads actuals
callee_pname loc = callee_pname loc =
let open Domain in let open Domain in
let actuals_ownership =
(* precompute array holding ownership of each actual for fast random access *)
Array.of_list_map actuals ~f:(fun actual_exp ->
OwnershipDomain.ownership_of_expr actual_exp caller_astate.ownership )
in
let update_ownership_precondition actual_index (acc : OwnershipAbstractValue.t) = let update_ownership_precondition actual_index (acc : OwnershipAbstractValue.t) =
match acc with if actual_index >= Array.length actuals_ownership then
| Unowned ->
(* optimisation -- already unowned, don't compute ownership of remaining actuals *)
acc
| actuals_ownership -> (
match List.nth actuals actual_index with
| None ->
(* vararg methods can result into missing actuals so simply ignore *) (* vararg methods can result into missing actuals so simply ignore *)
acc acc
| Some actual_exp -> else OwnershipAbstractValue.join acc actuals_ownership.(actual_index)
OwnershipDomain.ownership_of_expr actual_exp caller_astate.ownership
|> OwnershipAbstractValue.join actuals_ownership )
in in
let update_callee_access (snapshot : AccessSnapshot.t) acc = let update_callee_access (snapshot : AccessSnapshot.t) acc =
let access = TraceElem.with_callsite snapshot.access (CallSite.make callee_pname loc) in let access = TraceElem.with_callsite snapshot.access (CallSite.make callee_pname loc) in

Loading…
Cancel
Save