From: bdemsky Date: Fri, 12 Jun 2009 00:41:05 +0000 (+0000) Subject: bug fix for comparisons X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=25edbd5b0aec9bc32daf2f832a203e704103c009;p=IRC.git bug fix for comparisons --- diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index 1a0b2a88..928733c4 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -20,6 +20,8 @@ public class DiscoverConflicts { Hashtable> treadmap; Hashtable> transreadmap; Hashtable> srcmap; + Hashtable> leftsrcmap; + Hashtable> rightsrcmap; TypeAnalysis typeanalysis; public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis) { @@ -31,6 +33,8 @@ public class DiscoverConflicts { transreadmap=new Hashtable>(); treadmap=new Hashtable>(); srcmap=new Hashtable>(); + leftsrcmap=new Hashtable>(); + rightsrcmap=new Hashtable>(); } public void doAnalysis() { @@ -94,6 +98,14 @@ public class DiscoverConflicts { return srcmap.get(lb).contains(fn); } + public boolean getNeedLeftSrcTrans(LocalityBinding lb, FlatNode fn) { + return leftsrcmap.get(lb).contains(fn); + } + + public boolean getNeedRightSrcTrans(LocalityBinding lb, FlatNode fn) { + return rightsrcmap.get(lb).contains(fn); + } + public boolean getNeedTrans(LocalityBinding lb, FlatNode fn) { return treadmap.get(lb).contains(fn); } @@ -104,8 +116,12 @@ public class DiscoverConflicts { Hashtable>> fnmap=computeTempSets(lb); HashSet tfset=computeTranslationSet(lb, fm, fnmap); HashSet srctrans=new HashSet(); + HashSet leftsrctrans=new HashSet(); + HashSet rightsrctrans=new HashSet(); transreadmap.put(lb, tfset); srcmap.put(lb,srctrans); + leftsrcmap.put(lb,leftsrctrans); + rightsrcmap.put(lb,rightsrctrans); //compute writes that need translation on source @@ -115,6 +131,37 @@ public class DiscoverConflicts { if (atomictable.get(fn).intValue()>0) { Hashtable> tmap=fnmap.get(fn); switch(fn.kind()) { + case FKind.FlatOpNode: { + FlatOpNode fon=(FlatOpNode)fn; + if (fon.getOp().getOp()==Operation.EQUAL|| + fon.getOp().getOp()==Operation.NOTEQUAL) { + if (!fon.getLeft().getType().isPtr()) + break; + Set lefttfpset=tmap.get(fon.getLeft()); + Set righttfpset=tmap.get(fon.getRight()); + //handle left operand + if (lefttfpset!=null) { + for(Iterator tfpit=lefttfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (tfset.contains(tfp)||ok(tfp)) { + leftsrctrans.add(fon); + break; + } + } + } + //handle right operand + if (righttfpset!=null) { + for(Iterator tfpit=righttfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (tfset.contains(tfp)||ok(tfp)) { + rightsrctrans.add(fon); + break; + } + } + } + } + break; + } case FKind.FlatSetFieldNode: { //definitely need to translate these FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index d765ecaa..10845a51 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -439,6 +439,7 @@ public class BuildCode { outmethod.println("invokeSESEargs* tempSESEargs;"); } + //Store the sizes of classes & array elements generateSizeArray(outmethod); @@ -876,21 +877,12 @@ public class BuildCode { outclassdefs.print("#endif\n"); outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n"); - outclassdefs.print("int classsize[]={"); Iterator it=state.getClassSymbolTable().getDescriptorsIterator(); cdarray=new ClassDescriptor[state.numClasses()]; while(it.hasNext()) { ClassDescriptor cd=(ClassDescriptor)it.next(); cdarray[cd.getId()]=cd; } - boolean needcomma=false; - for(int i=0; i>"+generateTemp(fm,fon.getRight(),lb)+";"); + } else if (dc!=null) { + output.print(generateTemp(fm, fon.getDest(),lb)+" = "); + if (dc.getNeedLeftSrcTrans(lb, fon)) + output.print("("+generateTemp(fm, fon.getLeft(),lb)+"!=NULL?"+generateTemp(fm, fon.getLeft(),lb)+"->"+oidstr+":NULL)"); + else + output.print(generateTemp(fm, fon.getLeft(),lb)); + output.print(fon.getOp().toString()); + if (dc.getNeedRightSrcTrans(lb, fon)) + output.println("("+generateTemp(fm, fon.getRight(),lb)+"!=NULL?"+generateTemp(fm, fon.getRight(),lb)+"->"+oidstr+":NULL);"); + else + output.println(generateTemp(fm,fon.getRight(),lb)+";"); } else output.println(generateTemp(fm, fon.getDest(),lb)+" = "+generateTemp(fm, fon.getLeft(),lb)+fon.getOp().toString()+generateTemp(fm,fon.getRight(),lb)+";"); } else if (fon.getOp().getOp()==Operation.ASSIGN)