1 package Analysis.Disjoint;
8 ///////////////////////////////////////////
10 // This class is an immutable Canonical, so
12 // 0) construct them with a factory pattern
13 // to ensure only canonical versions escape
15 // 1) any operation that modifies a Canonical
16 // is a static method in the Canonical class
18 // 2) operations that just read this object
19 // should be defined here
21 // 3) every Canonical subclass hashCode should
22 // throw an error if the hash ever changes
24 ///////////////////////////////////////////
26 // a taint is applied to a reference edge, and
27 // is used to associate an effect with a heap root
29 public class Taint extends Canonical {
31 // taints can either be associated with
32 // a stall site and live variable or
33 // an sese (rblock) and an in-set var
34 // only one identifer will be non-null
36 // identify an sese (rblock) + inset var
37 protected FlatSESEEnterNode sese;
39 // identify a stall site + live variable
40 protected FlatNode stallSite;
42 // either type of taint includes a var
43 // and allocation site
44 protected TempDescriptor var;
45 protected AllocSite allocSite;
47 // existance predicates must be true in a caller
48 // context for this taint's effects to transfer from this
49 // callee to that context
50 protected ExistPredSet preds;
52 public static Taint factory( FlatSESEEnterNode sese,
53 TempDescriptor insetVar,
56 Taint out = new Taint( sese, null, insetVar, as, eps );
57 out = (Taint) Canonical.makeCanonical( out );
61 public static Taint factory( FlatNode stallSite,
62 TempDescriptor liveVar,
65 Taint out = new Taint( null, stallSite, liveVar, as, eps );
66 out = (Taint) Canonical.makeCanonical( out );
70 public static Taint factory( FlatSESEEnterNode sese,
72 TempDescriptor liveVar,
75 Taint out = new Taint( sese, stallSite, liveVar, as, eps );
76 out = (Taint) Canonical.makeCanonical( out );
80 protected Taint( FlatSESEEnterNode sese,
86 (sese == null && stallSite != null) ||
87 (sese != null && stallSite == null);
94 this.stallSite = stallSite;
100 protected Taint( Taint t ) {
108 public boolean isRBlockTaint() {
112 public boolean isStallSiteTaint() {
113 return stallSite != null;
116 public FlatSESEEnterNode getSESE() {
120 public FlatNode getStallSite() {
124 public TempDescriptor getVar() {
128 public AllocSite getAllocSite() {
132 public ExistPredSet getPreds() {
136 public boolean equalsSpecific( Object o ) {
137 if( !equalsIgnorePreds( o ) ) {
142 return preds.equals( t.preds );
145 public boolean equalsIgnorePreds( Object o ) {
150 if( !(o instanceof Taint) ) {
158 seseEqual = (t.sese == null);
160 seseEqual = sese.equals( t.sese );
163 boolean stallSiteEqual;
164 if( stallSite == null ) {
165 stallSiteEqual = (t.stallSite == null);
167 stallSiteEqual = stallSite.equals( t.stallSite );
173 var .equals( t.var ) &&
174 allocSite.equals( t.allocSite );
177 public int hashCodeSpecific() {
178 int hash = allocSite.hashCode();
179 hash = hash ^ var.hashCode();
182 hash = hash ^ sese.hashCode();
185 if( stallSite != null ) {
186 hash = hash ^ stallSite.hashCode();
192 public String toString() {
196 if( isRBlockTaint() ) {
197 if( sese.getIsCallerSESEplaceholder() ) {
200 s = sese.getPrettyIdentifier();
204 s = stallSite.toString();
210 ", "+allocSite.toStringBrief()+