improved debug graph capture
[IRC.git] / Robust / src / IR / State.java
1 package IR;
2 import IR.Tree.*;
3 import IR.Flat.*;
4 import IR.*;
5 import java.util.*;
6 import Analysis.TaskStateAnalysis.*;
7
8 public class State {
9
10     public int lines;
11   public State() {
12     this.classes=new SymbolTable();
13     this.tasks=new SymbolTable();
14     this.treemethodmap=new Hashtable();
15     this.flatmethodmap=new Hashtable();
16     this.parsetrees=new HashSet();
17     this.arraytypes=new HashSet();
18     this.arraytonumber=new Hashtable();
19     this.tagmap=new Hashtable();
20     this.selfloops=new HashSet();
21     this.excprefetch=new HashSet();
22     this.classpath=new Vector();
23     this.lines=0;
24   }
25
26   public void addParseNode(ParseNode parsetree) {
27     parsetrees.add(parsetree);
28   }
29
30   public void storeAnalysisResult(Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults) {
31     this.analysisresults=analysisresults;
32   }
33
34   public Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> getAnalysisResult() {
35     return analysisresults;
36   }
37
38
39   public void storeOptionalTaskDescriptors(Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors) {
40     this.optionaltaskdescriptors=optionaltaskdescriptors;
41   }
42
43   public Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> getOptionalTaskDescriptors() {
44     return optionaltaskdescriptors;
45   }
46
47
48   /** Boolean flag which indicates whether compiler is compiling a task-based
49    * program. */
50   public boolean WEBINTERFACE=false;
51   public boolean MINIMIZE=false;
52   public boolean TASK=false;
53   public boolean FASTCHECK=false;
54   public boolean PREFETCH=false;
55   public boolean TASKSTATE=false;
56   public boolean TAGSTATE=false;
57   public boolean FLATIRGRAPH=false;
58   public boolean FLATIRGRAPHTASKS=false;
59   public boolean FLATIRGRAPHUSERMETHODS=false;
60   public boolean FLATIRGRAPHLIBMETHODS=false;
61   public boolean MULTICORE=false;
62   public boolean MULTICOREGC=false;
63   public boolean OWNERSHIP=false;
64   public int OWNERSHIPALLOCDEPTH=3;
65   public boolean OWNERSHIPWRITEDOTS=false;
66   public boolean OWNERSHIPWRITEALL=false;
67   public String OWNERSHIPALIASFILE=null;
68   public boolean OWNERSHIPALIASTAB=false;
69   public int OWNERSHIPDEBUGCALLCOUNT=0;
70   public String OWNERSHIPDEBUGCALLEE=null;
71   public String OWNERSHIPDEBUGCALLER=null;
72   
73   public boolean DISJOINT=false;
74   public int DISJOINTALLOCDEPTH=3;
75   public boolean DISJOINTWRITEDOTS=false;
76   public boolean DISJOINTWRITEALL=false;
77   public boolean DISJOINTWRITEIHMS=false;
78   public String DISJOINTALIASFILE=null;
79   public boolean DISJOINTALIASTAB=false;
80   public int DISJOINTDEBUGCALLCOUNT=0;
81   public String DISJOINTDEBUGCALLEE=null;
82   public String DISJOINTDEBUGCALLER=null;
83   public String DISJOINTSNAPSYMBOL=null;
84   public int DISJOINTSNAPVISITTOSTART=0;
85   public int DISJOINTSNAPNUMVISITS=0;
86   public boolean DISJOINTSNAPSTOPAFTER=false;
87
88   public boolean OPTIONAL=false;
89   public boolean ARRAYBOUNDARYCHECK=true;
90   public boolean RAW=false;
91   public boolean ARRAYPAD=false;
92   public boolean SCHEDULING=false;
93   public boolean USEPROFILE=false;
94   public String profilename = null;
95   public boolean THREAD=false;
96   public boolean CONSCHECK=false;
97   public boolean INSTRUCTIONFAILURE=false;
98   public boolean MLP=false;
99   public boolean MLPDEBUG=false;
100   public int MLP_NUMCORES=0;
101   public int MLP_MAXSESEAGE=0;
102   public boolean METHODEFFECTS=false;
103   public static double TRUEPROB=0.8;
104   public static boolean PRINTFLAT=false;
105   public static boolean PRINTSCHEDULING=false;
106   public static boolean PRINTSCHEDULESIM=false;
107   public static boolean PRINTCRITICALPATH=false;
108   //DSM options
109   public boolean DSM=false;
110   public boolean DSMTASK=false;
111   public static boolean ABORTREADERS=false;
112
113   // Recovery Stats Options
114   public boolean DSMRECOVERYSTATS=false;
115   //STM options
116   public boolean EVENTMONITOR=false;
117   public static boolean STMARRAY=false;
118   public static boolean SINGLETM=false;
119   public static boolean READSET=false;
120   public boolean SANDBOX=false;
121   public boolean DCOPTS=false;
122   public boolean DELAYCOMP=false;
123   public boolean DUALVIEW=false;
124   public boolean HYBRID=false;
125   //Other options
126   public int CORENUM = 1;
127   public int CORENUM4GC = 0;
128   public String structfile;
129   public String main;
130   public String outputdir = "/scratch/";
131   public boolean INLINEATOMIC=false;
132   public int inlineatomicdepth;
133   public HashSet selfloops;
134   public HashSet excprefetch;
135   public Vector classpath;
136   public SymbolTable classes;
137   public SymbolTable tasks;
138   public Set parsetrees;
139   public Hashtable treemethodmap;
140   public Hashtable flatmethodmap;
141   private HashSet arraytypes;
142   public Hashtable arraytonumber;
143   private int numclasses=1; // start from 1 instead of 0 for multicore gc
144   private int numtasks=0;
145   private int arraycount=0;
146   public boolean OPTIMIZE=false;
147
148   private Hashtable<ClassDescriptor, Hashtable<OptionalTaskDescriptor, OptionalTaskDescriptor>> optionaltaskdescriptors;
149   private Hashtable<ClassDescriptor, Hashtable<FlagState, Set<OptionalTaskDescriptor>>> analysisresults;
150
151   private Hashtable tagmap;
152   private int numtags=0;
153
154   public void addArrayType(TypeDescriptor td) {
155     if (!arraytypes.contains(td)) {
156       arraytypes.add(td);
157       arraytonumber.put(td,new Integer(arraycount++));
158     }
159   }
160
161   public Iterator getArrayIterator() {
162     return arraytypes.iterator();
163   }
164
165   public int getTagId(TagDescriptor tag) {
166     if (tagmap.containsKey(tag)) {
167       return ((Integer) tagmap.get(tag)).intValue();
168     } else {
169       tagmap.put(tag, new Integer(numtags));
170       return numtags++;
171     }
172   }
173
174   public int getArrayNumber(TypeDescriptor td) {
175     if (arraytonumber.containsKey(td))
176       return ((Integer)arraytonumber.get(td)).intValue();
177     else return -1;
178   }
179
180   public int numArrays() {
181     return arraytypes.size();
182   }
183
184   public static TypeDescriptor getTypeDescriptor(int t) {
185     TypeDescriptor td=new TypeDescriptor(t);
186     return td;
187   }
188
189   public static TypeDescriptor getTypeDescriptor(NameDescriptor n) {
190     TypeDescriptor td=new TypeDescriptor(n);
191     return td;
192   }
193
194   public void addClass(ClassDescriptor tdn) {
195     if (classes.contains(tdn.getSymbol()))
196       throw new Error("Class "+tdn.getSymbol()+" defined twice");
197     classes.add(tdn);
198     numclasses++;
199   }
200
201   public int numClasses() {
202     return numclasses;
203   }
204
205   public BlockNode getMethodBody(MethodDescriptor md) {
206     return (BlockNode)treemethodmap.get(md);
207   }
208
209   public BlockNode getMethodBody(TaskDescriptor td) {
210     return (BlockNode)treemethodmap.get(td);
211   }
212
213   public SymbolTable getClassSymbolTable() {
214     return classes;
215   }
216
217   public SymbolTable getTaskSymbolTable() {
218     return tasks;
219   }
220
221   /** Returns Flat IR representation of MethodDescriptor md. */
222
223   public FlatMethod getMethodFlat(MethodDescriptor md) {
224     return (FlatMethod)flatmethodmap.get(md);
225   }
226
227   /** Returns Flat IR representation of TaskDescriptor td. */
228
229   public FlatMethod getMethodFlat(TaskDescriptor td) {
230     return (FlatMethod)flatmethodmap.get(td);
231   }
232
233   // The descriptor is either a method or task desc
234   // and should call one of the above methods
235   public FlatMethod getMethodFlat(Descriptor d) {
236     FlatMethod fm;
237     if( d instanceof MethodDescriptor ) {
238       fm = getMethodFlat( (MethodDescriptor) d);
239     } else {
240       assert d instanceof TaskDescriptor;
241       fm = getMethodFlat( (TaskDescriptor) d);
242     }
243     return fm;
244   }
245
246   public void addTreeCode(MethodDescriptor md, BlockNode bn) {
247     treemethodmap.put(md,bn);
248   }
249
250   public void addTreeCode(TaskDescriptor td, BlockNode bn) {
251     treemethodmap.put(td,bn);
252   }
253
254   public void addFlatCode(MethodDescriptor md, FlatMethod bn) {
255     flatmethodmap.put(md,bn);
256   }
257
258   public void addFlatCode(TaskDescriptor td, FlatMethod bn) {
259     flatmethodmap.put(td,bn);
260   }
261
262   public void addTask(TaskDescriptor td) {
263     if (tasks.contains(td.getSymbol()))
264       throw new Error("Task "+td.getSymbol()+" defined twice");
265     tasks.add(td);
266     numtasks++;
267   }
268 }