3 import java.util.HashSet;
4 import java.util.Iterator;
7 import Analysis.OwnershipAnalysis.HeapRegionNode;
8 import IR.Flat.TempDescriptor;
10 public class LiveInNode extends ConflictNode {
12 Set<SESEEffectsKey> readEffectsSet;
13 Set<SESEEffectsKey> writeEffectsSet;
14 Set<SESEEffectsKey> strongUpdateSet;
15 Set<HeapRegionNode> hrnSet;
18 public LiveInNode(String id, TempDescriptor td, Set<HeapRegionNode> hrnSet,
19 Set<SESEEffectsKey> readEffectsSet,
20 Set<SESEEffectsKey> writeEffectsSet, Set<SESEEffectsKey> strongUpdateSet, Set<Set> reachabilitySet, int seseID) {
24 this.readEffectsSet = readEffectsSet;
25 this.writeEffectsSet = writeEffectsSet;
26 this.strongUpdateSet=strongUpdateSet;
27 this.reachabilitySet = reachabilitySet;
31 public Set<HeapRegionNode> getHRNSet() {
35 public Set<SESEEffectsKey> getReadEffectsSet() {
36 return readEffectsSet;
39 public Set<SESEEffectsKey> getWriteEffectsSet() {
40 return writeEffectsSet;
43 public Set<SESEEffectsKey> getStrongUpdateSet(){
44 return strongUpdateSet;
47 public void addReadEffectsSet(Set<SESEEffectsKey> newReadEffectsSet) {
48 if (newReadEffectsSet != null) {
49 readEffectsSet.addAll(newReadEffectsSet);
53 public void addWriteEffectsSet(Set<SESEEffectsKey> newWriteEffectsSet) {
54 if (newWriteEffectsSet != null) {
55 writeEffectsSet.addAll(newWriteEffectsSet);
59 public void addReachabilitySet(Set<Set> newReachabilitySet) {
60 if (newReachabilitySet != null) {
61 reachabilitySet.addAll(newReachabilitySet);
65 public boolean isWriteConflictWith(StallSiteNode stallNode) {
67 // if live-in var has write-effects on heap region node of stall site,
68 // it is write conflict
70 boolean result = false;
71 StallSite stallSite = stallNode.getStallSite();
73 if (writeEffectsSet != null) {
74 Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
75 while (writeIter.hasNext()) {
76 SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter
78 String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
79 String writeFieldName = seseEffectsKey.getFieldDescriptor();
81 HashSet<HeapRegionNode> stallSiteHRNSet = stallNode.getHRNSet();
82 for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
84 HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
85 if (stallHRN.getGloballyUniqueIdentifier().equals(
88 // check whether there are read or write effects of
91 HashSet<Effect> effectSet = stallSite.getEffectSet();
92 for (Iterator iterator2 = effectSet.iterator(); iterator2
94 Effect effect = (Effect) iterator2.next();
95 String stallEffectfieldName = effect.getField();
97 if (stallEffectfieldName.equals(writeFieldName)) {
98 result = result | true;
108 if (readEffectsSet != null) {
109 Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
110 while (readIter.hasNext()) {
112 SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
114 String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
115 String readFieldName = seseEffectsKey.getFieldDescriptor();
117 HashSet<HeapRegionNode> stallSiteHRNSet = stallNode.getHRNSet();
118 for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
120 HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
121 if (stallHRN.getGloballyUniqueIdentifier().equals(
124 HashSet<Effect> effectSet = stallSite.getEffectSet();
125 for (Iterator iterator2 = effectSet.iterator(); iterator2
127 Effect effect = (Effect) iterator2.next();
128 String stallEffectfieldName = effect.getField();
130 if (effect.getEffectType().equals(
131 StallSite.WRITE_EFFECT)) {
132 if (stallEffectfieldName.equals(readFieldName)) {
133 result = result | true;
149 public int getSESEIdentifier(){
153 public boolean equals(Object o) {
159 if (!(o instanceof LiveInNode)) {
163 LiveInNode in = (LiveInNode) o;
165 if (id.equals(in.id)) {
173 public String toString() {
174 String str = "LiveInNode " + id +" type="+type;