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.Hashtable;
10 import java.util.Iterator;
12 import java.util.Vector;
14 import IR.Tree.ParseNode;
15 import IR.Tree.BuildIR;
16 import IR.Tree.SemanticCheck;
17 import IR.Flat.BuildCodeMultiCore;
18 import IR.Flat.BuildCodeMGC;
19 import IR.Flat.BuildFlat;
20 import IR.Flat.BuildCode;
21 import IR.Flat.BuildCodeTran;
22 import IR.Flat.BuildOoOJavaCode;
23 import IR.Flat.Inliner;
24 import IR.ClassDescriptor;
26 import IR.TaskDescriptor;
28 import Analysis.SSJava.SSJavaAnalysis;
29 import Analysis.Scheduling.MCImplSynthesis;
30 import Analysis.Scheduling.Schedule;
31 import Analysis.Scheduling.ScheduleAnalysis;
32 import Analysis.Scheduling.ScheduleSimulator;
33 import Analysis.TaskStateAnalysis.TaskAnalysis;
34 import Analysis.TaskStateAnalysis.TaskTagAnalysis;
35 import Analysis.TaskStateAnalysis.TaskGraph;
36 import Analysis.CallGraph.CallGraph;
37 import Analysis.CallGraph.JavaCallGraph;
38 import Analysis.TaskStateAnalysis.FEdge;
39 import Analysis.TaskStateAnalysis.FlagState;
40 import Analysis.TaskStateAnalysis.TagAnalysis;
41 import Analysis.TaskStateAnalysis.GarbageAnalysis;
42 import Analysis.TaskStateAnalysis.ExecutionGraph;
43 import Analysis.TaskStateAnalysis.SafetyAnalysis;
44 import Analysis.Locality.LocalityAnalysis;
45 import Analysis.Locality.GenerateConversions;
46 import Analysis.Prefetch.PrefetchAnalysis;
47 import Analysis.FlatIRGraph.FlatIRGraph;
48 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
49 import Analysis.Disjoint.DisjointAnalysis;
50 import Analysis.OoOJava.OoOJavaAnalysis;
51 import Analysis.Loops.*;
52 import Analysis.Liveness;
53 import Analysis.ArrayReferencees;
54 import Analysis.Pointer.Pointer;
55 import IR.MethodDescriptor;
56 import IR.Flat.FlatMethod;
58 import Util.GraphNode;
59 import Util.GraphNode.DFS;
60 import Util.GraphNode.SCC;
64 /** Main method for the compiler. */
66 public static void main(String args[]) throws Exception {
67 String ClassLibraryPrefix="./ClassLibrary/";
68 State state=new State();
69 Vector sourcefiles=new Vector();
71 state.classpath.add(".");
73 String outputdir = null;
74 boolean isDistributeInfo = false;
75 boolean isDisAll = false;
79 for(int i=0; i<args.length; i++) {
80 String option=args[i];
81 if (option.equals("-precise"))
82 IR.Flat.BuildCode.GENERATEPRECISEGC=true;
83 else if (option.equals("-jni"))
85 else if (option.equals("-prefetch"))
87 else if (option.equals("-dir"))
88 IR.Flat.BuildCode.PREFIX=args[++i]+"/";
89 else if (option.equals("-fastcheck"))
91 else if (option.equals("-selfloop"))
92 state.selfloops.add(args[++i]);
93 else if (option.equals("-outputdir"))
94 state.outputdir = args[++i];
95 else if (option.equals("-excprefetch"))
96 state.excprefetch.add(args[++i]);
97 else if (option.equals("-classlibrary"))
98 state.classpath.add(args[++i]);
99 else if (option.equals("-inlineatomic")) {
100 state.INLINEATOMIC=true;
101 state.inlineatomicdepth=Integer.parseInt(args[++i]);
102 } else if(option.equals("-numcore")) {
104 state.CORENUM = Integer.parseInt(args[i]);
105 } else if(option.equals("-numcore4gc")) {
107 state.CORENUM4GC = Integer.parseInt(args[i]);
108 } else if (option.equals("-mainclass"))
109 state.main=args[++i];
110 else if (option.equals("-trueprob")) {
111 state.TRUEPROB=Double.parseDouble(args[++i]);
112 } else if (option.equals("-printflat"))
113 State.PRINTFLAT=true;
114 else if (option.equals("-printscheduling"))
115 State.PRINTSCHEDULING=true;
116 else if (option.equals("-minimize"))
118 else if (option.equals("-printschedulesim"))
119 State.PRINTSCHEDULESIM=true;
120 else if (option.equals("-printcriticalpath"))
121 State.PRINTCRITICALPATH=true;
122 else if (option.equals("-struct"))
123 state.structfile=args[++i];
124 else if (option.equals("-conscheck"))
125 state.CONSCHECK=true;
126 else if (option.equals("-task"))
128 else if (option.equals("-abortreaders"))
129 state.ABORTREADERS=true;
130 else if (option.equals("-sandbox"))
132 else if (option.equals("-taskstate"))
133 state.TASKSTATE=true;
134 else if (option.equals("-tagstate"))
136 else if (option.equals("-stmarray"))
138 else if (option.equals("-eventmonitor"))
139 state.EVENTMONITOR=true;
140 else if (option.equals("-dualview"))
142 else if (option.equals("-hybrid"))
144 else if (option.equals("-flatirtasks")) {
145 state.FLATIRGRAPH=true;
146 state.FLATIRGRAPHTASKS=true;
147 } else if (option.equals("-flatirusermethods")) {
148 state.FLATIRGRAPH=true;
149 state.FLATIRGRAPHUSERMETHODS=true;
150 } else if (option.equals("-flatirlibmethods")) {
151 state.FLATIRGRAPH=true;
152 state.FLATIRGRAPHLIBMETHODS=true;
153 } else if (option.equals("-bamboocompiletime")) {
154 state.BAMBOOCOMPILETIME = true;
155 } else if (option.equals("-multicore"))
156 state.MULTICORE=true;
157 else if (option.equals("-multicoregc"))
158 state.MULTICOREGC=true;
159 else if (option.equals("-mgc")) {
161 } else if (option.equals("-objectlockdebug")) {
162 state.OBJECTLOCKDEBUG = true;
163 } else if (option.equals("-ownership"))
164 state.OWNERSHIP=true;
165 else if (option.equals("-ownallocdepth")) {
166 state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
167 } else if (option.equals("-ownwritedots")) {
168 state.OWNERSHIPWRITEDOTS=true;
169 if (args[++i].equals("all")) {
170 state.OWNERSHIPWRITEALL=true;
172 } else if (option.equals("-ownaliasfile")) {
173 state.OWNERSHIPALIASFILE=args[++i];
174 } else if (option.equals("-ownaliasfiletab")) {
175 state.OWNERSHIPALIASFILE=args[++i];
176 state.OWNERSHIPALIASTAB=true;
177 } else if (option.equals("-owndebugcallee")) {
178 state.OWNERSHIPDEBUGCALLEE=args[++i];
179 } else if (option.equals("-owndebugcaller")) {
180 state.OWNERSHIPDEBUGCALLER=args[++i];
181 } else if (option.equals("-owndebugcallcount")) {
182 state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
183 } else if (option.equals("-pointer")) {
185 } else if (option.equals("-disjoint"))
187 else if (option.equals("-disjoint-k")) {
188 state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
190 } else if (option.equals("-disjoint-write-dots")) {
191 state.DISJOINTWRITEDOTS = true;
192 String arg = args[++i];
193 if( arg.equals("all") ) {
194 state.DISJOINTWRITEALL = true;
195 } else if( arg.equals("final") ) {
196 state.DISJOINTWRITEALL = false;
198 throw new Error("disjoint-write-dots requires argument <all/final>");
201 } else if (option.equals("-disjoint-write-initial-contexts")) {
202 state.DISJOINTWRITEINITCONTEXTS = true;
204 } else if (option.equals("-disjoint-write-ihms")) {
205 state.DISJOINTWRITEIHMS = true;
207 } else if (option.equals("-disjoint-alias-file")) {
208 state.DISJOINTALIASFILE = args[++i];
209 String arg = args[++i];
210 if( arg.equals("normal") ) {
211 state.DISJOINTALIASTAB = false;
212 } else if( arg.equals("tabbed") ) {
213 state.DISJOINTALIASTAB = true;
215 throw new Error("disjoint-alias-file requires arguments: <filename> <normal/tabbed>");
218 } else if (option.equals("-disjoint-debug-callsite")) {
219 state.DISJOINTDEBUGCALLEE=args[++i];
220 state.DISJOINTDEBUGCALLER=args[++i];
221 state.DISJOINTDEBUGCALLVISITTOSTART=Integer.parseInt(args[++i]);
222 state.DISJOINTDEBUGCALLNUMVISITS=Integer.parseInt(args[++i]);
223 String arg = args[++i];
224 if( arg.equals("true") ) {
225 state.DISJOINTDEBUGCALLSTOPAFTER = true;
226 } else if( arg.equals("false") ) {
227 state.DISJOINTDEBUGCALLSTOPAFTER = false;
229 throw new Error("disjoint-debug-callsite requires arguments:\n"+
230 " <callee symbol> <caller symbol> <# visit to start> <# visits to capture> <T/F stop after>");
233 } else if (option.equals("-disjoint-debug-snap-method")) {
234 state.DISJOINTSNAPSYMBOL=args[++i];
235 state.DISJOINTSNAPVISITTOSTART=Integer.parseInt(args[++i]);
236 state.DISJOINTSNAPNUMVISITS=Integer.parseInt(args[++i]);
237 String arg = args[++i];
238 if( arg.equals("true") ) {
239 state.DISJOINTSNAPSTOPAFTER = true;
240 } else if( arg.equals("false") ) {
241 state.DISJOINTSNAPSTOPAFTER = false;
243 throw new Error("disjoint-debug-snap-method requires arguments:\n"+
244 " <method symbol> <# visit to start> <# visits to snap> <T/F stop after>");
247 } else if( option.equals( "-disjoint-release-mode" ) ) {
248 state.DISJOINTRELEASEMODE = true;
250 } else if( option.equals( "-disjoint-dvisit-stack" ) ) {
251 state.DISJOINTDVISITSTACK = true;
252 state.DISJOINTDVISITPQUE = false;
253 state.DISJOINTDVISITSTACKEESONTOP = false;
255 } else if( option.equals( "-disjoint-dvisit-pqueue" ) ) {
256 state.DISJOINTDVISITPQUE = true;
257 state.DISJOINTDVISITSTACK = false;
258 state.DISJOINTDVISITSTACKEESONTOP = false;
260 } else if( option.equals( "-disjoint-dvisit-stack-callees-on-top" ) ) {
261 state.DISJOINTDVISITSTACKEESONTOP = true;
262 state.DISJOINTDVISITPQUE = false;
263 state.DISJOINTDVISITSTACK = false;
265 } else if( option.equals( "-disjoint-desire-determinism" ) ) {
266 state.DISJOINTDETERMINISM = true;
268 // when asking analysis for a deterministic result, force
269 // a stack-based visiting scheme, because the priority queue
270 // requires a non-deterministic topological sort
271 state.DISJOINTDVISITSTACKEESONTOP = true;
272 state.DISJOINTDVISITPQUE = false;
273 state.DISJOINTDVISITSTACK = false;
276 } else if( option.equals( "-disjoint-debug-scheduling" ) ) {
277 state.DISJOINTDEBUGSCHEDULING = true;
281 else if (option.equals("-optional"))
283 else if (option.equals("-optimize"))
285 else if (option.equals("-noloop"))
287 else if (option.equals("-dcopts"))
289 else if (option.equals("-arraypad"))
291 else if (option.equals("-delaycomp"))
292 state.DELAYCOMP=true;
293 else if (option.equals("-raw"))
295 else if (option.equals("-scheduling"))
296 state.SCHEDULING=true;
297 else if (option.equals("-distributioninfo"))
298 isDistributeInfo=true;
299 else if (option.equals("-disall"))
301 else if (option.equals("-disstart"))
302 startnum = Integer.parseInt(args[++i]);
303 else if (option.equals("-useprofile")) {
304 state.USEPROFILE=true;
305 state.profilename = args[++i];
307 else if (option.equals("-thread"))
309 else if (option.equals("-dsm"))
311 else if (option.equals("-recoverystats"))
312 state.DSMRECOVERYSTATS=true;
313 else if (option.equals("-dsmtask"))
315 else if (option.equals("-singleTM"))
317 else if (option.equals("-readset"))
319 else if (option.equals("-webinterface"))
320 state.WEBINTERFACE=true;
321 else if (option.equals("-instructionfailures"))
322 state.INSTRUCTIONFAILURE=true;
323 else if (option.equals("-abcclose"))
324 state.ARRAYBOUNDARYCHECK=false;
326 else if (option.equals("-methodeffects")) {
327 state.METHODEFFECTS=true;
329 } else if (option.equals("-coreprof")) {
332 } else if (option.equals("-ooojava")) {
333 state.OOOJAVA = true;
334 state.DISJOINT = true;
335 state.OOO_NUMCORES = Integer.parseInt( args[++i] );
336 state.OOO_MAXSESEAGE = Integer.parseInt( args[++i] );
338 } else if (option.equals("-ooodebug") ){
339 state.OOODEBUG = true;
340 } else if (option.equals("-rcr")){
342 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
343 } else if (option.equals("-rcr_debug")){
344 state.RCR_DEBUG = true;
345 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
346 } else if (option.equals("-rcr_debug_verbose")){
347 state.RCR_DEBUG_VERBOSE = true;
348 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
349 } else if (option.equals("-nostalltr")){
350 state.NOSTALLTR = true;
351 } else if (option.equals("-ssjava")){
353 } else if (option.equals("-printlinenum")){
355 }else if (option.equals("-help")) {
356 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
357 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
358 System.out.println("-dir outputdirectory -- output code in outputdirectory");
359 System.out.println("-struct structfile -- output structure declarations for repair tool");
360 System.out.println("-mainclass -- main function to call");
361 System.out.println("-dsm -- distributed shared memory support");
362 System.out.println("-singleTM -- single machine committing transactions");
363 System.out.println("-abortreaders -- abort readers");
364 System.out.println("-precise -- use precise garbage collection");
365 System.out.println("-conscheck -- turn on consistency checking");
366 System.out.println("-task -- compiler for tasks");
367 System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
368 System.out.println("-thread -- threads");
369 System.out.println("-trueprob <d> -- probability of true branch");
370 System.out.println("-printflat -- print out flat representation");
371 System.out.println("-instructionfailures -- insert code for instruction level failures");
372 System.out.println("-taskstate -- do task state analysis");
373 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
374 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
375 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
376 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
377 System.out.println("-ownership -- do ownership analysis");
378 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
379 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
380 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
381 System.out.println("-optimize -- enable optimizations");
382 System.out.println("-noloop -- disable loop optimizations");
383 System.out.println("-optional -- enable optional arguments");
384 System.out.println("-abcclose close the array boundary check");
385 System.out.println("-scheduling do task scheduling");
386 System.out.println("-mlp <num cores> <max sese age> build mlp code");
387 System.out.println("-mlpdebug if mlp, report progress and interim results");
388 System.out.println("-multicore generate multi-core version binary");
389 System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
390 System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
391 System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
392 System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
393 System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
394 System.out.println("-threadsimulate generate multi-thread simulate version binary");
395 System.out.println("-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version");
396 System.out.println("-printscheduling -- print out scheduling graphs");
397 System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
398 System.out.println("-webinterface -- enable web interface");
399 System.out.println("-linenum print out line numbers in generated C codes");
400 System.out.println("-help -- print out help");
403 sourcefiles.add(args[i]);
407 //add default classpath
408 if (state.classpath.size()==1)
409 state.classpath.add(ClassLibraryPrefix);
411 State.logEvent("Done Parsing Commands");
413 SSJavaAnalysis ssjava=new SSJavaAnalysis(state);
414 BuildIR bir=new BuildIR(state);
415 TypeUtil tu=new TypeUtil(state, bir);
417 SemanticCheck sc=new SemanticCheck(state,tu);
419 for(int i=0;i<sourcefiles.size();i++)
420 loadClass(state, bir,(String)sourcefiles.get(i));
422 //Stuff the runtime wants to see
423 sc.getClass("String");
426 sc.getClass("Socket");
427 sc.getClass("ServerSocket");
428 sc.getClass("FileInputStream");
429 sc.getClass("FileOutputStream");
431 sc.getClass("TagDescriptor");
433 if (state.THREAD||state.DSM||state.SINGLETM||state.MGC) {
434 sc.getClass("Thread");
439 State.logEvent("Done Semantic Checking");
441 tu.createFullTable();
442 State.logEvent("Done Creating TypeUtil");
444 BuildFlat bf=new BuildFlat(state,tu);
446 State.logEvent("Done Building Flat");
448 SafetyAnalysis sa=null;
449 PrefetchAnalysis pa=null;
450 OoOJavaAnalysis oooa=null;
451 if (state.INLINEATOMIC) {
452 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
453 while(classit.hasNext()) {
454 ClassDescriptor cn=(ClassDescriptor)classit.next();
455 Iterator methodit=cn.getMethods();
456 while(methodit.hasNext()) {
458 MethodDescriptor md=(MethodDescriptor)methodit.next();
459 FlatMethod fm=state.getMethodFlat(md);
460 Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
465 CallGraph callgraph=state.TASK?new CallGraph(state, tu):new JavaCallGraph(state, tu);
469 ssjava.doFlowDownCheck();
470 ssjava.doLoopCheck();
471 State.logEvent("Done SSJava Checking");
474 if (state.OPTIMIZE) {
475 CopyPropagation cp=new CopyPropagation();
476 DeadCode dc=new DeadCode();
477 GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
478 CSE cse=new CSE(gft, tu);
479 localCSE lcse=new localCSE(gft, tu);
480 LoopOptimize lo=null;
482 lo=new LoopOptimize(gft, tu);
483 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
484 while(classit.hasNext()) {
485 ClassDescriptor cn=(ClassDescriptor)classit.next();
486 Iterator methodit=cn.getMethods();
487 while(methodit.hasNext()) {
488 /* Classify parameters */
489 MethodDescriptor md=(MethodDescriptor)methodit.next();
490 FlatMethod fm=state.getMethodFlat(md);
505 State.logEvent("Done Optimizing");
508 if (state.FLATIRGRAPH) {
509 FlatIRGraph firg = new FlatIRGraph(state,
510 state.FLATIRGRAPHTASKS,
511 state.FLATIRGRAPHUSERMETHODS,
512 state.FLATIRGRAPHLIBMETHODS);
515 if (state.OWNERSHIP) {
516 Liveness liveness = new Liveness();
517 ArrayReferencees ar = new ArrayReferencees(state);
518 OwnershipAnalysis oa = new OwnershipAnalysis(state,
523 state.OWNERSHIPALLOCDEPTH,
524 state.OWNERSHIPWRITEDOTS,
525 state.OWNERSHIPWRITEALL,
526 state.OWNERSHIPALIASFILE,
527 state.METHODEFFECTS);
530 if (state.DISJOINT && !state.OOOJAVA) {
531 Liveness l = new Liveness();
532 ArrayReferencees ar = new ArrayReferencees(state);
533 DisjointAnalysis da = new DisjointAnalysis(state, tu, callgraph, l, ar, null, null);
537 Liveness l = new Liveness();
538 ArrayReferencees ar = new ArrayReferencees(state);
539 oooa = new OoOJavaAnalysis(state, tu, callgraph, l, ar);
543 if (state.TAGSTATE) {
544 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
545 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
548 if (state.TASKSTATE) {
549 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
550 TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
552 TaskGraph tg=new TaskGraph(state, ta);
555 if (state.OPTIONAL) {
556 ExecutionGraph et=new ExecutionGraph(state, ta);
557 et.createExecutionGraph();
558 sa = new SafetyAnalysis(et.getExecutionGraph(), state, ta);
560 state.storeAnalysisResult(sa.getResult());
561 state.storeOptionalTaskDescriptors(sa.getOptionalTaskDescriptors());
564 if (state.WEBINTERFACE) {
565 GarbageAnalysis ga=new GarbageAnalysis(state, ta);
566 WebInterface wi=new WebInterface(state, ta, tg, ga, taganalysis);
567 JhttpServer serve=new JhttpServer(8000,wi);
571 if (state.SCHEDULING) {
572 // Use ownership analysis to get alias information
573 Liveness liveness = new Liveness();
574 ArrayReferencees ar = new ArrayReferencees(state);
575 OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
580 state.OWNERSHIPALLOCDEPTH,
581 state.OWNERSHIPWRITEDOTS,
582 state.OWNERSHIPWRITEALL,
583 state.OWNERSHIPALIASFILE);*/
585 // synthesis a layout according to target multicore processor
586 MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
589 if(isDistributeInfo) {
590 mcImplSynthesis.distribution(isDisAll, startnum);
592 double timeStartAnalysis = (double) System.nanoTime();
593 mcImplSynthesis.setScheduleThreshold(20);
594 mcImplSynthesis.setProbThreshold(0);
595 mcImplSynthesis.setGenerateThreshold(30);
596 Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
598 double timeEndAnalysis = (double) System.nanoTime();
599 if(state.BAMBOOCOMPILETIME) {
600 double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
601 System.err.println("The analysis took" + dt + "sec.");
605 // generate multicore codes
606 if(state.MULTICORE) {
607 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
612 mcImplSynthesis.getCoreNum(),
613 state.CORENUM4GC, callgraph);
614 bcm.setOwnershipAnalysis(oa);
624 // generate multicore codes
625 if(state.MULTICORE) {
626 BuildCodeMGC bcmgc=new BuildCodeMGC(state,
632 state.CORENUM4GC, callgraph);
637 if(!state.MULTICORE) {
640 if (state.DSM||state.SINGLETM) {
641 if (state.PREFETCH) {
642 //speed up prefetch generation using locality analysis results
643 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
644 pa=new PrefetchAnalysis(state, callgraph, tu, la);
646 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
647 GenerateConversions gc=new GenerateConversions(la, state);
648 bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa, callgraph);
650 if( state.OOOJAVA ) {
651 bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa, callgraph);
653 bc=new BuildCode(state, bf.getMap(), tu, sa, callgraph);
658 State.logEvent("Done With BuildCode");
662 System.out.println("Lines="+state.lines);
666 public static void loadClass(State state, BuildIR bir, String sourcefile) {
668 ParseNode pn=readSourceFile(state, sourcefile);
669 bir.buildtree(pn, null,sourcefile);
670 } catch (Exception e) {
671 System.out.println("Error in sourcefile:"+sourcefile);
675 System.out.println("Error in sourcefile:"+sourcefile);
681 /** Reads in a source file and adds the parse tree to the state object. */
683 public static ParseNode readSourceFile(State state, String sourcefile) {
685 Reader fr= new BufferedReader(new FileReader(sourcefile));
686 Lex.Lexer l = new Lex.Lexer(fr);
687 java_cup.runtime.lr_parser g;
688 g = new Parse.Parser(l);
691 p=(ParseNode) g./*debug_*/parse().value;
692 } catch (Exception e) {
693 System.err.println("Error parsing file:"+sourcefile);
697 state.addParseNode(p);
698 if (l.numErrors()!=0) {
699 System.out.println("Error parsing "+sourcefile);
700 System.exit(l.numErrors());
702 state.lines+=l.line_num;
705 } catch (Exception e) {