Options to print prettier graphs...
authorbdemsky <bdemsky>
Fri, 4 Feb 2005 20:15:39 +0000 (20:15 +0000)
committerbdemsky <bdemsky>
Fri, 4 Feb 2005 20:15:39 +0000 (20:15 +0000)
Repair/RepairCompiler/MCC/CLI.java
Repair/RepairCompiler/MCC/CRuntime/buildruntime
Repair/RepairCompiler/MCC/Compiler.java
Repair/RepairCompiler/MCC/IR/GraphNode.java
Repair/RepairCompiler/MCC/IR/Termination.java

index febfd744040537deb30a6f6c48d240b85989b389..7da685b666a37c0b92afc3af0c80d3ae1ba853f6 100755 (executable)
@@ -11,7 +11,7 @@ import MCC.IR.DebugItem;
  * files.
  *
  * @author  le01, 6.035 Staff (<tt>6.035-staff@mit.edu</tt>)
  * files.
  *
  * @author  le01, 6.035 Staff (<tt>6.035-staff@mit.edu</tt>)
- * @version <tt>$Id: CLI.java,v 1.12 2004/08/16 20:53:53 bdemsky Exp $</tt>
+ * @version <tt>$Id: CLI.java,v 1.13 2005/02/04 20:14:52 bdemsky Exp $</tt>
  */
 public class CLI {
     /**
  */
 public class CLI {
     /**
@@ -107,6 +107,7 @@ public class CLI {
            System.out.println("-prunequantifiernodes");
            System.out.println("-cplusplus");
            System.out.println("-time");
            System.out.println("-prunequantifiernodes");
            System.out.println("-cplusplus");
            System.out.println("-time");
+           System.out.println("-omitcomp");
            System.exit(-1);
        }
 
            System.exit(-1);
        }
 
@@ -116,6 +117,8 @@ public class CLI {
                 debug = true;
            } else if (args[i].equals("-checkonly")) {
                 Compiler.REPAIR=false;
                 debug = true;
            } else if (args[i].equals("-checkonly")) {
                 Compiler.REPAIR=false;
+           } else if (args[i].equals("-omitcomp")) {
+                Compiler.OMITCOMP=true;
            } else if (args[i].equals("-depth")) {
                Compiler.debuggraphs.add(new DebugItem(Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2])));
                i+=2;
            } else if (args[i].equals("-depth")) {
                Compiler.debuggraphs.add(new DebugItem(Integer.parseInt(args[i+1]),Integer.parseInt(args[i+2])));
                i+=2;
index 3f66d459b1994a321e143fea25a22f7e6b1e955a..ac3149bfb56cead42ac2f56ca895736708c57213 100755 (executable)
@@ -6,4 +6,4 @@ gcc $FLAG -c instrument.c
 gcc $FLAG -c libredblack/redblack.c
 gcc $FLAG -c stack.c
 gcc $FLAG -c size.c
 gcc $FLAG -c libredblack/redblack.c
 gcc $FLAG -c stack.c
 gcc $FLAG -c size.c
-gcc $FLAG -c cache_aux.c
+
index 41794e712df1590a9ee44e1976cbef7567612a4d..712079db96441cf4de04deb96976c2d7f43b46f7 100755 (executable)
@@ -25,6 +25,7 @@ public class Compiler {
     public static boolean GENERATEDEBUGPRINT=false;
     public static boolean GENERATEINSTRUMENT=false;
     public static boolean ALLOCATECPLUSPLUS=false;
     public static boolean GENERATEDEBUGPRINT=false;
     public static boolean GENERATEINSTRUMENT=false;
     public static boolean ALLOCATECPLUSPLUS=false;
+    public static boolean OMITCOMP=false;
     public static boolean TIME=false;
 
     public static Vector debuggraphs=new Vector();
     public static boolean TIME=false;
 
     public static Vector debuggraphs=new Vector();
index 8c5c119ae852ac88b875f5cef1491abca29c575f..424a8459852d4190620fecae79d20ff301e2bf92 100755 (executable)
@@ -72,6 +72,16 @@ public class GraphNode {
     NodeStatus status = UNVISITED;    
     String dotnodeparams = new String();
     Object owner = null;
     NodeStatus status = UNVISITED;    
     String dotnodeparams = new String();
     Object owner = null;
+    boolean merge=false;
+    String nodeoption="";
+
+    public void setOption(String option) {
+       this.nodeoption=option;
+    }
+
+    public void setMerge() {
+       merge=true;
+    }
 
     public GraphNode(String label) {
         this.nodelabel = label;
 
     public GraphNode(String label) {
         this.nodelabel = label;
@@ -263,23 +273,49 @@ public class GraphNode {
                 GraphNode gn = (GraphNode) i.next();
                 Iterator edges = gn.edges();
                 String label = gn.getTextLabel(); // + " [" + gn.discoverytime + "," + gn.finishingtime + "];";
                 GraphNode gn = (GraphNode) i.next();
                 Iterator edges = gn.edges();
                 String label = gn.getTextLabel(); // + " [" + gn.discoverytime + "," + gn.finishingtime + "];";
-               String option="";
-               if (cycleset.contains(gn))
-                   option=",style=bold";
+               String option=gn.nodeoption;
                if (special!=null&&special.contains(gn))
                    option+=",shape=box";
                if (special!=null&&special.contains(gn))
                    option+=",shape=box";
-                output.println("\t" + gn.getLabel() + " [label=\"" + label + "\"" + gn.dotnodeparams + option+"];");
+               if (!gn.merge)
+                   output.println("\t" + gn.getLabel() + " [label=\"" + label + "\"" + gn.dotnodeparams + option+"];");
 
 
+               if (!gn.merge)
                 while (edges.hasNext()) {
                     Edge edge = (Edge) edges.next();
                     GraphNode node = edge.getTarget();
                    if (nodes.contains(node)) {
                 while (edges.hasNext()) {
                     Edge edge = (Edge) edges.next();
                     GraphNode node = edge.getTarget();
                    if (nodes.contains(node)) {
-                       String edgelabel = useEdgeLabels ? "label=\"" + edge.getLabel() + "\"" : "label=\"\"";
-                       output.println("\t" + gn.getLabel() + " -> " + node.getLabel() + " [" + edgelabel + edge.dotnodeparams + "];");
+                       for(Iterator nodeit=nonmerge(node).iterator();nodeit.hasNext();) {
+                           GraphNode node2=(GraphNode)nodeit.next();
+                           String edgelabel = useEdgeLabels ? "label=\"" + edge.getLabel() + "\"" : "label=\"\"";
+                           output.println("\t" + gn.getLabel() + " -> " + node2.getLabel() + " [" + edgelabel + edge.dotnodeparams + "];");
+                       }
                    }
                 }
             }
         }
                    }
                 }
             }
         }
+
+       Set nonmerge(GraphNode gn) {
+           HashSet newset=new HashSet();
+           HashSet toprocess=new HashSet();
+           toprocess.add(gn);
+           while(!toprocess.isEmpty()) {
+               GraphNode gn2=(GraphNode)toprocess.iterator().next();
+               toprocess.remove(gn2);
+               if (!gn2.merge)
+                   newset.add(gn2);
+               else {
+                   Iterator edges = gn2.edges();
+                   while (edges.hasNext()) {
+                       Edge edge = (Edge) edges.next();
+                       GraphNode node = edge.getTarget();
+                       if (!newset.contains(node)&&nodes.contains(node))
+                           toprocess.add(node);
+                   }
+               }
+           }
+           return newset;
+       }
+
     }
 
     /** This function returns the set of nodes involved in cycles. 
     }
 
     /** This function returns the set of nodes involved in cycles. 
index 764453f239535d979d072aa28fea54d0c94d9060..5d25732106884d1a26f81fce5a483f974d3559be 100755 (executable)
@@ -31,6 +31,12 @@ public class Termination {
     ExactSize exactsize;
     ArrayAnalysis arrayanalysis;
     Sources sources;
     ExactSize exactsize;
     ArrayAnalysis arrayanalysis;
     Sources sources;
+    static String conjoption="style=bold";
+    static String absrepoption="shape=box,color=blue,style=bold";
+    static String updateoption="shape=box,color=red,style=bold";
+    static String scopeoption="color=brown";
+    static String conseqoption="style=bold,color=green";
+    static String compoption="shape=box,color=purple,style=bold";
 
     public Termination(State state) {
        this.state=state;
 
     public Termination(State state) {
        this.state=state;
@@ -74,7 +80,8 @@ public class Termination {
         debugmsg("Generating data structure nodes");
        generatedatastructureupdatenodes();
         debugmsg("Generating compensation nodes");
         debugmsg("Generating data structure nodes");
        generatedatastructureupdatenodes();
         debugmsg("Generating compensation nodes");
-       generatecompensationnodes();
+       if (!Compiler.OMITCOMP)
+           generatecompensationnodes();
         debugmsg("Generating abstract edges");
        generateabstractedges();
         debugmsg("Generating scope edges");
         debugmsg("Generating abstract edges");
        generateabstractedges();
         debugmsg("Generating scope edges");
@@ -170,6 +177,7 @@ public class Termination {
                GraphNode gn=new GraphNode("Conj"+i+"A"+j,
                                           "Conj ("+i+","+j+") "+dnf.get(j).name()
                                           ,tn);
                GraphNode gn=new GraphNode("Conj"+i+"A"+j,
                                           "Conj ("+i+","+j+") "+dnf.get(j).name()
                                           ,tn);
+               gn.setOption(conjoption);
                conjunctions.add(gn);
                if (!conjunctionmap.containsKey(c))
                    conjunctionmap.put(c,new HashSet());
                conjunctions.add(gn);
                if (!conjunctionmap.containsKey(c))
                    conjunctionmap.put(c,new HashSet());
@@ -190,6 +198,7 @@ public class Termination {
                    GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
                                               "Conj ("+i+","+j+") "+dconst.get(0).name()
                                               ,tn);
                    GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
                                               "Conj ("+i+","+j+") "+dconst.get(0).name()
                                               ,tn);
+                   gn.setOption(conjoption);
                    conjunctions.add(gn);
                    if (!conjunctionmap.containsKey(c))
                        conjunctionmap.put(c,new HashSet());
                    conjunctions.add(gn);
                    if (!conjunctionmap.containsKey(c))
                        conjunctionmap.put(c,new HashSet());
@@ -207,6 +216,7 @@ public class Termination {
                    GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
                                               "Conj ("+i+","+j+") "+dconst.get(0).name()
                                               ,tn);
                    GraphNode gn=new GraphNode("Conj"+i+"AQ"+j,
                                               "Conj ("+i+","+j+") "+dconst.get(0).name()
                                               ,tn);
+                   gn.setOption(conjoption);
                    conjunctions.add(gn);
                    if (!conjunctionmap.containsKey(c))
                        conjunctionmap.put(c,new HashSet());
                    conjunctions.add(gn);
                    if (!conjunctionmap.containsKey(c))
                        conjunctionmap.put(c,new HashSet());
@@ -335,9 +345,12 @@ public class Termination {
            ScopeNode satisfy=new ScopeNode(r,true);
            TermNode tnsatisfy=new TermNode(satisfy);
            GraphNode gnsatisfy=new GraphNode("SatisfyRule"+i,tnsatisfy);
            ScopeNode satisfy=new ScopeNode(r,true);
            TermNode tnsatisfy=new TermNode(satisfy);
            GraphNode gnsatisfy=new GraphNode("SatisfyRule"+i,tnsatisfy);
+           gnsatisfy.setOption(scopeoption);
+           gnsatisfy.setMerge();
            ConsequenceNode cnsatisfy=new ConsequenceNode();
            TermNode ctnsatisfy=new TermNode(cnsatisfy);
            GraphNode cgnsatisfy=new GraphNode("ConseqSatisfyRule"+i,ctnsatisfy);
            ConsequenceNode cnsatisfy=new ConsequenceNode();
            TermNode ctnsatisfy=new TermNode(cnsatisfy);
            GraphNode cgnsatisfy=new GraphNode("ConseqSatisfyRule"+i,ctnsatisfy);
+           cgnsatisfy.setOption(conseqoption);
            consequence.put(satisfy,cgnsatisfy);
            GraphNode.Edge esat=new GraphNode.Edge("consequencesatisfy"+i,cgnsatisfy);
            gnsatisfy.addEdge(esat);
            consequence.put(satisfy,cgnsatisfy);
            GraphNode.Edge esat=new GraphNode.Edge("consequencesatisfy"+i,cgnsatisfy);
            gnsatisfy.addEdge(esat);
@@ -348,9 +361,12 @@ public class Termination {
            ScopeNode falsify=new ScopeNode(r,false);
            TermNode tnfalsify=new TermNode(falsify);
            GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify);
            ScopeNode falsify=new ScopeNode(r,false);
            TermNode tnfalsify=new TermNode(falsify);
            GraphNode gnfalsify=new GraphNode("FalsifyRule"+i,tnfalsify);
+           gnfalsify.setOption(scopeoption);
+           gnfalsify.setMerge();
            ConsequenceNode cnfalsify=new ConsequenceNode();
            TermNode ctnfalsify=new TermNode(cnfalsify);
            GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify);
            ConsequenceNode cnfalsify=new ConsequenceNode();
            TermNode ctnfalsify=new TermNode(cnfalsify);
            GraphNode cgnfalsify=new GraphNode("ConseqFalsifyRule"+i,ctnfalsify);
+           cgnfalsify.setOption(conseqoption);
            consequence.put(falsify,cgnfalsify);
            GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify);
            gnfalsify.addEdge(efals);
            consequence.put(falsify,cgnfalsify);
            GraphNode.Edge efals=new GraphNode.Edge("consequencefalsify"+i,cgnfalsify);
            gnfalsify.addEdge(efals);
@@ -442,7 +458,9 @@ public class Termination {
                for(int j=0;j<array.length;j++) {
                    AbstractRepair ar=new AbstractRepair(dp,array[j],d,sources);
                    TermNode tn2=new TermNode(ar);
                for(int j=0;j<array.length;j++) {
                    AbstractRepair ar=new AbstractRepair(dp,array[j],d,sources);
                    TermNode tn2=new TermNode(ar);
-                   GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),gn.getTextLabel()+" #"+i+" "+ar.type(),tn2);
+                   //              GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),gn.getTextLabel()+" #"+i+" "+ar.type(),tn2);
+                   GraphNode gn2=new GraphNode(gn.getLabel()+"A"+i+"B"+ar.type(),dp.name()+" "+ar.type(),tn2);
+                   gn2.setOption(absrepoption);
                    GraphNode.Edge e=new GraphNode.Edge("abstract",gn2);
                    gn.addEdge(e);
                    if (!predtoabstractmap.containsKey(dp))
                    GraphNode.Edge e=new GraphNode.Edge("abstract",gn2);
                    gn.addEdge(e);
                    if (!predtoabstractmap.containsKey(dp))
@@ -463,6 +481,7 @@ public class Termination {
            AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTOSET, sd,sources);
            TermNode tn=new TermNode(ar);
            GraphNode gn=new GraphNode("AbstractAddSetRule"+i,tn);
            AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTOSET, sd,sources);
            TermNode tn=new TermNode(ar);
            GraphNode gn=new GraphNode("AbstractAddSetRule"+i,tn);
+           gn.setOption(absrepoption);
            if (!predtoabstractmap.containsKey(tp))
                predtoabstractmap.put(tp,new HashSet());
            ((Set)predtoabstractmap.get(tp)).add(gn);
            if (!predtoabstractmap.containsKey(tp))
                predtoabstractmap.put(tp,new HashSet());
            ((Set)predtoabstractmap.get(tp)).add(gn);
@@ -474,6 +493,7 @@ public class Termination {
            AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMSET, sd,sources);
            TermNode tn2=new TermNode(ar2);
            GraphNode gn2=new GraphNode("AbstractRemSetRule"+i,tn2);
            AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMSET, sd,sources);
            TermNode tn2=new TermNode(ar2);
            GraphNode gn2=new GraphNode("AbstractRemSetRule"+i,tn2);
+           gn2.setOption(absrepoption);
            if (!predtoabstractmap.containsKey(tp2))
                predtoabstractmap.put(tp2,new HashSet());
            ((Set)predtoabstractmap.get(tp2)).add(gn2);
            if (!predtoabstractmap.containsKey(tp2))
                predtoabstractmap.put(tp2,new HashSet());
            ((Set)predtoabstractmap.get(tp2)).add(gn2);
@@ -494,6 +514,7 @@ public class Termination {
            AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTORELATION, rd,sources);
            TermNode tn=new TermNode(ar);
            GraphNode gn=new GraphNode("AbstractAddRelRule"+i,tn);
            AbstractRepair ar=new AbstractRepair(tp, AbstractRepair.ADDTORELATION, rd,sources);
            TermNode tn=new TermNode(ar);
            GraphNode gn=new GraphNode("AbstractAddRelRule"+i,tn);
+           gn.setOption(absrepoption);
            if (!predtoabstractmap.containsKey(tp))
                predtoabstractmap.put(tp,new HashSet());
            ((Set)predtoabstractmap.get(tp)).add(gn);
            if (!predtoabstractmap.containsKey(tp))
                predtoabstractmap.put(tp,new HashSet());
            ((Set)predtoabstractmap.get(tp)).add(gn);
@@ -505,6 +526,7 @@ public class Termination {
            AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMRELATION, rd,sources);
            TermNode tn2=new TermNode(ar2);
            GraphNode gn2=new GraphNode("AbstractRemRelRule"+i,tn2);
            AbstractRepair ar2=new AbstractRepair(tp2, AbstractRepair.REMOVEFROMRELATION, rd,sources);
            TermNode tn2=new TermNode(ar2);
            GraphNode gn2=new GraphNode("AbstractRemRelRule"+i,tn2);
+           gn2.setOption(absrepoption);
            if (!predtoabstractmap.containsKey(tp2))
                predtoabstractmap.put(tp2,new HashSet());
            ((Set)predtoabstractmap.get(tp2)).add(gn2);
            if (!predtoabstractmap.containsKey(tp2))
                predtoabstractmap.put(tp2,new HashSet());
            ((Set)predtoabstractmap.get(tp2)).add(gn2);
@@ -527,6 +549,7 @@ public class Termination {
                MultUpdateNode mun=new MultUpdateNode(sn);
                TermNode tn2=new TermNode(mun);
                GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
                MultUpdateNode mun=new MultUpdateNode(sn);
                TermNode tn2=new TermNode(mun);
                GraphNode gn2=new GraphNode("CompRem"+compensationcount,tn2);
+               gn2.setOption(compoption);
                UpdateNode un=new UpdateNode(r);
 
                if (j<r.numQuantifiers()) {
                UpdateNode un=new UpdateNode(r);
 
                if (j<r.numQuantifiers()) {
@@ -632,6 +655,7 @@ public class Termination {
            MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.REMOVE);
            TermNode tn=new TermNode(mun);
            GraphNode gn2=new GraphNode("UpdateRem"+removefromcount,tn);
            MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.REMOVE);
            TermNode tn=new TermNode(mun);
            GraphNode gn2=new GraphNode("UpdateRem"+removefromcount,tn);
+           gn2.setOption(updateoption);
 
            boolean goodflag=true;
            for(int i=0;i<possiblerules.size();i++) {
 
            boolean goodflag=true;
            for(int i=0;i<possiblerules.size();i++) {
@@ -747,6 +771,7 @@ public class Termination {
            MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.MODIFY);
            TermNode tn=new TermNode(mun);
            GraphNode gn2=new GraphNode("UpdateMod"+modifycount,tn);
            MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.MODIFY);
            TermNode tn=new TermNode(mun);
            GraphNode gn2=new GraphNode("UpdateMod"+modifycount,tn);
+           gn2.setOption(updateoption);
 
            boolean goodflag=true;
            for(int i=0;i<possiblerules.size();i++) {
 
            boolean goodflag=true;
            for(int i=0;i<possiblerules.size();i++) {
@@ -975,6 +1000,7 @@ public class Termination {
                    MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
                    TermNode tn=new TermNode(mun);
                    GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
                    MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
                    TermNode tn=new TermNode(mun);
                    GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
+                   gn2.setOption(updateoption);
 
                    if (debugmsg("Start processing quantifiers")&&
                        processquantifiers(gn2,un, r,setmapping)&&
 
                    if (debugmsg("Start processing quantifiers")&&
                        processquantifiers(gn2,un, r,setmapping)&&