import IR.MethodDescriptor;
import IR.TaskDescriptor;
import IR.TypeDescriptor;
+import IR.TypeUtil;
import java.util.*;
import java.io.*;
protected CallGraph() {}
- public CallGraph(State state) {
+ protected TypeUtil typeUtil;
+
+ public CallGraph(State state, TypeUtil typeUtil) {
this.state=state;
+ this.typeUtil=typeUtil;
+
mapVirtual2ImplementationSet = new Hashtable();
mapCaller2CalleeSet = new Hashtable();
mapCallee2CallerSet = new Hashtable();
MethodDescriptor md=(MethodDescriptor)methodit.next();
if (md.isStatic()||md.getReturnType()==null)
continue;
+ Stack<ClassDescriptor> possInterfaces=new Stack<ClassDescriptor>();
+ ClassDescriptor tmpcd=cn;
+ while(tmpcd!=null) {
+ for(Iterator supit=tmpcd.getSuperInterfaces();supit.hasNext();) {
+ possInterfaces.add((ClassDescriptor)supit.next());
+ }
+ tmpcd=tmpcd.getSuperDesc();
+ }
+ while(!possInterfaces.isEmpty()) {
+ ClassDescriptor IFdesc=possInterfaces.pop();
+ for(Iterator supit=IFdesc.getSuperInterfaces();supit.hasNext();) {
+ possInterfaces.add((ClassDescriptor)supit.next());
+ }
+ Set possiblematches=IFdesc.getMethodTable().getSet(md.getSymbol());
+ boolean foundmatch=false;
+ for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
+ MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+ if (md.matches(matchmd)) {
+ if (!mapVirtual2ImplementationSet.containsKey(matchmd))
+ mapVirtual2ImplementationSet.put(matchmd,new HashSet());
+ ((HashSet)mapVirtual2ImplementationSet.get(matchmd)).add(md);
+ break;
+ }
+ }
+ }
+
+
ClassDescriptor superdesc=cn.getSuperDesc();
if (superdesc!=null) {
Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
return ns;
}
+ public boolean isCallable(MethodDescriptor md) {
+ return true;
+ }
+
/** Returns all methods transitively callable from d */
public Set getAllMethods(Descriptor d) {
Descriptor md=(Descriptor)tovisit.iterator().next();
tovisit.remove(md);
Set s=(Set)mapCaller2CalleeSet.get(md);
+
if (s!=null) {
for(Iterator it=s.iterator(); it.hasNext();) {
MethodDescriptor md2=(MethodDescriptor)it.next();
MethodDescriptor calledmethod=fc.getMethod();
Set methodsthatcouldbecalled=fc.getThis()==null ? getMethods(calledmethod) :
getMethods(calledmethod, fc.getThis().getType());
-
+
// add caller -> callee maps
if( !mapCaller2CalleeSet.containsKey(caller) ) {
mapCaller2CalleeSet.put(caller, new HashSet() );
public class JavaCallGraph extends CallGraph {
TypeUtil tu;
+ HashSet discovered;
+
public JavaCallGraph(State state, TypeUtil tu) {
this.state=state;
mapVirtual2ImplementationSet = new Hashtable();
mapCaller2CalleeSet = new Hashtable();
mapCallee2CallerSet = new Hashtable();
+ discovered=new HashSet();
this.tu=tu;
buildVirtualMap();
buildGraph();
}
+ public boolean isCallable(MethodDescriptor md) {
+ return discovered.contains(md);
+ }
+
//Work our way down from main
private void buildGraph() {
MethodDescriptor main=tu.getMain();
HashSet tovisit=new HashSet();
- HashSet discovered=new HashSet();
tovisit.add(main);
discovered.add(main);
+ Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
+
+ while(it.hasNext()) {
+ ClassDescriptor cn=(ClassDescriptor)it.next();
+ Iterator methodit=cn.getMethods();
+ //Iterator through methods
+ while(methodit.hasNext()) {
+ MethodDescriptor md=(MethodDescriptor)methodit.next();
+ if (md.isStaticBlock()) {
+ tovisit.add(md);
+ discovered.add(md);
+ }
+ }
+ }
+
+
while(!tovisit.isEmpty()) {
MethodDescriptor md=(MethodDescriptor)tovisit.iterator().next();
tovisit.remove(md);
FlatMethod fm=state.getMethodFlat(md);
+ if (fm==null)
+ continue;
analyzeMethod(md, fm);
for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
FlatNode fn=fnit.next();
if (fn.kind()==FKind.FlatCall) {
FlatCall fcall=(FlatCall)fn;
Set callees=fcall.getThis()==null?getMethods(fcall.getMethod()):getMethods(fcall.getMethod(),fcall.getThis().getType());
+
+ if (fcall.getThis()!=null) {
+ MethodDescriptor methodd=fcall.getMethod();
+
+ if (methodd.getClassDesc()==tu.getClass(TypeUtil.ThreadClass)&&
+ methodd.getSymbol().equals("start")&&methodd.numParameters()==0&&!methodd.getModifiers().isStatic()) {
+ //Have call to start
+ HashSet ns=new HashSet();
+ ns.addAll(callees);
+ ns.addAll(getMethods(tu.getRun(), fcall.getThis().getType()));
+ callees=ns;
+ }
+ }
+
for(Iterator mdit=callees.iterator();mdit.hasNext();) {
MethodDescriptor callee=(MethodDescriptor)mdit.next();
if (!discovered.contains(callee)) {
int boundschknum = 0;
- public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil) {
- this(st, temptovar, typeutil, null);
+ public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, CallGraph callgraph) {
+ this(st, temptovar, typeutil, null, callgraph);
}
- public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa) {
+ public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, CallGraph callgraph) {
this.sa=sa;
state=st;
- State.logEvent("Start CallGraph");
- callgraph=new CallGraph(state);
- State.logEvent("Finish CallGraph");
+ this.callgraph=callgraph;
this.temptovar=temptovar;
paramstable=new Hashtable();
tempstable=new Hashtable();
fieldorder=new Hashtable();
flagorder=new Hashtable();
this.typeutil=typeutil;
- State.logEvent("CheckMethods");
- checkMethods2Gen();
State.logEvent("Virtual");
- virtualcalls=new Virtual(state, null);
+ virtualcalls=new Virtual(state, null, callgraph);
printedfieldstbl = new Hashtable<String, ClassDescriptor>();
}
State.logEvent("End of buildCode");
}
- /* This method goes though the call graph and check which methods are really
- * invoked and should be generated
- */
- protected void checkMethods2Gen() {
- MethodDescriptor md=(state.main==null)?null:typeutil.getMain();
-
- if(md != null) {
- // check the methods to be generated
- state.setGenAllMethods(false);
- } else {
- // generate all methods
- return;
- }
- this.state.addMethod2gen(md);
-
- Iterator it_classes = this.state.getClassSymbolTable().getDescriptorsIterator();
- while(it_classes.hasNext()) {
- ClassDescriptor cd = (ClassDescriptor)it_classes.next();
- Iterator it_methods = cd.getMethodTable().getDescriptorsIterator();
- while(it_methods.hasNext()) {
- md = (MethodDescriptor)it_methods.next();
- if(md.isStaticBlock() || md.getModifiers().isNative() || this.callgraph.getCallerSet(md).size() > 0
- || (cd.getSymbol().equals("Thread") && md.getSymbol().equals("staticStart"))) {
- this.state.addMethod2gen(md);
- }
- }
- }
- }
-
-
/* This method goes though the call graph and tag those methods that are
* invoked inside static blocks
*/
while(taskit.hasNext()) {
TaskDescriptor td=(TaskDescriptor)taskit.next();
FlatMethod fm=state.getMethodFlat(td);
+
generateFlatMethod(fm, outmethod);
generateTaskDescriptor(outtaskdefs, fm, td);
}
while(methodit.hasNext()) {
/* Classify parameters */
MethodDescriptor md=(MethodDescriptor)methodit.next();
- if(!this.state.genAllMethods) {
- boolean foundmatch = false;
- Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
- for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
- MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
- if (md.matches(matchmd)) {
- foundmatch=true;
- break;
- }
- }
- if(!foundmatch) {
- continue;
- }
- }
+ if (!callgraph.isCallable(md)) {
+ continue;
+ }
+
FlatMethod fm=state.getMethodFlat(md);
if (!md.getModifiers().isNative()) {
generateFlatMethod(fm, outmethod);
MethodDescriptor md=(MethodDescriptor)it.next();
if (md.isStatic()||md.getReturnType()==null)
continue;
- boolean foundmatch = false;
- if(this.state.genAllMethods) {
- foundmatch = true;
- } else {
- Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
- for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
- MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
- if (md.matches(matchmd)) {
- foundmatch=true;
- break;
- }
- }
- }
- if(!foundmatch) {
- continue;
+
+ if (!callgraph.isCallable(md)) {
+ continue;
}
+
int methodnum = virtualcalls.getMethodNumber(md);
virtualtable[rownum][methodnum]=md;
}
protected void generateCallStructsMethods(ClassDescriptor cn, PrintWriter output, PrintWriter headersout) {
for(Iterator methodit=cn.getMethods(); methodit.hasNext(); ) {
MethodDescriptor md=(MethodDescriptor)methodit.next();
- boolean foundmatch = false;
- if(this.state.genAllMethods) {
- foundmatch = true;
- } else {
- Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
- for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
- MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
- if (md.matches(matchmd)) {
- foundmatch=true;
- break;
- }
- }
- }
- if(foundmatch) {
- generateMethod(cn, md, headersout, output);
+
+ if (!callgraph.isCallable(md)) {
+ continue;
}
+
+ generateMethod(cn, md, headersout, output);
}
}
else
output.println(generateTemp(fm, fon.getDest())+" = ((unsigned int)"+generateTemp(fm, fon.getLeft())+")>>"+generateTemp(fm,fon.getRight())+";");
- } else
- output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+ } else {
+ if (fon.getLeft().getType().isPtr()&&fon.getLeft().getType()!=fon.getRight().getType()&&!fon.getRight().getType().isNull())
+ output.println(generateTemp(fm, fon.getDest())+" = (struct "+fon.getRight().getType().getSafeSymbol()+"*)"+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+ else
+ output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+ }
} else if (fon.getOp().getOp()==Operation.ASSIGN)
- output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
+ if (fon.getDest().getType().isPtr()&&fon.getDest().getType()!=fon.getLeft().getType())
+ output.println(generateTemp(fm, fon.getDest())+" = (struct "+fon.getDest().getType().getSafeSymbol()+"*)"+generateTemp(fm, fon.getLeft())+";");
+ else
+ output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
else if (fon.getOp().getOp()==Operation.UNARYPLUS)
output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
else if (fon.getOp().getOp()==Operation.UNARYMINUS)
import java.util.Iterator;
import Analysis.TaskStateAnalysis.SafetyAnalysis;
+import Analysis.CallGraph.CallGraph;
import IR.ClassDescriptor;
import IR.MethodDescriptor;
import IR.State;
SafetyAnalysis sa,
int coreNum,
int tcoreNum,
- int gcoreNum) {
- super(st, temptovar, typeutil, sa);
+ int gcoreNum, CallGraph callgraph) {
+ super(st, temptovar, typeutil, sa, callgraph);
this.coreNum = coreNum; // # of the active cores
this.tcoreNum = tcoreNum; // # of the total number of cores
this.gcoreNum = gcoreNum; // # of the cores for gc if any
import Analysis.OwnershipAnalysis.OwnershipAnalysis;
import Analysis.OwnershipAnalysis.HeapRegionNode;
import Analysis.Prefetch.*;
+import Analysis.CallGraph.CallGraph;
import IR.ClassDescriptor;
import IR.Descriptor;
import IR.FlagDescriptor;
SafetyAnalysis sa,
Vector<Schedule> scheduling,
int coreNum,
- int gcoreNum) {
- super(st, temptovar, typeutil, sa);
+ int gcoreNum, CallGraph callgraph) {
+ super(st, temptovar, typeutil, sa, callgraph);
this.scheduling = scheduling;
this.coreNum = coreNum; // # of the active cores
this.tcoreNum = coreNum; // # of the cores setup by users
LocalityBinding currlb;
- public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) {
- this(st, temptovar, typeutil, null, sa, pa);
+ public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, CallGraph callgraph) {
+ this(st, temptovar, typeutil, null, sa, pa, callgraph);
}
- public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa) {
- this(st, temptovar, typeutil, locality, null, pa);
+ public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, CallGraph callgraph) {
+ this(st, temptovar, typeutil, locality, null, pa, callgraph);
}
- public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa) {
- super(st, temptovar, typeutil, sa);
+ public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, CallGraph callgraph) {
+ super(st, temptovar, typeutil, sa, callgraph);
this.sa=sa;
+ this.virtualcalls=new Virtual(state, locality, callgraph);
if (state.SINGLETM)
oidstr="___objlocation___";
if (locality!=null) {
Hashtable temptovar,
TypeUtil typeutil,
SafetyAnalysis sa,
- OoOJavaAnalysis oooa
+ OoOJavaAnalysis oooa, CallGraph callgraph
) {
- super( st, temptovar, typeutil, sa);
+ super( st, temptovar, typeutil, sa, callgraph);
this.oooa = oooa;
}
import java.util.*;
import Analysis.TaskStateAnalysis.*;
+import Analysis.CallGraph.CallGraph;
public class State {
public static long startTime;
this.sclasses=new SymbolTable();
this.treemethodmap=new Hashtable();
this.flatmethodmap=new Hashtable();
- this.genAllMethods = true;
- this.methods2gen = new SymbolTable();
this.parsetrees=new HashSet();
this.arraytypes=new HashSet();
this.arraytonumber=new Hashtable();
public Hashtable treemethodmap;
public Hashtable flatmethodmap;
SymbolTable methods2gen;
- public boolean genAllMethods;
private HashSet arraytypes;
public Hashtable arraytonumber;
private int numclasses=1; // start from 1 instead of 0 for multicore gc
}
}
- public void setGenAllMethods(boolean flag) {
- this.genAllMethods = flag;
- }
-
- public void addMethod2gen(MethodDescriptor md) {
- if(this.genAllMethods) {
- throw new Error("The state.genAllMethods is TRUE, do not need to check methods to genenrate");
- }
- this.methods2gen.add(md);
- }
-
- public SymbolTable getMethod2gen() {
- return this.methods2gen;
- }
-
public int numClasses() {
return numclasses;
}
BuildIR bir;
// for interfaces
- Hashtable superIFtbl;
+ Hashtable<ClassDescriptor, Set<ClassDescriptor>> superIFtbl;
public TypeUtil(State state, BuildIR bir) {
this.state=state;
supertable.put(cd,cd_super);
}
}
- if (!this.superIFtbl.containsKey(cd)) {
+ if (!superIFtbl.containsKey(cd)) {
// add inherited interfaces
superIFtbl.put(cd,new HashSet());
HashSet hs=(HashSet)superIFtbl.get(cd);
private void createTables() {
supertable=new Hashtable();
- superIFtbl = new Hashtable();
+ superIFtbl = new Hashtable<ClassDescriptor,Set<ClassDescriptor>>();
}
public ClassDescriptor getMainClass() {
return (ClassDescriptor)supertable.get(cd);
}
- public Set getSuperIFs(ClassDescriptor cd) {
- return (Set)this.superIFtbl.get(cd);
+ public Set<ClassDescriptor> getSuperIFs(ClassDescriptor cd) {
+ return superIFtbl.get(cd);
}
public boolean isCastable(TypeDescriptor original, TypeDescriptor casttype) {
{
// check cd2's interface ancestors
- Iterator it_sifs = getSuperIFs(cd2).iterator();
+ Iterator<ClassDescriptor> it_sifs = getSuperIFs(cd2).iterator();
while(it_sifs.hasNext()) {
- ClassDescriptor cd = (ClassDescriptor)it_sifs.next();
+ ClassDescriptor cd = it_sifs.next();
if(cd == possiblesuper) {
return true;
} else if(!tovisit.contains(cd)){
import Analysis.Locality.LocalityBinding;
import Analysis.Locality.LocalityAnalysis;
-
+import Analysis.CallGraph.CallGraph;
public class Virtual {
State state;
Hashtable<MethodDescriptor, Integer> methodnumber;
Hashtable<ClassDescriptor, Integer> classmethodcount;
Hashtable<LocalityBinding, Integer> localitynumber;
-
+ CallGraph callgraph;
+
// for interfaces
int if_starts;
SymbolTable if_methods;
return localitynumber.get(lb).intValue();
}
- public Virtual(State state, LocalityAnalysis locality) {
+ public Virtual(State state, LocalityAnalysis locality, CallGraph callgraph) {
this.state=state;
this.locality=locality;
this.if_starts = 0;
this.if_methods = new SymbolTable();
+ this.callgraph=callgraph;
classmethodcount=new Hashtable<ClassDescriptor, Integer>();
if (state.DSM||state.SINGLETM)
localitynumber=new Hashtable<LocalityBinding, Integer>();
MethodDescriptor md=(MethodDescriptor)it.next();
if (md.isStatic()||md.getReturnType()==null)
continue;
- boolean foundmatch = false;
- if(this.state.genAllMethods) {
- foundmatch = true;
- } else {
- Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
- for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
- MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
- if (md.matches(matchmd)) {
- foundmatch=true;
- break;
- }
- }
- }
- if(!foundmatch) {
- continue;
- }
- foundmatch=false;
+
+ if (!callgraph.isCallable(md))
+ continue;
+ boolean foundmatch=false;
// check if there is a matched method that has been assigned method num
Set possiblematches_if = if_methods.getSet(md.getSymbol());
for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
break;
}
}
- if(!foundmatch) {
- methodnumber.put(md, new Integer(if_starts++));
- if_methods.add(md);
- mnum++;
+ if (!foundmatch) {
+ methodnumber.put(md, new Integer(if_starts++));
+ if_methods.add(md);
+ mnum++;
}
}
classmethodcount.put(cd, new Integer(mnum));
mnum = numberMethods(superdesc);
start += mnum;
}
+ methodit:
for(Iterator it=cd.getMethods(); it.hasNext();) {
MethodDescriptor md=(MethodDescriptor)it.next();
if (md.isStatic()||md.getReturnType()==null)
continue;
- boolean foundmatch = false;
- if(this.state.genAllMethods) {
- foundmatch = true;
- } else {
- Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
- for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
- MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
- if (md.matches(matchmd)) {
- foundmatch=true;
- break;
- }
- }
- }
- if(!foundmatch) {
- continue;
- }
- foundmatch=false;
+ if (!callgraph.isCallable(md))
+ continue;
// check if there is a matched method in methods defined in interfaces
Set possiblematches_if=if_methods.getSet(md.getSymbol());
for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
if (md.matches(matchmd)) {
- int num = methodnumber.get(matchmd);
+ int num;
+ if (!methodnumber.containsKey(matchmd)) {
+ num=start++;
+ mnum++;
+ methodnumber.put(matchmd,num);
+ } else
+ num = methodnumber.get(matchmd);
methodnumber.put(md, new Integer(num));
- foundmatch=true;
- break;
+ continue methodit;
}
}
- if (!foundmatch && superdesc!=null) {
+ if (superdesc!=null) {
Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
if (md.matches(matchmd)) {
- int num = methodnumber.get(matchmd);
+ int num;
+ if (!methodnumber.containsKey(matchmd)) {
+ num=start++;
+ mnum++;
+ methodnumber.put(matchmd,num);
+ } else
+ num = methodnumber.get(matchmd);
methodnumber.put(md, new Integer(num));
- foundmatch=true;
- break;
+ continue methodit;
}
}
}
- if (!foundmatch) {
- methodnumber.put(md, new Integer(start++));
- mnum++;
- }
+
+ methodnumber.put(md, new Integer(start++));
+ mnum++;
}
classmethodcount.put(cd, new Integer(mnum));
return mnum;
import Analysis.TaskStateAnalysis.TaskTagAnalysis;
import Analysis.TaskStateAnalysis.TaskGraph;
import Analysis.CallGraph.CallGraph;
+import Analysis.CallGraph.JavaCallGraph;
import Analysis.TaskStateAnalysis.FEdge;
import Analysis.TaskStateAnalysis.FlagState;
import Analysis.TaskStateAnalysis.TagAnalysis;
startnum = Integer.parseInt(args[++i]);
else if (option.equals("-useprofile")) {
state.USEPROFILE=true;
- state.profilename = args[++i];
+ state.profilename = args[++i];
}
else if (option.equals("-thread"))
state.THREAD=true;
else if (option.equals("-dsm"))
state.DSM=true;
else if (option.equals("-recoverystats"))
- state.DSMRECOVERYSTATS=true;
+ state.DSMRECOVERYSTATS=true;
else if (option.equals("-dsmtask"))
- state.DSMTASK=true;
+ state.DSMTASK=true;
else if (option.equals("-singleTM"))
state.SINGLETM=true;
else if (option.equals("-readset"))
state.RCR_DEBUG = true;
state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
} else if (option.equals("-rcr_debug_verbose")){
- state.RCR_DEBUG_VERBOSE = true;
- state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
+ state.RCR_DEBUG_VERBOSE = true;
+ state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
} else if (option.equals("-nostalltr")){
state.NOSTALLTR = true;
} else if (option.equals("-ssjava")){
- state.SSJAVA = true;
+ state.SSJAVA = true;
} else if (option.equals("-printlinenum")){
- state.LINENUM=true;
+ state.LINENUM=true;
}else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
}
+
BuildFlat bf=new BuildFlat(state,tu);
bf.buildFlat();
State.logEvent("Done Building Flat");
}
}
+ CallGraph callgraph=state.TASK?new CallGraph(state, tu):new JavaCallGraph(state, tu);
+
if (state.OPTIMIZE) {
- CallGraph callgraph=new CallGraph(state);
CopyPropagation cp=new CopyPropagation();
DeadCode dc=new DeadCode();
GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
}
if (state.OWNERSHIP) {
- CallGraph callGraph = new CallGraph(state);
Liveness liveness = new Liveness();
ArrayReferencees ar = new ArrayReferencees(state);
OwnershipAnalysis oa = new OwnershipAnalysis(state,
tu,
- callGraph,
+ callgraph,
liveness,
ar,
state.OWNERSHIPALLOCDEPTH,
}
if (state.DISJOINT && !state.OOOJAVA) {
- CallGraph cg = new CallGraph(state);
Liveness l = new Liveness();
ArrayReferencees ar = new ArrayReferencees(state);
- DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null);
+ DisjointAnalysis da = new DisjointAnalysis(state, tu, callgraph, l, ar, null, null);
}
if (state.OOOJAVA) {
- CallGraph cg = new CallGraph(state);
Liveness l = new Liveness();
ArrayReferencees ar = new ArrayReferencees(state);
- oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
+ oooa = new OoOJavaAnalysis(state, tu, callgraph, l, ar);
}
if (state.TAGSTATE) {
- CallGraph callgraph=new CallGraph(state);
TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
}
if (state.TASKSTATE) {
- CallGraph callgraph=new CallGraph(state);
TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
ta.taskAnalysis();
if (state.SCHEDULING) {
// Use ownership analysis to get alias information
- CallGraph callGraph = new CallGraph(state);
Liveness liveness = new Liveness();
ArrayReferencees ar = new ArrayReferencees(state);
OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
System.exit(0);
}
- // generate multicore codes
- if(state.MULTICORE) {
- BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
- bf.getMap(),
- tu,
- sa,
- scheduling,
- mcImplSynthesis.getCoreNum(),
- state.CORENUM4GC);
- bcm.setOwnershipAnalysis(oa);
- bcm.buildCode();
- }
- scheduling.clear();
- scheduling = null;
+ // generate multicore codes
+ if(state.MULTICORE) {
+ BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
+ bf.getMap(),
+ tu,
+ sa,
+ scheduling,
+ mcImplSynthesis.getCoreNum(),
+ state.CORENUM4GC, callgraph);
+ bcm.setOwnershipAnalysis(oa);
+ bcm.buildCode();
+ }
+ scheduling.clear();
+ scheduling = null;
}
}
}
sa,
state.CORENUM,
state.CORENUM,
- state.CORENUM4GC);
+ state.CORENUM4GC, callgraph);
bcmgc.buildCode();
}
}
BuildCode bc;
if (state.DSM||state.SINGLETM) {
- CallGraph callgraph=new CallGraph(state);
if (state.PREFETCH) {
//speed up prefetch generation using locality analysis results
LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
}
LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
GenerateConversions gc=new GenerateConversions(la, state);
- bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa);
+ bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa, callgraph);
} else {
if( state.OOOJAVA ) {
- bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa);
+ bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa, callgraph);
} else {
- bc=new BuildCode(state, bf.getMap(), tu, sa);
+ bc=new BuildCode(state, bf.getMap(), tu, sa, callgraph);
}
}
#include "structdefs.h"
#include "mem.h"
#include "runtime.h"
+#include "methodheaders.h"
+#ifdef D___FileOutputStream______nativeWrite____I__AR_B_I_I
void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off, int len, int fd, struct ArrayObject * ___array___, int off, int len) {
#ifdef MULTICORE
#else
int status=write(fd, &string[off], len);
#endif
}
+#endif
+#ifdef D___FileOutputStream______nativeClose____I
void CALL11(___FileOutputStream______nativeClose____I, int fd, int fd) {
#ifdef MULTICORE
#else
close(fd);
#endif
}
+#endif
+#ifdef D___FileOutputStream______nativeFlush____I
void CALL11(___FileOutputStream______nativeFlush____I, int fd, int fd) {
// not supported in RAW version
#ifdef MULTICORE
fsync(fd);
#endif
}
+#endif
+#ifdef D___FileOutputStream______nativeOpen_____AR_B
int CALL01(___FileOutputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
#ifdef MULTICORE
return 0;
return fd;
#endif
}
+#endif
+#ifdef D___FileOutputStream______nativeAppend_____AR_B
int CALL01(___FileOutputStream______nativeAppend_____AR_B, struct ArrayObject * ___filename___) {
#ifdef MULTICORE
return 0;
return fd;
#endif
}
+#endif
+#ifdef D___FileInputStream______nativeOpen_____AR_B
int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
#ifdef MULTICORE
return 0;
return fd;
#endif
}
+#endif
+#ifdef D___FileInputStream______nativeClose____I
void CALL11(___FileInputStream______nativeClose____I, int fd, int fd) {
#ifdef MULTICORE
#else
close(fd);
#endif
}
+#endif
+#ifdef D___FileInputStream______nativeRead____I__AR_B_I
int CALL23(___FileInputStream______nativeRead____I__AR_B_I, int fd, int numBytes, int fd, struct ArrayObject * ___array___, int numBytes) {
#ifdef MULTICORE
return -1;
return status;
#endif
}
+#endif
+#ifdef D___FileInputStream______nativePeek____I
int CALL11(___FileInputStream______nativePeek____I, int fd, int fd) {
#ifdef MULTICORE
return 0;
return string[0];
#endif
}
+#endif
+#ifdef D___File______nativeLength_____AR_B
long long CALL01(___File______nativeLength_____AR_B, struct ArrayObject * ___pathname___) {
#ifdef MULTICORE
return 0;
return st.st_size;
#endif
}
+#endif
#include "math.h"
#include "structdefs.h"
+#ifdef D___Math______cos____D
double CALL11(___Math______cos____D, double ___a___, double ___a___) {
return cos(___a___);
}
+#endif
+#ifdef D___Math______sin____D
double CALL11(___Math______sin____D, double ___a___, double ___a___) {
return sin(___a___);
}
+#endif
+#ifdef D___Math______tan____D
double CALL11(___Math______tan____D, double ___a___, double ___a___) {
return tan(___a___);
}
+#endif
+#ifdef D___Math______acos____D
double CALL11(___Math______acos____D, double ___a___, double ___a___) {
return acos(___a___);
}
+#endif
+#ifdef D___Math______asin____D
double CALL11(___Math______asin____D, double ___a___, double ___a___) {
return asin(___a___);
}
+#endif
+#ifdef D___Math______atan____D
double CALL11(___Math______atan____D, double ___a___, double ___a___) {
return atan(___a___);
}
+#endif
+#ifdef D___Math______atan2____D_D
double CALL22(___Math______atan2____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
return atan2(___a___,___b___);
}
+#endif
+#ifdef D___Math______log____D
double CALL11(___Math______log____D, double ___a___, double ___a___) {
return log(___a___);
}
+#endif
+#ifdef D___Math______exp____D
double CALL11(___Math______exp____D, double ___a___, double ___a___) {
return exp(___a___);
}
+#endif
+#ifdef D___Math______sqrt____D
double CALL11(___Math______sqrt____D, double ___a___, double ___a___) {
return sqrt(___a___);
}
+#endif
+#ifdef D___Math______pow____D_D
double CALL22(___Math______pow____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
return pow(___a___,___b___);
}
+#endif
+#ifdef D___Math______ceil____D
double CALL11(___Math______ceil____D, double ___a___, double ___a___) {
return ceil(___a___);
}
+#endif
+#ifdef D___Math______floor____D
double CALL11(___Math______floor____D, double ___a___, double ___a___) {
return floor(___a___);
}
+#endif
+#ifdef D___Math______cosf____F
float CALL11(___Math______cosf____F, float ___a___, float ___a___) {
return cosf(___a___);
}
+#endif
+#ifdef D___Math______sinf____F
float CALL11(___Math______sinf____F, float ___a___, float ___a___) {
return sinf(___a___);
}
+#endif
+#ifdef D___Math______expf____F
float CALL11(___Math______expf____F, float ___a___, float ___a___) {
return expf(___a___);
}
+#endif
+#ifdef D___Math______sqrtf____F
float CALL11(___Math______sqrtf____F, float ___a___, float ___a___) {
return sqrtf(___a___);
}
+#endif
+#ifdef D___Math______logf____F
float CALL11(___Math______logf____F, float ___a___, float ___a___) {
return logf(___a___);
}
+#endif
+#ifdef D___Math______powf____F_F
float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
return powf(___a___,___b___);
}
+#endif
+#ifdef D___Math______ceilf____F
float CALL11(___Math______ceilf____F, float ___a___, float ___a___) {
return ceilf(___a___);
}
+#endif
+#ifdef D___Math______IEEEremainder____F_F
float CALL22(___Math______IEEEremainder____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
return fmod(___a___, ___b___);
}
-
+#endif
}
#endif
+#ifdef D___Object______getType____
int CALL01(___Object______getType____, struct ___Object___ * ___this___) {
return ((int *)VAR(___this___))[0];
}
+#endif
#ifdef THREADS
+#ifdef D___Object______MonitorEnter____
int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
#ifndef NOLOCK
pthread_t self=pthread_self();
}
#endif
}
+#endif
+
#ifdef D___Object______notify____
void CALL01(___Object______notify____, struct ___Object___ * ___this___) {
}
#endif
+
#ifdef D___Object______notifyAll____
void CALL01(___Object______notifyAll____, struct ___Object___ * ___this___) {
}
#endif
+
#ifdef D___Object______wait____
void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
pthread_t self=pthread_self();
}
#endif
+#ifdef D___Object______MonitorExit____
int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
#ifndef NOLOCK
pthread_t self=pthread_self();
#endif
}
#endif
+#endif
#ifdef D___Object______hashCode____
int CALL01(___Object______hashCode____, struct ___Object___ * ___this___);
#endif
-int CALL01(___Object______getType____, struct ___Object___ * ___this___);
#ifdef THREADS
int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___);
int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___);
return 1024*1024*1024;
}
#endif
-
+#ifdef D___System______exit____I
void CALL11(___System______exit____I,int ___status___, int ___status___) {
#ifdef TRANSSTATS
#ifndef RECOVERY
#endif
exit(___status___);
}
+#endif
+#ifdef D___System______logevent____I
void CALL11(___System______logevent____I,int ___event___, int ___event___) {
#ifdef STMLOG
event[counter] = ___event___;
#endif
return;
}
+#endif
+#ifdef ___System______logevent____
void CALL00(___System______logevent____) {
#ifdef STMLOG
beginClock= rdtsc();
#endif
return;
}
+#endif
+#ifdef ___System______flushToFile____I
void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid___) {
#ifdef STMLOG
FILE *fp;
#endif
return;
}
+#endif
+#ifdef D___System______initLog____
void CALL00(___System______initLog____) {
#ifdef STMLOG
counter=0;
#endif
return;
}
+#endif
#ifdef D___Vector______removeElement_____AR_L___Object____I_I
void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) {
}
#endif
+#ifdef D___System______printI____I
void CALL11(___System______printI____I,int ___status___, int ___status___) {
printf("%d\n",___status___);
}
+#endif
+#ifdef D___System______currentTimeMillis____
long long CALL00(___System______currentTimeMillis____) {
struct timeval tv; long long retval;
gettimeofday(&tv, NULL);
retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
return retval;
}
+#endif
#ifdef D___System______gc____
void CALL00(___System______gc____) {
}
#endif
+#ifdef D___System______microTimes____
long long CALL00(___System______microTimes____) {
struct timeval tv;
long long retval;
retval+= (tv.tv_usec); /* adjust microseconds & add them in */
return retval;
}
+#endif
+#ifdef D___System______getticks____
long long CALL00(___System______getticks____) {
unsigned a, d;
asm("cpuid");
asm volatile("rdtsc" : "=a" (a), "=d" (d));
return (((ticks)a) | (((ticks)d) << 32));
}
+#endif
+#ifdef D___System______printString____L___String___
void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
struct ArrayObject * chararray=VAR(___s___)->___value___;
int i;
fflush(stdout);
#endif
}
+#endif
#ifdef D___RecoveryStat______printRecoveryStat____
#ifdef RECOVERYSTATS
#endif
#ifdef DSTM
+#ifdef D___System______clearPrefetchCache____
void CALL00(___System______clearPrefetchCache____) {
prehashClear();
}
+#endif
#ifdef RANGEPREFETCH
+#ifdef D___System______rangePrefetch____L___Object_____AR_S
void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Object___ * ___o___, struct ArrayObject * ___offsets___) {
/* Manual Prefetches to be inserted */
//printf("DEBUG-> %s() ___Object___ * ___o___ = %x\n", __func__, VAR(___o___));
return;
}
#endif
+#endif
#ifdef D___Task______execution____
extern void* virtualtable[];
struct RuntimeHash *fdtoobject;
+#ifdef D___Socket______nativeConnect____I__AR_B_I
int CALL24(___Socket______nativeConnect____I__AR_B_I, int ___fd___, int ___port___, struct ___Socket___ * ___this___, int ___fd___, struct ArrayObject * ___address___,int ___port___) {
#ifdef MULTICORE
// not supported in MULTICORE version
return -1;
#endif
}
+#endif
#ifdef TASK
+#ifdef D___Socket______nativeBindFD____I
int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
#ifdef MULTICORE
#else
return 0;
}
#endif
+#endif
-
+#ifdef D___Socket______nativeBind_____AR_B_I
int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___, struct ArrayObject * ___address___, int ___port___) {
#ifdef MULTICORE
// not supported in MULTICORE version
#endif
#endif
}
+#endif
+#ifdef D___InetAddress______getHostByName_____AR_B
struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct ArrayObject * ___hostname___) {
#ifdef MULTICORE
// not supported in MULTICORE version
}
#endif
}
+#endif
-
+#ifdef D___ServerSocket______createSocket____I
int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSocket___ * ___this___, int port) {
#ifdef MULTICORE
// not supported in MULTICORE version
return fd;
#endif
}
+#endif
+#ifdef D___ServerSocket______nativeaccept____L___Socket___
int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSocket___ * ___this___, struct ___Socket___ * ___s___) {
#ifdef MULTICORE
// not supported in MULTICORE version
return newfd;
#endif
}
+#endif
+#ifdef D___Socket______nativeWrite_____AR_B_I_I
void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, struct ___Socket___ * ___this___, struct ArrayObject * ___b___, int offset, int length) {
#ifdef MULTICORE
#else
}
#endif
}
+#endif
+
+#ifdef D___Socket______nativeRead_____AR_B
int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___, struct ArrayObject * ___b___) {
#ifdef MULTICORE
return -1;
return byteread;
#endif
}
+#endif
+#ifdef D___Socket______nativeClose____
void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
#ifdef MULTICORE
#else
close(fd);
#endif
}
+#endif
#include "thread.h"
#include "option.h"
#include <signal.h>
+#include "methodheaders.h"
#ifdef DSTM
#ifdef RECOVERY
}
#endif
+#ifdef D___Thread______sleep____J
void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) {
#if defined(THREADS)||defined(STM)
#ifdef PRECISE_GC
#endif
#endif
}
+#endif
-#if defined(DSTM)|| defined(THREADS)||defined(STM)
+#ifdef D___Thread______yield____
void CALL00(___Thread______yield____) {
pthread_yield();
}
#ifdef DSTM
#ifdef RECOVERY
// return if the machine is dead
+#ifdef D___Thread______nativeGetStatus____I
int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
return getStatus(___mid___);
}
+#endif
#else
+#ifdef D___Thread______nativeGetStatus____I
int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
return 0;
}
#endif
#endif
+#endif
#ifdef DSTM
/* Add thread join capability */
+#ifdef D___Thread______join____
void CALL01(___Thread______join____, struct ___Thread___ * ___this___) {
unsigned int *oidarray;
unsigned short *versionarray, version;
return;
}
#endif
+#endif
#if defined(THREADS)||defined(STM)
+#ifdef D___Thread______nativeJoin____
void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) {
pthread_mutex_lock(&joinlock);
while(!VAR(___this___)->___finished___) {
}
pthread_mutex_unlock(&joinlock);
}
+#endif
+#ifdef D___Thread______nativeCreate____
void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
pthread_t thread;
int retval;
pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
INTPTR stacksize;
pthread_attr_getstacksize(&nattr, &stacksize);
- printf("STACKSIZE=%u\n",stacksize);
do {
retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
if (retval!=0)
pthread_attr_destroy(&nattr);
}
#endif
+#endif
#ifdef DSTM
+#ifdef D___Thread______start____I
void CALL12(___Thread______start____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
startRemoteThread((unsigned int)VAR(___this___), ___mid___);
}
#endif
+#endif
#ifdef DSTM
void globalDestructor(void *value) {