}
return liveoutmap;
}
+
+
+ // Also allow an instantiation of this object that memoizes results
+ protected Hashtable< FlatMethod, Hashtable< FlatNode, Set<TempDescriptor> > > fm2liveMap;
+
+ public Liveness() {
+ fm2liveMap = new Hashtable< FlatMethod, Hashtable< FlatNode, Set<TempDescriptor> > >();
+ }
+
+ public Set<TempDescriptor> getLiveInTemps( FlatMethod fm, FlatNode fn ) {
+ if( !fm2liveMap.containsKey( fm ) ) {
+ fm2liveMap.put( fm, Liveness.computeLiveTemps( fm ) );
+ }
+ return fm2liveMap.get( fm ).get( fn );
+ }
}
\ No newline at end of file
package Analysis.MLP;
import Analysis.CallGraph.*;
+import Analysis.Liveness;
import Analysis.OwnershipAnalysis.*;
import IR.*;
import IR.Flat.*;
// disjoint analysis with a set of flagged allocation sites of live-in variable
try {
- OwnershipAnalysis oa2 = new OwnershipAnalysis(state, tu, callGraph,
+ OwnershipAnalysis oa2 = new OwnershipAnalysis(state, tu, callGraph, new Liveness(),
state.OWNERSHIPALLOCDEPTH, false,
false, state.OWNERSHIPALIASFILE,
state.METHODEFFECTS,
package Analysis.OwnershipAnalysis;
import Analysis.CallGraph.*;
+import Analysis.Liveness;
import IR.*;
import IR.Flat.*;
import IR.Tree.Modifiers;
// data from the compiler
public State state;
public CallGraph callGraph;
+ public Liveness liveness;
public TypeUtil typeUtil;
public int allocationDepth;
public OwnershipAnalysis(State state,
TypeUtil tu,
CallGraph callGraph,
+ Liveness liveness,
int allocationDepth,
boolean writeDOTs,
boolean writeAllDOTs,
String aliasFile) throws java.io.IOException {
this.methodEffects = false;
- init(state,tu,callGraph,allocationDepth,writeDOTs,writeAllDOTs,aliasFile);
+ init(state,tu,callGraph,liveness,allocationDepth,writeDOTs,writeAllDOTs,aliasFile);
}
public OwnershipAnalysis(State state,
- TypeUtil tu,
- CallGraph callGraph,
- int allocationDepth,
- boolean writeDOTs,
- boolean writeAllDOTs,
- String aliasFile,
- boolean methodEffects) throws java.io.IOException {
+ TypeUtil tu,
+ CallGraph callGraph,
+ Liveness liveness,
+ int allocationDepth,
+ boolean writeDOTs,
+ boolean writeAllDOTs,
+ String aliasFile,
+ boolean methodEffects) throws java.io.IOException {
this.methodEffects = methodEffects;
- init(state,tu,callGraph,allocationDepth,writeDOTs,writeAllDOTs,aliasFile);
+ init(state,tu,callGraph,liveness,allocationDepth,writeDOTs,writeAllDOTs,aliasFile);
}
State state,
TypeUtil tu,
CallGraph callGraph,
+ Liveness liveness,
int allocationDepth,
boolean writeDOTs,
boolean writeAllDOTs,
this.methodEffects = methodEffects;
this.mapMethodContextToLiveInAllocationSiteSet=mapMethodContextToLiveInAllocationSiteSet;
- init(state, tu, callGraph, allocationDepth, writeDOTs, writeAllDOTs,
+ init(state, tu, callGraph, liveness, allocationDepth, writeDOTs, writeAllDOTs,
aliasFile);
}
private void init(State state,
- TypeUtil tu,
- CallGraph callGraph,
- int allocationDepth,
- boolean writeDOTs,
- boolean writeAllDOTs,
- String aliasFile) throws java.io.IOException {
+ TypeUtil tu,
+ CallGraph callGraph,
+ Liveness liveness,
+ int allocationDepth,
+ boolean writeDOTs,
+ boolean writeAllDOTs,
+ String aliasFile) throws java.io.IOException {
analysisComplete = false;
this.state = state;
this.typeUtil = tu;
this.callGraph = callGraph;
+ this.liveness = liveness;
this.allocationDepth = allocationDepth;
this.writeDOTs = writeDOTs;
this.writeAllDOTs = writeAllDOTs;
meAnalysis.createNewMapping(mc);
- og = analyzeFlatNode(mc, fm, null, og);
+ og = analyzeFlatNode(mc, fm, fm, null, og);
setGraphForMethodContext(mc, og);
}
// ownership graph made from the merge of the
// parent graphs
og = analyzeFlatNode(mc,
+ flatm,
fn,
returnNodesToCombineForCompleteOwnershipGraph,
og);
private OwnershipGraph
analyzeFlatNode(MethodContext mc,
+ FlatMethod fmContaining,
FlatNode fn,
HashSet<FlatReturnNode> setRetNodes,
OwnershipGraph og) throws java.io.IOException {
+
+
+ // any variables that are no longer live should be
+ // nullified in the graph to reduce edges
+ // NOTE: it is not clear we need this. It costs a
+ // liveness calculation for every method, so only
+ // turn it on if we find we actually need it.
+ //og.nullifyDeadVars( liveness.getLiveInTemps( fmContaining, fn ) );
+
TempDescriptor lhs;
TempDescriptor rhs;
setRetNodes.add(frn);
break;
}
+
Hashtable<FlatNode, OwnershipGraph> table=mapMethodContextToFlatNodeOwnershipGraph.get(mc);
if(table==null){
public Hashtable<Integer, TokenTuple> paramIndex2paramTokenSecondaryStar;
+
+
+
public OwnershipGraph() {
id2hrn = new Hashtable<Integer, HeapRegionNode>();
// of the nodes and edges involved.
//
////////////////////////////////////////////////////
+
+ public void nullifyDeadVars( Set<TempDescriptor> liveIn ) {
+
+ // make a set of the temps that are out of scope, don't
+ // consider them when nullifying dead in-scope variables
+ Set<TempDescriptor> outOfScope = new HashSet<TempDescriptor>();
+ outOfScope.add( tdReturn );
+ outOfScope.add( tdAliasBlob );
+ outOfScope.addAll( paramIndex2tdQ.values() );
+ outOfScope.addAll( paramIndex2tdR.values() );
+
+ Iterator varItr = td2ln.entrySet().iterator();
+ while( varItr.hasNext() ) {
+ Map.Entry me = (Map.Entry) varItr.next();
+ TempDescriptor td = (TempDescriptor) me.getKey();
+ LabelNode ln = (LabelNode) me.getValue();
+
+ // if this variable is not out-of-scope or live
+ // in graph, nullify its references to anything
+ if( !outOfScope.contains( td ) &&
+ !liveIn.contains( td )
+ ) {
+ clearReferenceEdgesFrom( ln, null, null, true );
+ }
+ }
+ }
+
+
public void assignTempXEqualToTempY(TempDescriptor x,
TempDescriptor y) {
--- /dev/null
+\documentclass{article}
+\begin{document}
+
+Nullfy dead means to remove references from variables when they are no
+longer live.
+
+\section{Analysis without Nullify Dead}
+\begin{tabular}{|l|l|r|r|r|}
+\hline
+Benchmark & Sharing & Time (s) & Lines & Methods \\
+\hline
+Bank & 0 & 6.20 & 1827 & 67 \\
+Chat & 3 & 5.84 & 1512 & 71 \\
+Conglomerator & 0 & 3.84 & 1981 & 93 \\
+jHTTPp2 & 0 & 5.65 & 2585 & 122 \\
+MapReduce1 & 2 & 11.96 & 2276 & 114 \\
+MultiGame & 10 & 30.89 & 3005 & 46 \\
+Performance & 0 & 2.65 & 1762 & 30 \\
+PERT & 0 & 3.20 & 1952 & 61 \\
+FilterBank & 0 & 1.23 & 1323 & 9 \\
+Fractal & 1 & 1.43 & 1336 & 8 \\
+MolDynamics & 2 & 7.96 & 1904 & 31 \\
+MonteCarlo & 0 & 4.10 & 3544 & 49 \\
+Series & 0 & 1.24 & 1407 & 10 \\
+KMeans & 2 & 5.24 & 2661 & 45 \\
+MapReduce2 & 3 & 20.39 & 2220 & 95 \\
+FluidAnimate & 2 & 1045.30 & 3589 & 82 \\
+Spider1 & 0 & 7.01 & 1595 & 80 \\
+Spider2 & 0 & 7.62 & 1599 & 83 \\
+TileSearch & 0 & 8.24 & 2052 & 34 \\
+TicTacToe & 0 & 4.15 & 1534 & 68 \\
+WebServer1 & 0 & 7.81 & 1858 & 97 \\
+WebServer2 & 0 & 8.03 & 1857 & 100 \\
+\hline
+\end{tabular}
+
+
+\section{Using Nullify Dead}
+\begin{tabular}{|l|l|r|r|r|}
+\hline
+Benchmark & Sharing & Time (s) & Lines & Methods \\
+\hline
+Bank & 0 & 5.70 & 1827 & 67 \\
+Chat & 3 & 5.60 & 1512 & 71 \\
+Conglomerator & 0 & 5.42 & 1981 & 93 \\
+jHTTPp2 & 0 & 6.45 & 2585 & 122 \\
+MapReduce1 & 2 & 11.68 & 2276 & 114 \\
+MultiGame & 10 & 22.27 & 3005 & 46 \\
+Performance & 0 & 2.74 & 1762 & 30 \\
+PERT & 0 & 4.24 & 1952 & 61 \\
+FilterBank & 0 & 1.56 & 1323 & 9 \\
+Fractal & 1 & 1.26 & 1336 & 8 \\
+MolDynamics & 2 & 6.58 & 1904 & 31 \\
+MonteCarlo & 0 & 4.24 & 3544 & 49 \\
+Series & 0 & 1.70 & 1407 & 10 \\
+KMeans & 2 & 5.51 & 2661 & 45 \\
+MapReduce2 & 3 & 17.76 & 2220 & 95 \\
+FluidAnimate & 2 & 164.37 & 3589 & 82 \\
+Spider1 & 0 & 6.58 & 1595 & 80 \\
+Spider2 & 0 & 6.24 & 1599 & 83 \\
+TileSearch & 0 & 8.18 & 2052 & 34 \\
+TicTacToe & 0 & 5.16 & 1534 & 68 \\
+WebServer1 & 0 & 6.79 & 1858 & 97 \\
+WebServer2 & 0 & 6.45 & 1857 & 100 \\
+\hline
+\end{tabular}
+
+
+\end{document}
import Analysis.OwnershipAnalysis.OwnershipAnalysis;
import Analysis.MLP.MLPAnalysis;
import Analysis.Loops.*;
+import Analysis.Liveness;
import IR.MethodDescriptor;
import IR.Flat.FlatMethod;
import Interface.*;
if (state.OWNERSHIP && !state.MLP) {
CallGraph callGraph = new CallGraph(state);
+ Liveness liveness = new Liveness();
OwnershipAnalysis oa = new OwnershipAnalysis(state,
tu,
callGraph,
+ liveness,
state.OWNERSHIPALLOCDEPTH,
state.OWNERSHIPWRITEDOTS,
state.OWNERSHIPWRITEALL,
if (state.MLP) {
CallGraph callGraph = new CallGraph(state);
+ Liveness liveness = new Liveness();
OwnershipAnalysis oa = new OwnershipAnalysis(state,
tu,
callGraph,
+ liveness,
state.OWNERSHIPALLOCDEPTH,
state.OWNERSHIPWRITEDOTS,
state.OWNERSHIPWRITEALL,
if (state.SCHEDULING) {
// Use ownership analysis to get alias information
CallGraph callGraph = new CallGraph(state);
+ Liveness liveness = new Liveness();
OwnershipAnalysis oa = new OwnershipAnalysis(state,
tu,
callGraph,
+ liveness,
state.OWNERSHIPALLOCDEPTH,
state.OWNERSHIPWRITEDOTS,
state.OWNERSHIPWRITEALL,