[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
master
Nikos Gorogiannis 5 years ago committed by Facebook Github Bot
parent f7a860401b
commit b8d51b0493

@ -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]) *)

@ -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 *)

Loading…
Cancel
Save