3 import java.io.FileOutputStream;
4 import java.io.PrintStream;
6 import java.io.BufferedReader;
7 import java.io.FileReader;
8 import java.io.FileInputStream;
9 import java.util.Iterator;
11 import java.util.Vector;
13 import IR.Tree.ParseNode;
14 import IR.Tree.BuildIR;
15 import IR.Tree.SemanticCheck;
16 import IR.Flat.BuildCodeMultiCore;
17 import IR.Flat.BuildFlat;
18 import IR.Flat.BuildCode;
19 import IR.ClassDescriptor;
21 import IR.TaskDescriptor;
23 import Analysis.Scheduling.Schedule;
24 import Analysis.Scheduling.ScheduleAnalysis;
25 import Analysis.Scheduling.ScheduleSimulator;
26 import Analysis.TaskStateAnalysis.TaskAnalysis;
27 import Analysis.TaskStateAnalysis.TaskTagAnalysis;
28 import Analysis.TaskStateAnalysis.TaskGraph;
29 import Analysis.CallGraph.CallGraph;
30 import Analysis.TaskStateAnalysis.FEdge;
31 import Analysis.TaskStateAnalysis.FlagState;
32 import Analysis.TaskStateAnalysis.TagAnalysis;
33 import Analysis.TaskStateAnalysis.GarbageAnalysis;
34 import Analysis.TaskStateAnalysis.ExecutionGraph;
35 import Analysis.TaskStateAnalysis.SafetyAnalysis;
36 import Analysis.Locality.LocalityAnalysis;
37 import Analysis.Locality.GenerateConversions;
38 import Analysis.Prefetch.PrefetchAnalysis;
39 import Analysis.FlatIRGraph.FlatIRGraph;
40 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
42 import Util.GraphNode;
43 import Util.GraphNode.DFS;
44 import Util.GraphNode.SCC;
48 /** Main method for the compiler. */
50 public static void main(String args[]) throws Exception {
51 String ClassLibraryPrefix="./ClassLibrary/";
52 State state=new State();
54 for(int i=0; i<args.length; i++) {
55 String option=args[i];
56 if (option.equals("-precise"))
57 IR.Flat.BuildCode.GENERATEPRECISEGC=true;
58 else if (option.equals("-prefetch"))
60 else if (option.equals("-dir"))
61 IR.Flat.BuildCode.PREFIX=args[++i]+"/";
62 else if (option.equals("-selfloop"))
63 state.selfloops.add(args[++i]);
64 else if (option.equals("-excprefetch"))
65 state.excprefetch.add(args[++i]);
66 else if (option.equals("-classlibrary"))
67 ClassLibraryPrefix=args[++i]+"/";
68 else if(option.equals("-numcore")) {
70 state.CORENUM = Integer.parseInt(args[i]);
71 } else if (option.equals("-mainclass"))
73 else if (option.equals("-trueprob")) {
74 state.TRUEPROB=Double.parseDouble(args[++i]);
75 } else if (option.equals("-printflat"))
77 else if (option.equals("-struct"))
78 state.structfile=args[++i];
79 else if (option.equals("-conscheck"))
81 else if (option.equals("-task"))
83 else if (option.equals("-taskstate"))
85 else if (option.equals("-tagstate"))
87 else if (option.equals("-flatirtasks")) {
88 state.FLATIRGRAPH=true;
89 state.FLATIRGRAPHTASKS=true;
90 } else if (option.equals("-flatirusermethods")) {
91 state.FLATIRGRAPH=true;
92 state.FLATIRGRAPHUSERMETHODS=true;
93 } else if (option.equals("-flatirlibmethods")) {
94 state.FLATIRGRAPH=true;
95 state.FLATIRGRAPHLIBMETHODS=true;
96 } else if (option.equals("-multicore"))
98 else if (option.equals("-ownership"))
100 else if (option.equals("-ownallocdepth")) {
101 state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
102 } else if (option.equals("-ownwritedots")) {
103 state.OWNERSHIPWRITEDOTS=true;
104 if (args[++i].equals("all")) {
105 state.OWNERSHIPWRITEALL=true;
107 } else if (option.equals("-ownaliasfile"))
108 state.OWNERSHIPALIASFILE=args[++i];
109 else if (option.equals("-optional"))
111 else if (option.equals("-raw"))
113 else if (option.equals("-scheduling"))
114 state.SCHEDULING=true;
115 else if (option.equals("-useprofile"))
116 state.USEPROFILE=true;
117 else if (option.equals("-thread"))
119 else if (option.equals("-dsm"))
121 else if (option.equals("-webinterface"))
122 state.WEBINTERFACE=true;
123 else if (option.equals("-instructionfailures"))
124 state.INSTRUCTIONFAILURE=true;
125 else if (option.equals("-help")) {
126 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
127 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
128 System.out.println("-dir outputdirectory -- output code in outputdirectory");
129 System.out.println("-struct structfile -- output structure declarations for repair tool");
130 System.out.println("-mainclass -- main function to call");
131 System.out.println("-dsm -- distributed shared memory support");
132 System.out.println("-precise -- use precise garbage collection");
133 System.out.println("-conscheck -- turn on consistency checking");
134 System.out.println("-task -- compiler for tasks");
135 System.out.println("-thread -- threads");
136 System.out.println("-trueprob <d> -- probability of true branch");
137 System.out.println("-printflat -- print out flat representation");
138 System.out.println("-instructionfailures -- insert code for instruction level failures");
139 System.out.println("-taskstate -- do task state analysis");
140 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
141 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
142 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
143 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
144 System.out.println("-ownership -- do ownership analysis");
145 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
146 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
147 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
148 System.out.println("-optional -- enable optional arguments");
149 System.out.println("-webinterface -- enable web interface");
150 System.out.println("-help -- print out help");
153 readSourceFile(state, args[i]);
158 readSourceFile(state, ClassLibraryPrefix+"System.java");
159 readSourceFile(state, ClassLibraryPrefix+"String.java");
160 readSourceFile(state, ClassLibraryPrefix+"HashSet.java");
161 readSourceFile(state, ClassLibraryPrefix+"HashMap.java");
162 readSourceFile(state, ClassLibraryPrefix+"HashMapIterator.java");
163 readSourceFile(state, ClassLibraryPrefix+"HashEntry.java");
164 readSourceFile(state, ClassLibraryPrefix+"Integer.java");
165 readSourceFile(state, ClassLibraryPrefix+"StringBuffer.java");
167 readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java");
168 readSourceFile(state, ClassLibraryPrefix+"InputStream.java");
169 readSourceFile(state, ClassLibraryPrefix+"OutputStream.java");
170 readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
171 readSourceFile(state, ClassLibraryPrefix+"File.java");
172 readSourceFile(state, ClassLibraryPrefix+"InetAddress.java");
173 readSourceFile(state, ClassLibraryPrefix+"SocketInputStream.java");
174 readSourceFile(state, ClassLibraryPrefix+"SocketOutputStream.java");
176 readSourceFile(state, ClassLibraryPrefix+"Math.java");
177 readSourceFile(state, ClassLibraryPrefix+"gnu/Random.java");
178 readSourceFile(state, ClassLibraryPrefix+"Vector.java");
179 readSourceFile(state, ClassLibraryPrefix+"Enumeration.java");
180 readSourceFile(state, ClassLibraryPrefix+"Dictionary.java");
181 readSourceFile(state, ClassLibraryPrefix+"Writer.java");
182 readSourceFile(state, ClassLibraryPrefix+"BufferedWriter.java");
183 readSourceFile(state, ClassLibraryPrefix+"OutputStreamWriter.java");
184 readSourceFile(state, ClassLibraryPrefix+"FileWriter.java");
185 readSourceFile(state, ClassLibraryPrefix+"Date.java");
188 readSourceFile(state, ClassLibraryPrefix+"Object.java");
189 readSourceFile(state, ClassLibraryPrefix+"TagDescriptor.java");
190 } else if (state.DSM) {
191 readSourceFile(state, ClassLibraryPrefix+"ThreadDSM.java");
192 readSourceFile(state, ClassLibraryPrefix+"ObjectJavaDSM.java");
193 readSourceFile(state, ClassLibraryPrefix+"Barrier.java");
196 readSourceFile(state, ClassLibraryPrefix+"Thread.java");
197 readSourceFile(state, ClassLibraryPrefix+"ObjectJava.java");
199 readSourceFile(state, ClassLibraryPrefix+"ObjectJavaNT.java");
203 readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
204 readSourceFile(state, ClassLibraryPrefix+"Socket.java");
205 readSourceFile(state, ClassLibraryPrefix+"ServerSocket.java");
207 readSourceFile(state, ClassLibraryPrefix+"SocketJava.java");
208 readSourceFile(state, ClassLibraryPrefix+"ServerSocketJava.java");
211 BuildIR bir=new BuildIR(state);
214 TypeUtil tu=new TypeUtil(state);
216 SemanticCheck sc=new SemanticCheck(state,tu);
218 tu.createFullTable();
220 BuildFlat bf=new BuildFlat(state,tu);
222 SafetyAnalysis sa=null;
223 PrefetchAnalysis pa=null;
225 if (state.TAGSTATE) {
226 CallGraph callgraph=new CallGraph(state);
227 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
228 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis);
231 if (state.TASKSTATE) {
232 CallGraph callgraph=new CallGraph(state);
233 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
234 TaskAnalysis ta=new TaskAnalysis(state, taganalysis);
236 TaskGraph tg=new TaskGraph(state, ta);
239 if (state.OPTIONAL) {
240 ExecutionGraph et=new ExecutionGraph(state, ta);
241 et.createExecutionGraph();
242 sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
244 state.storeAnalysisResult(sa.getResult());
245 state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
248 if (state.WEBINTERFACE) {
249 GarbageAnalysis ga=new GarbageAnalysis(state, ta);
250 WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
251 JhttpServer serve=new JhttpServer(8000,wi);
255 if (state.SCHEDULING) {
256 // Indentify backedges
257 for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) {
258 ClassDescriptor cd=(ClassDescriptor) it_classes.next();
260 Set<FlagState> fss = ta.getFlagStates(cd);
261 SCC scc=GraphNode.DFS.computeSCC(fss);
262 if (scc.hasCycles()) {
263 for(int i=0; i<scc.numSCC(); i++) {
264 if (scc.hasCycle(i)) {
265 Set cycleset = scc.getSCC(i);
266 Iterator it_fs = cycleset.iterator();
267 while(it_fs.hasNext()) {
268 FlagState fs = (FlagState)it_fs.next();
269 Iterator it_edges = fs.edges();
270 while(it_edges.hasNext()) {
271 FEdge edge = (FEdge)it_edges.next();
272 if(cycleset.contains(edge.getTarget())) {
274 edge.setisbackedge(true);
284 // set up profiling data
285 if(state.USEPROFILE) {
286 // read in profile data and set
287 FileInputStream inStream = new FileInputStream("/scratch/profile.rst");
288 byte[] b = new byte[1024 * 100];
289 int length = inStream.read(b);
291 System.out.print("No content in input file: /scratch/profile.rst\n");
294 String profiledata = new String(b, 0, length);
295 java.util.Hashtable<String, Integer> taskinfo = new java.util.Hashtable<String, Integer>();
297 int inindex = profiledata.indexOf('\n');
298 while((inindex != -1) ) {
299 String inline = profiledata.substring(0, inindex);
300 profiledata = profiledata.substring(inindex + 1);
301 //System.printString(inline + "\n");
302 int tmpinindex = inline.indexOf(',');
303 if(tmpinindex == -1) {
306 String inname = inline.substring(0, tmpinindex);
307 String inint = inline.substring(tmpinindex + 1);
308 while(inint.startsWith(" ")) {
309 inint = inint.substring(1);
311 int duration = Integer.parseInt(inint);
312 taskinfo.put(inname, duration);
313 inindex = profiledata.indexOf('\n');
316 java.util.Random r=new java.util.Random();
318 for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) {
319 ClassDescriptor cd=(ClassDescriptor) it_classes.next();
321 Vector rootnodes=ta.getRootNodes(cd);
322 if(rootnodes!=null) {
323 for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();) {
324 FlagState root=(FlagState)it_rootnodes.next();
325 Vector allocatingTasks = root.getAllocatingTasks();
326 if(allocatingTasks != null) {
327 for(int k = 0; k < allocatingTasks.size(); k++) {
328 TaskDescriptor td = (TaskDescriptor)allocatingTasks.elementAt(k);
329 Vector<FEdge> fev = (Vector<FEdge>)ta.getFEdgesFromTD(td);
330 int numEdges = fev.size();
332 for(int j = 0; j < numEdges; j++) {
333 FEdge pfe = fev.elementAt(j);
334 if(numEdges - j == 1) {
335 pfe.setProbability(total);
337 if((total != 0) && (total != 1)) {
339 tint = r.nextInt()%total;
342 pfe.setProbability(tint);
346 // tint = r.nextInt()%10;
347 // } while(tint <= 0);
348 //int newRate = tint;
349 //int newRate = (j+1)%2+1;
351 String cdname = cd.getSymbol();
352 if((cdname.equals("SeriesRunner")) ||
353 (cdname.equals("MDRunner")) ||
354 (cdname.equals("Stage")) ||
355 (cdname.equals("AppDemoRunner")) ||
356 (cdname.equals("FilterBankAtom"))) {
358 } else if(cdname.equals("SentenceParser")) {
362 // tint = r.nextInt()%100;
363 // } while(tint <= 0);
364 // int probability = tint;
365 int probability = 100;
366 pfe.addNewObjInfo(cd, newRate, probability);
372 Iterator it_flags = ta.getFlagStates(cd).iterator();
373 while(it_flags.hasNext()) {
374 FlagState fs = (FlagState)it_flags.next();
375 Iterator it_edges = fs.edges();
377 while(it_edges.hasNext()) {
379 // tint = r.nextInt()%10;
380 // } while(tint <= 0);
381 FEdge edge = (FEdge)it_edges.next();
382 tint = taskinfo.get(edge.getTask().getSymbol()).intValue();
383 edge.setExeTime(tint);
384 if((fs.getClassDescriptor().getSymbol().equals("MD")) && (edge.getTask().getSymbol().equals("t6"))) {
385 if(edge.isbackedge()) {
386 if(edge.getTarget().equals(edge.getSource())) {
387 edge.setProbability(93.75);
389 edge.setProbability(3.125);
392 edge.setProbability(3.125);
396 if(!it_edges.hasNext()) {
397 edge.setProbability(total);
399 if((total != 0) && (total != 1)) {
401 tint = r.nextInt()%total;
404 edge.setProbability(tint);
413 // Randomly set the newRate and probability of FEdges
414 java.util.Random r=new java.util.Random();
416 for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) {
417 ClassDescriptor cd=(ClassDescriptor) it_classes.next();
419 Vector rootnodes=ta.getRootNodes(cd);
420 if(rootnodes!=null) {
421 for(Iterator it_rootnodes=rootnodes.iterator(); it_rootnodes.hasNext();) {
422 FlagState root=(FlagState)it_rootnodes.next();
423 Vector allocatingTasks = root.getAllocatingTasks();
424 if(allocatingTasks != null) {
425 for(int k = 0; k < allocatingTasks.size(); k++) {
426 TaskDescriptor td = (TaskDescriptor)allocatingTasks.elementAt(k);
427 Vector<FEdge> fev = (Vector<FEdge>)ta.getFEdgesFromTD(td);
428 int numEdges = fev.size();
430 for(int j = 0; j < numEdges; j++) {
431 FEdge pfe = fev.elementAt(j);
432 if(numEdges - j == 1) {
433 pfe.setProbability(total);
435 if((total != 0) && (total != 1)) {
437 tint = r.nextInt()%total;
440 pfe.setProbability(tint);
444 // tint = r.nextInt()%10;
445 // } while(tint <= 0);
446 //int newRate = tint;
447 //int newRate = (j+1)%2+1;
449 String cdname = cd.getSymbol();
450 if((cdname.equals("SeriesRunner")) ||
451 (cdname.equals("MDRunner")) ||
452 (cdname.equals("Stage")) ||
453 (cdname.equals("AppDemoRunner")) ||
454 (cdname.equals("FilterBankAtom"))) {
456 } else if(cdname.equals("SentenceParser")) {
460 // tint = r.nextInt()%100;
461 // } while(tint <= 0);
462 // int probability = tint;
463 int probability = 100;
464 pfe.addNewObjInfo(cd, newRate, probability);
471 Iterator it_flags = ta.getFlagStates(cd).iterator();
472 while(it_flags.hasNext()) {
473 FlagState fs = (FlagState)it_flags.next();
474 Iterator it_edges = fs.edges();
476 while(it_edges.hasNext()) {
478 // tint = r.nextInt()%10;
479 // } while(tint <= 0);
481 FEdge edge = (FEdge)it_edges.next();
482 edge.setExeTime(tint);
483 if((fs.getClassDescriptor().getSymbol().equals("MD")) && (edge.getTask().getSymbol().equals("t6"))) {
484 if(edge.isbackedge()) {
485 if(edge.getTarget().equals(edge.getSource())) {
486 edge.setProbability(93.75);
488 edge.setProbability(3.125);
491 edge.setProbability(3.125);
495 if(!it_edges.hasNext()) {
496 edge.setProbability(total);
498 if((total != 0) && (total != 1)) {
500 tint = r.nextInt()%total;
503 edge.setProbability(tint);
512 // Use ownership analysis to get alias information
513 CallGraph callGraph = new CallGraph(state);
514 OwnershipAnalysis oa = new OwnershipAnalysis(state,
517 state.OWNERSHIPALLOCDEPTH,
518 state.OWNERSHIPWRITEDOTS,
519 state.OWNERSHIPWRITEALL,
520 state.OWNERSHIPALIASFILE);
522 // Save the current standard input, output, and error streams
523 // for later restoration.
524 PrintStream origOut = System.out;
526 // Create a new output stream for the standard output.
527 PrintStream stdout = null;
529 stdout = new PrintStream(new FileOutputStream("SimulatorResult.out"));
530 } catch (Exception e) {
531 // Sigh. Couldn't open the file.
532 System.out.println("Redirect: Unable to open output file!");
536 // Print stuff to the original output and error streams.
537 // On most systems all of this will end up on your console when you
538 // run this application.
539 //origOut.println ("\nRedirect: Round #1");
540 //System.out.println ("Test output via 'System.out'.");
541 //origOut.println ("Test output via 'origOut' reference.");
543 // Set the System out and err streams to use our replacements.
544 System.setOut(stdout);
546 // Print stuff to the original output and error streams.
547 // The stuff printed through the 'origOut' and 'origErr' references
548 // should go to the console on most systems while the messages
549 // printed through the 'System.out' and 'System.err' will end up in
550 // the files we created for them.
551 //origOut.println ("\nRedirect: Round #2");
552 //System.out.println ("Test output via 'SimulatorResult.out'.");
553 //origOut.println ("Test output via 'origOut' reference.");
555 // generate multiple schedulings
556 ScheduleAnalysis scheduleAnalysis = new ScheduleAnalysis(state, ta);
557 scheduleAnalysis.preSchedule();
558 scheduleAnalysis.scheduleAnalysis();
559 //scheduleAnalysis.setCoreNum(scheduleAnalysis.getSEdges4Test().size());
560 scheduleAnalysis.setCoreNum(state.CORENUM);
561 scheduleAnalysis.schedule();
563 //simulate these schedulings
564 ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), state, ta);
565 Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter();
567 Vector<Integer> selectedScheduling = new Vector<Integer>();
568 int processTime = Integer.MAX_VALUE;
569 while(it_scheduling.hasNext()) {
570 Vector<Schedule> scheduling = (Vector<Schedule>)it_scheduling.next();
571 scheduleSimulator.setScheduling(scheduling);
572 int tmpTime = scheduleSimulator.process();
573 if(tmpTime < processTime) {
574 selectedScheduling.clear();
575 selectedScheduling.add(index);
576 processTime = tmpTime;
577 } else if(tmpTime == processTime) {
578 selectedScheduling.add(index);
582 System.out.print("Selected schedulings with least exectution time " + processTime + ": \n\t");
583 for(int i = 0; i < selectedScheduling.size(); i++) {
584 System.out.print((selectedScheduling.elementAt(i) + 1) + ", ");
586 System.out.println();
588 /*ScheduleSimulator scheduleSimulator = new ScheduleSimulator(4, state, ta);
589 Vector<Schedule> scheduling = new Vector<Schedule>();
590 for(int i = 0; i < 4; i++) {
591 Schedule schedule = new Schedule(i);
592 scheduling.add(schedule);
594 Iterator it_tasks = state.getTaskSymbolTable().getAllDescriptorsIterator();
595 while(it_tasks.hasNext()) {
596 TaskDescriptor td = (TaskDescriptor)it_tasks.next();
597 if(td.getSymbol().equals("t10")) {
598 scheduling.elementAt(1).addTask(td);
600 scheduling.elementAt(0).addTask(td);
603 ClassDescriptor cd = (ClassDescriptor)state.getClassSymbolTable().get("E");
604 scheduling.elementAt(0).addTargetCore(cd, 1);
605 scheduleSimulator.setScheduling(scheduling);
606 scheduleSimulator.process();
608 Vector<Schedule> scheduling1 = new Vector<Schedule>();
609 for(int i = 0; i < 4; i++) {
610 Schedule schedule = new Schedule(i);
611 scheduling1.add(schedule);
613 Iterator it_tasks1 = state.getTaskSymbolTable().getAllDescriptorsIterator();
614 while(it_tasks1.hasNext()) {
615 TaskDescriptor td = (TaskDescriptor)it_tasks1.next();
616 scheduling1.elementAt(0).addTask(td);
618 scheduleSimulator.setScheduling(scheduling1);
619 scheduleSimulator.process();*/
621 // Close the streams.
624 System.setOut(origOut);
625 } catch (Exception e) {
626 origOut.println("Redirect: Unable to close files!");
629 if(state.MULTICORE) {
630 //it_scheduling = scheduleAnalysis.getSchedulingsIter();
631 //Vector<Schedule> scheduling = (Vector<Schedule>)it_scheduling.next();
632 Vector<Schedule> scheduling = scheduleAnalysis.getSchedulings().elementAt(selectedScheduling.lastElement());
633 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state, bf.getMap(), tu, sa, scheduling, scheduleAnalysis.getCoreNum(), pa);
634 bcm.setOwnershipAnalysis(oa);
641 if(!state.MULTICORE) {
643 CallGraph callgraph=new CallGraph(state);
644 if (state.PREFETCH) {
645 //speed up prefetch generation using locality analysis results
646 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
647 pa=new PrefetchAnalysis(state, callgraph, tu, la);
650 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
651 GenerateConversions gc=new GenerateConversions(la, state);
652 BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa);
655 BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa);
660 if (state.FLATIRGRAPH) {
661 FlatIRGraph firg = new FlatIRGraph(state,
662 state.FLATIRGRAPHTASKS,
663 state.FLATIRGRAPHUSERMETHODS,
664 state.FLATIRGRAPHLIBMETHODS);
667 if (state.OWNERSHIP) {
668 CallGraph callGraph = new CallGraph(state);
669 OwnershipAnalysis oa = new OwnershipAnalysis(state,
672 state.OWNERSHIPALLOCDEPTH,
673 state.OWNERSHIPWRITEDOTS,
674 state.OWNERSHIPWRITEALL,
675 state.OWNERSHIPALIASFILE);
681 /** Reads in a source file and adds the parse tree to the state object. */
683 private static void readSourceFile(State state, String sourcefile) throws Exception {
684 Reader fr = new BufferedReader(new FileReader(sourcefile));
685 Lex.Lexer l = new Lex.Lexer(fr);
686 java_cup.runtime.lr_parser g;
687 g = new Parse.Parser(l);
690 p=(ParseNode) g./*debug_*/ parse().value;
691 } catch (Exception e) {
692 System.err.println("Error parsing file:"+sourcefile);
696 state.addParseNode(p);
697 if (l.numErrors()!=0) {
698 System.out.println("Error parsing "+sourcefile);
699 System.exit(l.numErrors());