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.TaskStateAnalysis.FEdge;
38 import Analysis.TaskStateAnalysis.FlagState;
39 import Analysis.TaskStateAnalysis.TagAnalysis;
40 import Analysis.TaskStateAnalysis.GarbageAnalysis;
41 import Analysis.TaskStateAnalysis.ExecutionGraph;
42 import Analysis.TaskStateAnalysis.SafetyAnalysis;
43 import Analysis.Locality.LocalityAnalysis;
44 import Analysis.Locality.GenerateConversions;
45 import Analysis.Prefetch.PrefetchAnalysis;
46 import Analysis.FlatIRGraph.FlatIRGraph;
47 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
48 import Analysis.Disjoint.DisjointAnalysis;
49 import Analysis.OoOJava.OoOJavaAnalysis;
50 import Analysis.Loops.*;
51 import Analysis.Liveness;
52 import Analysis.ArrayReferencees;
53 import Analysis.Pointer.Pointer;
54 import IR.MethodDescriptor;
55 import IR.Flat.FlatMethod;
57 import Util.GraphNode;
58 import Util.GraphNode.DFS;
59 import Util.GraphNode.SCC;
63 /** Main method for the compiler. */
65 public static void main(String args[]) throws Exception {
66 String ClassLibraryPrefix="./ClassLibrary/";
67 State state=new State();
68 Vector sourcefiles=new Vector();
70 state.classpath.add(".");
72 String outputdir = null;
73 boolean isDistributeInfo = false;
74 boolean isDisAll = false;
78 for(int i=0; i<args.length; i++) {
79 String option=args[i];
80 if (option.equals("-precise"))
81 IR.Flat.BuildCode.GENERATEPRECISEGC=true;
82 else if (option.equals("-prefetch"))
84 else if (option.equals("-dir"))
85 IR.Flat.BuildCode.PREFIX=args[++i]+"/";
86 else if (option.equals("-fastcheck"))
88 else if (option.equals("-selfloop"))
89 state.selfloops.add(args[++i]);
90 else if (option.equals("-outputdir"))
91 state.outputdir = args[++i];
92 else if (option.equals("-excprefetch"))
93 state.excprefetch.add(args[++i]);
94 else if (option.equals("-classlibrary"))
95 state.classpath.add(args[++i]);
96 else if (option.equals("-inlineatomic")) {
97 state.INLINEATOMIC=true;
98 state.inlineatomicdepth=Integer.parseInt(args[++i]);
99 } else if(option.equals("-numcore")) {
101 state.CORENUM = Integer.parseInt(args[i]);
102 } else if(option.equals("-numcore4gc")) {
104 state.CORENUM4GC = Integer.parseInt(args[i]);
105 } else if (option.equals("-mainclass"))
106 state.main=args[++i];
107 else if (option.equals("-trueprob")) {
108 state.TRUEPROB=Double.parseDouble(args[++i]);
109 } else if (option.equals("-printflat"))
110 State.PRINTFLAT=true;
111 else if (option.equals("-printscheduling"))
112 State.PRINTSCHEDULING=true;
113 else if (option.equals("-minimize"))
115 else if (option.equals("-printschedulesim"))
116 State.PRINTSCHEDULESIM=true;
117 else if (option.equals("-printcriticalpath"))
118 State.PRINTCRITICALPATH=true;
119 else if (option.equals("-struct"))
120 state.structfile=args[++i];
121 else if (option.equals("-conscheck"))
122 state.CONSCHECK=true;
123 else if (option.equals("-task"))
125 else if (option.equals("-abortreaders"))
126 state.ABORTREADERS=true;
127 else if (option.equals("-sandbox"))
129 else if (option.equals("-taskstate"))
130 state.TASKSTATE=true;
131 else if (option.equals("-tagstate"))
133 else if (option.equals("-stmarray"))
135 else if (option.equals("-eventmonitor"))
136 state.EVENTMONITOR=true;
137 else if (option.equals("-dualview"))
139 else if (option.equals("-hybrid"))
141 else if (option.equals("-flatirtasks")) {
142 state.FLATIRGRAPH=true;
143 state.FLATIRGRAPHTASKS=true;
144 } else if (option.equals("-flatirusermethods")) {
145 state.FLATIRGRAPH=true;
146 state.FLATIRGRAPHUSERMETHODS=true;
147 } else if (option.equals("-flatirlibmethods")) {
148 state.FLATIRGRAPH=true;
149 state.FLATIRGRAPHLIBMETHODS=true;
150 } else if (option.equals("-bamboocompiletime")) {
151 state.BAMBOOCOMPILETIME = true;
152 } else if (option.equals("-multicore"))
153 state.MULTICORE=true;
154 else if (option.equals("-multicoregc"))
155 state.MULTICOREGC=true;
156 else if (option.equals("-mgc")) {
158 } else if (option.equals("-objectlockdebug")) {
159 state.OBJECTLOCKDEBUG = true;
160 } else if (option.equals("-ownership"))
161 state.OWNERSHIP=true;
162 else if (option.equals("-ownallocdepth")) {
163 state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
164 } else if (option.equals("-ownwritedots")) {
165 state.OWNERSHIPWRITEDOTS=true;
166 if (args[++i].equals("all")) {
167 state.OWNERSHIPWRITEALL=true;
169 } else if (option.equals("-ownaliasfile")) {
170 state.OWNERSHIPALIASFILE=args[++i];
171 } else if (option.equals("-ownaliasfiletab")) {
172 state.OWNERSHIPALIASFILE=args[++i];
173 state.OWNERSHIPALIASTAB=true;
174 } else if (option.equals("-owndebugcallee")) {
175 state.OWNERSHIPDEBUGCALLEE=args[++i];
176 } else if (option.equals("-owndebugcaller")) {
177 state.OWNERSHIPDEBUGCALLER=args[++i];
178 } else if (option.equals("-owndebugcallcount")) {
179 state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
180 } else if (option.equals("-pointer")) {
182 } else if (option.equals("-disjoint"))
184 else if (option.equals("-disjoint-k")) {
185 state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
187 } else if (option.equals("-disjoint-write-dots")) {
188 state.DISJOINTWRITEDOTS = true;
189 String arg = args[++i];
190 if( arg.equals("all") ) {
191 state.DISJOINTWRITEALL = true;
192 } else if( arg.equals("final") ) {
193 state.DISJOINTWRITEALL = false;
195 throw new Error("disjoint-write-dots requires argument <all/final>");
198 } else if (option.equals("-disjoint-write-initial-contexts")) {
199 state.DISJOINTWRITEINITCONTEXTS = true;
201 } else if (option.equals("-disjoint-write-ihms")) {
202 state.DISJOINTWRITEIHMS = true;
204 } else if (option.equals("-disjoint-alias-file")) {
205 state.DISJOINTALIASFILE = args[++i];
206 String arg = args[++i];
207 if( arg.equals("normal") ) {
208 state.DISJOINTALIASTAB = false;
209 } else if( arg.equals("tabbed") ) {
210 state.DISJOINTALIASTAB = true;
212 throw new Error("disjoint-alias-file requires arguments: <filename> <normal/tabbed>");
215 } else if (option.equals("-disjoint-debug-callsite")) {
216 state.DISJOINTDEBUGCALLEE=args[++i];
217 state.DISJOINTDEBUGCALLER=args[++i];
218 state.DISJOINTDEBUGCALLVISITTOSTART=Integer.parseInt(args[++i]);
219 state.DISJOINTDEBUGCALLNUMVISITS=Integer.parseInt(args[++i]);
220 String arg = args[++i];
221 if( arg.equals("true") ) {
222 state.DISJOINTDEBUGCALLSTOPAFTER = true;
223 } else if( arg.equals("false") ) {
224 state.DISJOINTDEBUGCALLSTOPAFTER = false;
226 throw new Error("disjoint-debug-callsite requires arguments:\n"+
227 " <callee symbol> <caller symbol> <# visit to start> <# visits to capture> <T/F stop after>");
230 } else if (option.equals("-disjoint-debug-snap-method")) {
231 state.DISJOINTSNAPSYMBOL=args[++i];
232 state.DISJOINTSNAPVISITTOSTART=Integer.parseInt(args[++i]);
233 state.DISJOINTSNAPNUMVISITS=Integer.parseInt(args[++i]);
234 String arg = args[++i];
235 if( arg.equals("true") ) {
236 state.DISJOINTSNAPSTOPAFTER = true;
237 } else if( arg.equals("false") ) {
238 state.DISJOINTSNAPSTOPAFTER = false;
240 throw new Error("disjoint-debug-snap-method requires arguments:\n"+
241 " <method symbol> <# visit to start> <# visits to snap> <T/F stop after>");
244 } else if( option.equals( "-disjoint-release-mode" ) ) {
245 state.DISJOINTRELEASEMODE = true;
247 } else if( option.equals( "-disjoint-dvisit-stack" ) ) {
248 state.DISJOINTDVISITSTACK = true;
249 state.DISJOINTDVISITPQUE = false;
250 state.DISJOINTDVISITSTACKEESONTOP = false;
252 } else if( option.equals( "-disjoint-dvisit-pqueue" ) ) {
253 state.DISJOINTDVISITPQUE = true;
254 state.DISJOINTDVISITSTACK = false;
255 state.DISJOINTDVISITSTACKEESONTOP = false;
257 } else if( option.equals( "-disjoint-dvisit-stack-callees-on-top" ) ) {
258 state.DISJOINTDVISITSTACKEESONTOP = true;
259 state.DISJOINTDVISITPQUE = false;
260 state.DISJOINTDVISITSTACK = false;
262 } else if( option.equals( "-disjoint-desire-determinism" ) ) {
263 state.DISJOINTDETERMINISM = true;
265 // when asking analysis for a deterministic result, force
266 // a stack-based visiting scheme, because the priority queue
267 // requires a non-deterministic topological sort
268 state.DISJOINTDVISITSTACKEESONTOP = true;
269 state.DISJOINTDVISITPQUE = false;
270 state.DISJOINTDVISITSTACK = false;
273 } else if( option.equals( "-disjoint-debug-scheduling" ) ) {
274 state.DISJOINTDEBUGSCHEDULING = true;
278 else if (option.equals("-optional"))
280 else if (option.equals("-optimize"))
282 else if (option.equals("-noloop"))
284 else if (option.equals("-dcopts"))
286 else if (option.equals("-arraypad"))
288 else if (option.equals("-delaycomp"))
289 state.DELAYCOMP=true;
290 else if (option.equals("-raw"))
292 else if (option.equals("-scheduling"))
293 state.SCHEDULING=true;
294 else if (option.equals("-distributioninfo"))
295 isDistributeInfo=true;
296 else if (option.equals("-disall"))
298 else if (option.equals("-disstart"))
299 startnum = Integer.parseInt(args[++i]);
300 else if (option.equals("-useprofile")) {
301 state.USEPROFILE=true;
302 state.profilename = args[++i];
304 else if (option.equals("-thread"))
306 else if (option.equals("-dsm"))
308 else if (option.equals("-recoverystats"))
309 state.DSMRECOVERYSTATS=true;
310 else if (option.equals("-dsmtask"))
312 else if (option.equals("-singleTM"))
314 else if (option.equals("-readset"))
316 else if (option.equals("-webinterface"))
317 state.WEBINTERFACE=true;
318 else if (option.equals("-instructionfailures"))
319 state.INSTRUCTIONFAILURE=true;
320 else if (option.equals("-abcclose"))
321 state.ARRAYBOUNDARYCHECK=false;
323 else if (option.equals("-methodeffects")) {
324 state.METHODEFFECTS=true;
326 } else if (option.equals("-coreprof")) {
329 } else if (option.equals("-ooojava")) {
330 state.OOOJAVA = true;
331 state.DISJOINT = true;
332 state.OOO_NUMCORES = Integer.parseInt( args[++i] );
333 state.OOO_MAXSESEAGE = Integer.parseInt( args[++i] );
335 } else if (option.equals("-ooodebug") ){
336 state.OOODEBUG = true;
337 } else if (option.equals("-rcr")){
339 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
340 } else if (option.equals("-rcr_debug")){
341 state.RCR_DEBUG = true;
342 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
343 } else if (option.equals("-rcr_debug_verbose")){
344 state.RCR_DEBUG_VERBOSE = true;
345 state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
346 } else if (option.equals("-nostalltr")){
347 state.NOSTALLTR = true;
348 } else if (option.equals("-ssjava")){
350 } else if (option.equals("-printlinenum")){
352 }else if (option.equals("-help")) {
353 System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
354 System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
355 System.out.println("-dir outputdirectory -- output code in outputdirectory");
356 System.out.println("-struct structfile -- output structure declarations for repair tool");
357 System.out.println("-mainclass -- main function to call");
358 System.out.println("-dsm -- distributed shared memory support");
359 System.out.println("-singleTM -- single machine committing transactions");
360 System.out.println("-abortreaders -- abort readers");
361 System.out.println("-precise -- use precise garbage collection");
362 System.out.println("-conscheck -- turn on consistency checking");
363 System.out.println("-task -- compiler for tasks");
364 System.out.println("-fastcheck -- fastcheckpointing for Bristlecone");
365 System.out.println("-thread -- threads");
366 System.out.println("-trueprob <d> -- probability of true branch");
367 System.out.println("-printflat -- print out flat representation");
368 System.out.println("-instructionfailures -- insert code for instruction level failures");
369 System.out.println("-taskstate -- do task state analysis");
370 System.out.println("-flatirtasks -- create dot files for flat IR graphs of tasks");
371 System.out.println("-flatirusermethods -- create dot files for flat IR graphs of user methods");
372 System.out.println("-flatirlibmethods -- create dot files for flat IR graphs of library class methods");
373 System.out.println(" note: -flatirusermethods or -flatirlibmethods currently generate all class method flat IR graphs");
374 System.out.println("-ownership -- do ownership analysis");
375 System.out.println("-ownallocdepth <d> -- set allocation depth for ownership analysis");
376 System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
377 System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
378 System.out.println("-optimize -- enable optimizations");
379 System.out.println("-noloop -- disable loop optimizations");
380 System.out.println("-optional -- enable optional arguments");
381 System.out.println("-abcclose close the array boundary check");
382 System.out.println("-scheduling do task scheduling");
383 System.out.println("-mlp <num cores> <max sese age> build mlp code");
384 System.out.println("-mlpdebug if mlp, report progress and interim results");
385 System.out.println("-multicore generate multi-core version binary");
386 System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
387 System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
388 System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
389 System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
390 System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
391 System.out.println("-threadsimulate generate multi-thread simulate version binary");
392 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");
393 System.out.println("-printscheduling -- print out scheduling graphs");
394 System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
395 System.out.println("-webinterface -- enable web interface");
396 System.out.println("-linenum print out line numbers in generated C codes");
397 System.out.println("-help -- print out help");
400 sourcefiles.add(args[i]);
404 //add default classpath
405 if (state.classpath.size()==1)
406 state.classpath.add(ClassLibraryPrefix);
408 State.logEvent("Done Parsing Commands");
410 SSJavaAnalysis ssjava=new SSJavaAnalysis(state);
411 BuildIR bir=new BuildIR(state);
412 TypeUtil tu=new TypeUtil(state, bir);
414 SemanticCheck sc=new SemanticCheck(state,tu);
416 for(int i=0;i<sourcefiles.size();i++)
417 loadClass(state, bir,(String)sourcefiles.get(i));
419 //Stuff the runtime wants to see
420 sc.getClass("String");
423 sc.getClass("Socket");
424 sc.getClass("ServerSocket");
425 sc.getClass("FileInputStream");
426 sc.getClass("FileOutputStream");
428 sc.getClass("TagDescriptor");
430 if (state.THREAD||state.DSM||state.SINGLETM||state.MGC) {
431 sc.getClass("Thread");
436 State.logEvent("Done Semantic Checking");
438 tu.createFullTable();
439 State.logEvent("Done Creating TypeUtil");
447 BuildFlat bf=new BuildFlat(state,tu);
449 State.logEvent("Done Building Flat");
451 SafetyAnalysis sa=null;
452 PrefetchAnalysis pa=null;
453 OoOJavaAnalysis oooa=null;
454 if (state.INLINEATOMIC) {
455 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
456 while(classit.hasNext()) {
457 ClassDescriptor cn=(ClassDescriptor)classit.next();
458 Iterator methodit=cn.getMethods();
459 while(methodit.hasNext()) {
461 MethodDescriptor md=(MethodDescriptor)methodit.next();
462 FlatMethod fm=state.getMethodFlat(md);
463 Inliner.inlineAtomic(state, tu, fm, state.inlineatomicdepth);
468 if (state.OPTIMIZE) {
469 CallGraph callgraph=new CallGraph(state);
470 CopyPropagation cp=new CopyPropagation();
471 DeadCode dc=new DeadCode();
472 GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
473 CSE cse=new CSE(gft, tu);
474 localCSE lcse=new localCSE(gft, tu);
475 LoopOptimize lo=null;
477 lo=new LoopOptimize(gft, tu);
478 Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
479 while(classit.hasNext()) {
480 ClassDescriptor cn=(ClassDescriptor)classit.next();
481 Iterator methodit=cn.getMethods();
482 while(methodit.hasNext()) {
483 /* Classify parameters */
484 MethodDescriptor md=(MethodDescriptor)methodit.next();
485 FlatMethod fm=state.getMethodFlat(md);
500 State.logEvent("Done Optimizing");
503 if (state.FLATIRGRAPH) {
504 FlatIRGraph firg = new FlatIRGraph(state,
505 state.FLATIRGRAPHTASKS,
506 state.FLATIRGRAPHUSERMETHODS,
507 state.FLATIRGRAPHLIBMETHODS);
510 if (state.OWNERSHIP) {
511 CallGraph callGraph = new CallGraph(state);
512 Liveness liveness = new Liveness();
513 ArrayReferencees ar = new ArrayReferencees(state);
514 OwnershipAnalysis oa = new OwnershipAnalysis(state,
519 state.OWNERSHIPALLOCDEPTH,
520 state.OWNERSHIPWRITEDOTS,
521 state.OWNERSHIPWRITEALL,
522 state.OWNERSHIPALIASFILE,
523 state.METHODEFFECTS);
526 if (state.DISJOINT && !state.OOOJAVA) {
527 CallGraph cg = new CallGraph(state);
528 Liveness l = new Liveness();
529 ArrayReferencees ar = new ArrayReferencees(state);
530 DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null);
534 CallGraph cg = new CallGraph(state);
535 Liveness l = new Liveness();
536 ArrayReferencees ar = new ArrayReferencees(state);
537 oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
541 if (state.TAGSTATE) {
542 CallGraph callgraph=new CallGraph(state);
543 TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
544 TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
547 if (state.TASKSTATE) {
548 CallGraph callgraph=new CallGraph(state);
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 CallGraph callGraph = new CallGraph(state);
574 Liveness liveness = new Liveness();
575 ArrayReferencees ar = new ArrayReferencees(state);
576 OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
581 state.OWNERSHIPALLOCDEPTH,
582 state.OWNERSHIPWRITEDOTS,
583 state.OWNERSHIPWRITEALL,
584 state.OWNERSHIPALIASFILE);*/
586 // synthesis a layout according to target multicore processor
587 MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
590 if(isDistributeInfo) {
591 mcImplSynthesis.distribution(isDisAll, startnum);
593 double timeStartAnalysis = (double) System.nanoTime();
594 mcImplSynthesis.setScheduleThreshold(20);
595 mcImplSynthesis.setProbThreshold(0);
596 mcImplSynthesis.setGenerateThreshold(30);
597 Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
599 double timeEndAnalysis = (double) System.nanoTime();
600 if(state.BAMBOOCOMPILETIME) {
601 double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
602 System.err.println("The analysis took" + dt + "sec.");
606 // generate multicore codes
607 if(state.MULTICORE) {
608 BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
613 mcImplSynthesis.getCoreNum(),
615 bcm.setOwnershipAnalysis(oa);
625 // generate multicore codes
626 if(state.MULTICORE) {
627 BuildCodeMGC bcmgc=new BuildCodeMGC(state,
638 if(!state.MULTICORE) {
641 if (state.DSM||state.SINGLETM) {
642 CallGraph callgraph=new CallGraph(state);
643 if (state.PREFETCH) {
644 //speed up prefetch generation using locality analysis results
645 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
646 pa=new PrefetchAnalysis(state, callgraph, tu, la);
648 LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
649 GenerateConversions gc=new GenerateConversions(la, state);
650 bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa);
652 if( state.OOOJAVA ) {
653 bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa);
655 bc=new BuildCode(state, bf.getMap(), tu, sa);
660 State.logEvent("Done With BuildCode");
664 System.out.println("Lines="+state.lines);
668 public static void loadClass(State state, BuildIR bir, String sourcefile) {
670 ParseNode pn=readSourceFile(state, sourcefile);
671 bir.buildtree(pn, null,sourcefile);
672 } catch (Exception e) {
673 System.out.println("Error in sourcefile:"+sourcefile);
677 System.out.println("Error in sourcefile:"+sourcefile);
683 /** Reads in a source file and adds the parse tree to the state object. */
685 public static ParseNode readSourceFile(State state, String sourcefile) {
687 Reader fr= new BufferedReader(new FileReader(sourcefile));
688 Lex.Lexer l = new Lex.Lexer(fr);
689 java_cup.runtime.lr_parser g;
690 g = new Parse.Parser(l);
693 p=(ParseNode) g./*debug_*/parse().value;
694 } catch (Exception e) {
695 System.err.println("Error parsing file:"+sourcefile);
699 state.addParseNode(p);
700 if (l.numErrors()!=0) {
701 System.out.println("Error parsing "+sourcefile);
702 System.exit(l.numErrors());
704 state.lines+=l.line_num;
707 } catch (Exception e) {