From b8d51b0493103303ebd17759535f5941c5983ae0 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Mon, 13 Jan 2020 07:14:42 -0800 Subject: [PATCH] [starvation] use root component in lock order Summary: Now that we have the kind of lock stored (global/class obj/path rooted at parameter), use it for comparison/equality, while ignoring the root variable of the access path, which is only used for printing. Reviewed By: skcho Differential Revision: D19346801 fbshipit-source-id: c65661dc6 --- infer/src/IR/AccessPath.mli | 2 +- infer/src/concurrency/starvationDomain.ml | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/infer/src/IR/AccessPath.mli b/infer/src/IR/AccessPath.mli index c5b6def91..3b0bd76b3 100644 --- a/infer/src/IR/AccessPath.mli +++ b/infer/src/IR/AccessPath.mli @@ -14,7 +14,7 @@ type base = Var.t * Typ.t [@@deriving compare] type access = | ArrayAccess of Typ.t * t list (** array element type with list of access paths in index *) | FieldAccess of Fieldname.t (** field name *) -[@@deriving compare] +[@@deriving compare, equal] (** root var, and a list of accesses. closest to the root var is first that is, x.f.g is representedas (x, [f; g]) *) diff --git a/infer/src/concurrency/starvationDomain.ml b/infer/src/concurrency/starvationDomain.ml index 5d796a620..832ade9a2 100644 --- a/infer/src/concurrency/starvationDomain.ml +++ b/infer/src/concurrency/starvationDomain.ml @@ -83,20 +83,26 @@ module ThreadDomain = struct end module Lock = struct - type var = Var.t + (** var type used only for printing, not comparisons *) + module IgnoreVar = struct + type t = Var.t - let compare_var = Var.compare_modulo_this + let compare _x _y = 0 - type path = (var * Typ.t) * AccessPath.access list [@@deriving compare] + let equal _x _y = true + end + + (** access path that does not ignore the type (like the original AccessPath.t) but which instead + ignores the root variable for comparisons; this is taken care of by the root type *) + type path = (IgnoreVar.t * Typ.t) * AccessPath.access list [@@deriving compare, equal] type root = | Global of Mangled.t | Class of Typ.name | Parameter of int (** method parameter represented by its 0-indexed position *) + [@@deriving compare, equal] - type t = {root: root [@compare.ignore]; path: path} [@@deriving compare] - - let equal = [%compare.equal: t] + type t = {root: root; path: path} [@@deriving compare, equal] (* using an indentifier for a class object, create an access path representing that lock; this is for synchronizing on Java class objects only *)