1 cananian 1.1.2.1 // CheckOracle.java, created Sun Nov 12 01:19:11 2000 by cananian 2 cananian 1.1.2.1 // Copyright (C) 2000 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1.2.1 package harpoon.Analysis.Transactions; 5 cananian 1.1.2.1 6 cananian 1.1.2.1 import harpoon.ClassFile.HClass; 7 cananian 1.1.2.1 import harpoon.ClassFile.HCodeElement; 8 cananian 1.1.2.1 import harpoon.ClassFile.HField; 9 cananian 1.1.2.1 import harpoon.Temp.Temp; 10 cananian 1.1.2.1 11 cananian 1.1.2.1 import java.util.Set; 12 cananian 1.1.2.1 /** 13 cananian 1.1.2.1 * A <code>CheckOracle</code> helps the SyncTransformer place 14 cananian 1.1.2.1 * field and object version lookups and checks. 15 cananian 1.1.2.1 * 16 cananian 1.1.2.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 17 cananian 1.3 * @version $Id: CheckOracle.java,v 1.3 2002/04/10 03:01:43 cananian Exp $ 18 cananian 1.1.2.1 */ 19 cananian 1.1.2.1 abstract class CheckOracle { 20 cananian 1.1.2.1 21 cananian 1.1.2.1 /** Returns <code>Set</code> of <code>Temp</code>s for which read-only 22 cananian 1.1.2.1 * versions should be looked up just before <code>hce</code> is 23 cananian 1.1.2.1 * executed. */ 24 cananian 1.2.2.1 public abstract Set<Temp> createReadVersions(HCodeElement hce); 25 cananian 1.1.2.1 /** Returns <code>Set</code> of <code>Temp</code>s for which writable 26 cananian 1.1.2.1 * versions should be created just before <code>hce</code> is executed. */ 27 cananian 1.2.2.1 public abstract Set<Temp> createWriteVersions(HCodeElement hce); 28 cananian 1.1.2.1 /** Returns a <code>Set</code> of <code>RefAndField</code> tuples 29 cananian 1.1.2.4 * which should be read-checked before <code>hce</code> is 30 cananian 1.1.2.1 * executed. */ 31 cananian 1.2.2.1 public abstract Set<RefAndField> checkFieldReads(HCodeElement hce); 32 cananian 1.1.2.4 /** Returns a <code>Set</code> of <code>RefAndField</code> tuples 33 cananian 1.1.2.4 * which should be write-checked before <code>hce</code> is 34 cananian 1.1.2.4 * executed. */ 35 cananian 1.2.2.1 public abstract Set<RefAndField> checkFieldWrites(HCodeElement hce); 36 cananian 1.1.2.4 /** Returns a <code>Set</code> of <code>RefAndIndexAndType</code> 37 cananian 1.1.2.4 * typles which indicate indexed array elements which should be 38 cananian 1.1.2.4 * read-checked before <code>hce</code> is executed. */ 39 cananian 1.2.2.1 public abstract Set<RefAndIndexAndType> checkArrayElementReads(HCodeElement hce); 40 cananian 1.1.2.1 /** Returns a <code>Set</code> of <code>RefAndIndexAndType</code> 41 cananian 1.1.2.1 * typles which indicate indexed array elements which should be 42 cananian 1.1.2.4 * write-checked before <code>hce</code> is executed. */ 43 cananian 1.2.2.1 public abstract Set<RefAndIndexAndType> checkArrayElementWrites(HCodeElement hce); 44 cananian 1.1.2.1 45 cananian 1.1.2.1 class RefAndField { 46 cananian 1.1.2.1 public final Temp objref; 47 cananian 1.1.2.1 public final HField field; 48 cananian 1.1.2.1 RefAndField(Temp objref, HField field) { 49 cananian 1.1.2.1 this.objref = objref; this.field = field; 50 cananian 1.1.2.1 } 51 cananian 1.1.2.2 // define hashCode and equals so these objects work well in sets 52 cananian 1.1.2.2 public int hashCode() { return objref.hashCode() ^ field.hashCode(); } 53 cananian 1.1.2.2 public boolean equals(Object o) { 54 cananian 1.1.2.2 if (!(o instanceof RefAndField)) return false; 55 cananian 1.1.2.2 RefAndField raf = (RefAndField) o; 56 cananian 1.1.2.2 return this.objref.equals(raf.objref) && 57 cananian 1.1.2.2 this.field.equals(raf.field); 58 cananian 1.1.2.2 } 59 cananian 1.1.2.3 // for debugging, define toString 60 cananian 1.1.2.3 public String toString() { return "{ "+objref+", "+field+" }"; } 61 cananian 1.1.2.1 } 62 cananian 1.1.2.1 class RefAndIndexAndType { 63 cananian 1.1.2.1 public final Temp objref; 64 cananian 1.1.2.1 public final Temp index; 65 cananian 1.1.2.1 public final HClass type; 66 cananian 1.1.2.1 RefAndIndexAndType(Temp objref, Temp index, HClass type) { 67 cananian 1.1.2.1 this.objref = objref; this.index = index; this.type = type; 68 cananian 1.1.2.2 } 69 cananian 1.1.2.2 // define hashCode and equals so these objects work well in sets 70 cananian 1.1.2.2 public int hashCode() { return objref.hashCode() ^ index.hashCode(); } 71 cananian 1.1.2.2 public boolean equals(Object o) { 72 cananian 1.1.2.2 if (!(o instanceof RefAndIndexAndType)) return false; 73 cananian 1.1.2.2 RefAndIndexAndType rit = (RefAndIndexAndType) o; 74 cananian 1.1.2.2 return this.objref.equals(rit.objref) && 75 cananian 1.1.2.2 this.index.equals(rit.index) && 76 cananian 1.1.2.2 this.type.equals(rit.type); 77 cananian 1.1.2.1 } 78 cananian 1.1.2.3 // for debugging, define toString 79 cananian 1.1.2.3 public String toString() { return "{ "+objref+", "+index+", "+type+" }"; } 80 cananian 1.1.2.1 } 81 cananian 1.2 }