From 827cb19b1470287e2ae795e9a6cad49e7f54df44 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 8 Oct 2009 16:51:56 +0000 Subject: [PATCH] Allow some disjointness improvements to be turned off, add script to run all benchmarks add aggregate results (way overdue), also checking in a test that verifies strong update and global sweep can alter sharing for some programs --- .../OwnershipAnalysis/OwnershipAnalysis.java | 82 ++++++-- .../OwnershipAnalysis/OwnershipGraph.java | 31 ++- Robust/src/Benchmarks/Ownership/makeTable.sh | 119 ++++++++++++ Robust/src/Benchmarks/Ownership/makefile | 5 +- Robust/src/Benchmarks/Ownership/summary.tex | 176 ++++++++++++++---- Robust/src/IR/State.java | 1 + Robust/src/Main/Main.java | 6 +- .../proveStrongAndGlobal/makefile | 27 +++ .../proveStrongAndGlobal/test.java | 66 +++++++ 9 files changed, 445 insertions(+), 68 deletions(-) create mode 100755 Robust/src/Benchmarks/Ownership/makeTable.sh create mode 100644 Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/makefile create mode 100644 Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/test.java diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index e323687e..0921ef0c 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -119,25 +119,36 @@ public class OwnershipAnalysis { // use the methods given above to check every possible alias // between task parameters and flagged allocation sites reachable // from the task - public void writeAllAliases(String outputFile, String timeReport) throws java.io.IOException { + public void writeAllAliases(String outputFile, + String timeReport, + String justTime, + boolean tabularOutput, + int numLines + ) throws java.io.IOException { checkAnalysisComplete(); BufferedWriter bw = new BufferedWriter(new FileWriter(outputFile) ); - bw.write("Conducting ownership analysis with allocation depth = "+allocationDepth+"\n"); - bw.write(timeReport+"\n"); + if( !tabularOutput ) { + bw.write("Conducting ownership analysis with allocation depth = "+allocationDepth+"\n"); + bw.write(timeReport+"\n"); + } + + int numAlias = 0; // look through every task for potential aliases Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator(); while( taskItr.hasNext() ) { TaskDescriptor td = (TaskDescriptor) taskItr.next(); - bw.write("\n---------"+td+"--------\n"); + if( !tabularOutput ) { + bw.write("\n---------"+td+"--------\n"); + } HashSet allocSites = getFlaggedAllocationSitesReachableFromTask(td); Set common; - + // for each task parameter, check for aliases with // other task parameters and every allocation site // reachable from this task @@ -152,11 +163,15 @@ public class OwnershipAnalysis { common = createsPotentialAliases(td, i, j); if( !common.isEmpty() ) { foundSomeAlias = true; - bw.write("Potential alias between parameters "+i+" and "+j+".\n"); - bw.write(prettyPrintNodeSet( common )+"\n" ); + if( !tabularOutput ) { + bw.write("Potential alias between parameters "+i+" and "+j+".\n"); + bw.write(prettyPrintNodeSet( common )+"\n" ); + } else { + ++numAlias; + } } } - + // for the ith parameter, check for aliases against // the set of allocation sites reachable from this // task context @@ -166,12 +181,16 @@ public class OwnershipAnalysis { common = createsPotentialAliases(td, i, as); if( !common.isEmpty() ) { foundSomeAlias = true; - bw.write("Potential alias between parameter "+i+" and "+as.getFlatNew()+".\n"); - bw.write(prettyPrintNodeSet( common )+"\n" ); + if( !tabularOutput ) { + bw.write("Potential alias between parameter "+i+" and "+as.getFlatNew()+".\n"); + bw.write(prettyPrintNodeSet( common )+"\n" ); + } else { + ++numAlias; + } } } } - + // for each allocation site check for aliases with // other allocation sites in the context of execution // of this task @@ -186,11 +205,15 @@ public class OwnershipAnalysis { if( !outerChecked.contains(as2) ) { common = createsPotentialAliases(td, as1, as2); - + if( !common.isEmpty() ) { foundSomeAlias = true; - bw.write("Potential alias between "+as1.getFlatNew()+" and "+as2.getFlatNew()+".\n"); - bw.write(prettyPrintNodeSet( common )+"\n" ); + if( !tabularOutput ) { + bw.write("Potential alias between "+as1.getFlatNew()+" and "+as2.getFlatNew()+".\n"); + bw.write(prettyPrintNodeSet( common )+"\n" ); + } else { + ++numAlias; + } } } } @@ -199,17 +222,33 @@ public class OwnershipAnalysis { } if( !foundSomeAlias ) { - bw.write("No aliases between flagged objects in Task "+td+".\n"); + if( !tabularOutput ) { + bw.write("No aliases between flagged objects in Task "+td+".\n"); + } } } - bw.write( "\n"+computeAliasContextHistogram() ); + if( !tabularOutput ) { + bw.write( "\n"+computeAliasContextHistogram() ); + } else { + bw.write( " & "+numAlias+ + " & "+justTime+ + " & "+numLines+ + " & "+numMethodsAnalyzed()+ + " \\\\\n" ); + } + bw.close(); } // this version of writeAllAliases is for Java programs that have no tasks - public void writeAllAliasesJava(String outputFile, String timeReport) throws java.io.IOException { + public void writeAllAliasesJava(String outputFile, + String timeReport, + String justTime, + boolean tabularOutput, + int numLines + ) throws java.io.IOException { checkAnalysisComplete(); assert !state.TASK; @@ -511,6 +550,7 @@ public class OwnershipAnalysis { double timeEndAnalysis = (double) System.nanoTime(); double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) ); String treport = String.format( "The reachability analysis took %.3f sec.", dt ); + String justtime = String.format( "%.2f", dt ); System.out.println( treport ); if( writeDOTs && !writeAllDOTs ) { @@ -523,9 +563,9 @@ public class OwnershipAnalysis { if( aliasFile != null ) { if( state.TASK ) { - writeAllAliases(aliasFile, treport); + writeAllAliases(aliasFile, treport, justtime, state.OWNERSHIPALIASTAB, state.lines); } else { - writeAllAliasesJava(aliasFile, treport); + writeAllAliasesJava(aliasFile, treport, justtime, state.OWNERSHIPALIASTAB, state.lines); } } @@ -1363,6 +1403,10 @@ public class OwnershipAnalysis { return s; } + + private int numMethodsAnalyzed() { + return descriptorsToAnalyze.size(); + } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 61e076f4..0d4d803c 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -7,6 +7,11 @@ import java.io.*; public class OwnershipGraph { + // use to disable improvements for comparison + protected static final boolean DISABLE_STRONG_UPDATES = false; + protected static final boolean DISABLE_GLOBAL_SWEEP = false; + + private int allocationDepth; private TypeUtil typeUtil; @@ -402,8 +407,10 @@ public class OwnershipGraph { (hrnX.isSingleObject() && lnX.getNumReferencees() == 1) // case 2 ) ) { - strongUpdate = true; - clearReferenceEdgesFrom( hrnX, f.getType(), f.getSymbol(), false ); + if( !DISABLE_STRONG_UPDATES ) { + strongUpdate = true; + clearReferenceEdgesFrom( hrnX, f.getType(), f.getSymbol(), false ); + } } } @@ -514,8 +521,10 @@ public class OwnershipGraph { // if there was a strong update, make sure to improve // reachability with a global sweep - if( strongUpdate ) { - globalSweep(); + if( strongUpdate ) { + if( !DISABLE_GLOBAL_SWEEP ) { + globalSweep(); + } } } @@ -2091,8 +2100,9 @@ public class OwnershipGraph { if( (hrn.getNumReferencers() == 1) || // case 1 (hrn.isSingleObject() && argLabel_i.getNumReferencees() == 1) // case 2 ) { - - effectCalleeStrongUpdates( paramIndex, ogCallee, hrn ); + if( !DISABLE_STRONG_UPDATES ) { + effectCalleeStrongUpdates( paramIndex, ogCallee, hrn ); + } } } } @@ -3025,8 +3035,9 @@ public class OwnershipGraph { // improve reachability as much as possible - globalSweep(); - + if( !DISABLE_GLOBAL_SWEEP ) { + globalSweep(); + } if( mc.getDescriptor().getSymbol().equals( debugCaller ) && @@ -4249,7 +4260,9 @@ public class OwnershipGraph { Set common = new HashSet(); if( aliasDetected ) { common = findCommonReachableNodes( hrn1, hrn2 ); - assert !common.isEmpty(); + if( !(DISABLE_STRONG_UPDATES || DISABLE_GLOBAL_SWEEP) ) { + assert !common.isEmpty(); + } } return common; diff --git a/Robust/src/Benchmarks/Ownership/makeTable.sh b/Robust/src/Benchmarks/Ownership/makeTable.sh new file mode 100755 index 00000000..83641820 --- /dev/null +++ b/Robust/src/Benchmarks/Ownership/makeTable.sh @@ -0,0 +1,119 @@ +#!/bin/bash + +NAME[0]=Bank +BDIR[0]=BankApp + +NAME[1]=Chat +BDIR[1]=ChatTag + +NAME[2]=Conglomerator +BDIR[2]=Conglomerator/Tag + +NAME[3]=jHTTPp2 +BDIR[3]=Jhttpp2/BR + +NAME[4]=MapReduce1 +BDIR[4]=MapReduce/Tag + +NAME[5]=MultiGame +BDIR[5]=MMG/Tag + +NAME[6]=Performance +BDIR[6]=Performance + +NAME[7]=PERT +BDIR[7]=PERT/Tag + +NAME[8]=FilterBank +BDIR[8]=Scheduling/FilterBank + +NAME[9]=Fractal +BDIR[9]=Scheduling/Fractal + +NAME[10]=MolDynamics +BDIR[10]=Scheduling/JGFMolDyn + +NAME[11]=MonteCarlo +BDIR[11]=Scheduling/JGFMonteCarlo + +NAME[12]=Series +BDIR[12]=Scheduling/JGFSeries + +NAME[13]=KMeans +BDIR[13]=Scheduling/KMeans + +NAME[14]=MapReduce2 +BDIR[14]=Scheduling/MapReduce + +NAME[15]=FluidAnimate +BDIR[15]=Scheduling/PSFluidAnimate + +NAME[16]=Spider1 +BDIR[16]=Spider/BR + +NAME[17]=Spider2 +BDIR[17]=Spider/BRTag + +NAME[18]=TileSearch +BDIR[18]=TileSearch/Tag + +NAME[19]=TicTacToe +BDIR[19]=TTTTag + +NAME[20]=WebServer1 +BDIR[20]=WebServer + +NAME[21]=WebServer2 +BDIR[21]=WebServerTag + +NUMBENCHMARKS=22 + + + +########################### +# No need to modify below! +########################### + +BENCHTOP=~/research/Robust/src/Benchmarks +BENCHSUM=$BENCHTOP/Ownership + +TABFILE=tabResults.tex +rm -f $TABFILE +touch $TABFILE +echo '\begin{tabular}{|l|l|r|r|r|}' >> $TABFILE +echo '\hline' >> $TABFILE +echo 'Benchmark & Sharing & Time (s) & Lines & Methods \\' >> $TABFILE +echo '\hline' >> $TABFILE + +i="0" +while [ $i -lt $NUMBENCHMARKS ]; do + cd $BENCHTOP/${BDIR[$i]} + # unfortunately this echo adds an unwanted newline + echo ${NAME[$i]} >> $BENCHSUM/$TABFILE + make -f $BENCHSUM/makefile + cat aliases.txt >> $BENCHSUM/$TABFILE + make -f $BENCHSUM/makefile clean + i=$[$i+1] +done + +cd $BENCHSUM + +echo '\hline' >> $TABFILE +echo '\end{tabular}' >> $TABFILE + +# remove unwanted newlines from file so latex doesn't barf +sed ' +/$/ { +# append the next line + N +# look for multi-line pattern + /\n \&/ { +# delete everything between + s/\n \&/ \&/ +# print + P +# then delete the first line + D + } +}' <$TABFILE >$TABFILE.temp +mv $TABFILE.temp $TABFILE diff --git a/Robust/src/Benchmarks/Ownership/makefile b/Robust/src/Benchmarks/Ownership/makefile index 082a4494..426d1b7d 100644 --- a/Robust/src/Benchmarks/Ownership/makefile +++ b/Robust/src/Benchmarks/Ownership/makefile @@ -1,5 +1,5 @@ BUILDSCRIPT=~/research/Robust/src/buildscript -BSFLAGS= -recover -justanalyze -ownership -ownaliasfile aliases.txt -enable-assertions -ownwritedots final #-flatirtasks +BSFLAGS= -recover -justanalyze -ownership -ownaliasfiletab aliases.txt -enable-assertions #-ownwritedots final #-flatirtasks AD1= -ownallocdepth 1 AD3= -ownallocdepth 3 AD5= -ownallocdepth 5 @@ -33,4 +33,7 @@ clean: rm -f *~ rm -f *.dot rm -f *.png + rm -f *.aux + rm -f *.log + rm -f *.pdf rm -f aliases.txt diff --git a/Robust/src/Benchmarks/Ownership/summary.tex b/Robust/src/Benchmarks/Ownership/summary.tex index 26c5f8a7..b01a3b64 100644 --- a/Robust/src/Benchmarks/Ownership/summary.tex +++ b/Robust/src/Benchmarks/Ownership/summary.tex @@ -3,56 +3,156 @@ All versions run with $k=1$ on dw-8. +Average of 64.4 methods per benchmark. -\section{Normal} -\begin{tabular}{|l|l|r|r|} -\hline -Benchmark & Sharing & Time (s) & Lines & Methods \\ -\hline -Bank & 0 & 6.87 & 1,825 & \\ -Chat & 3 & 6.45 & 1,510 & \\ -Conglomerator & 0 & 4.55 & 1,979 & \\ -MapReduce(1) & 2 & 11.83 & 2,274 & \\ -Performance & 0 & 2.10 & 1,760 & \\ -PERT & 0 & 2.77 & 1,950 & \\ -MapReduce(Sc) & 3 & 17.12 & 2,218 & \\ -Spider(1) & 0 & 7.66 & 1,593 & \\ -Spider(2) & 0 & 6.90 & 1,597 & \\ -TileSearch & 0 & 9.47 & 2,050 & \\ -TicTacToe & 0 & 3.80 & 1,532 & \\ -WebServer(1) & 0 & 9.28 & 1,856 & \\ -WebServer(2) & 0 & 8.27 & 1,855 & \\ -\hline -jHTTPp2 & 0 & 6.73 & 2,583 & \\ -FluidAnimate & 2 & 368.61 & 3,587 & \\ -FilterBank & 0 & 1.83 & 1,321 & \\ -KMeans & 2 & 5.60 & 2,659 & \\ -MonteCarlo & 0 & 3.69 & 3,542 & \\ -Moldyn & 2 & 6.03 & 1,902 & \\ -Series & 0 & 1.99 & 1,405 & \\ -MultiGame & 10 & 25.57 & 3,003 & \\ -Fractal & 1 & 2.13 & 1,334 & \\ + +\section{Alias Context Histogram} +Histogram of alias contexts per method over all programs analyzed. + +\begin{tabular}{|r|r|r|} +\hline +num unique alias contexts & num methods \\ +\hline +1 & 1324 \\ +2 & 37 \\ +3 & 16 \\ +4 & 6 \\ +5 & 11 \\ +6 & 0 \\ +7 & 1 \\ \hline \end{tabular} -Histogram of alias contexts per method over all programs analyzed. + +\section{All Improvement On} +\begin{tabular}{|l|l|r|r|r|} +\hline +Benchmark & Sharing & Time (s) & Lines & Methods \\ +\hline +Bank & 0 & 3.49 & 1825 & 67 \\ +Chat & 3 & 3.58 & 1510 & 71 \\ +Conglomerator & 0 & 3.11 & 1979 & 93 \\ +jHTTPp2 & 0 & 5.57 & 2583 & 122 \\ +MapReduce1 & 2 & 10.43 & 2274 & 114 \\ +MultiGame & 10 & 35.11 & 3003 & 46 \\ +Performance & 0 & 1.43 & 1760 & 30 \\ +PERT & 0 & 2.16 & 1950 & 61 \\ +FilterBank & 0 & 0.79 & 1321 & 9 \\ +Fractal & 1 & 0.68 & 1334 & 8 \\ +MolDynamics & 2 & 8.29 & 1902 & 31 \\ +MonteCarlo & 0 & 2.07 & 3542 & 49 \\ +Series & 0 & 0.77 & 1405 & 10 \\ +KMeans & 2 & 2.92 & 2659 & 45 \\ +MapReduce2 & 3 & 11.35 & 2218 & 95 \\ +FluidAnimate & 2 & 312.60 & 3587 & 82 \\ +Spider1 & 0 & 5.09 & 1593 & 80 \\ +Spider2 & 0 & 4.77 & 1597 & 83 \\ +TileSearch & 0 & 7.10 & 2050 & 34 \\ +TicTacToe & 0 & 2.31 & 1532 & 68 \\ +WebServer1 & 0 & 5.38 & 1856 & 97 \\ +WebServer2 & 0 & 6.62 & 1855 & 100 \\ +\hline +\end{tabular} + -\begin{tabular}{|r|r|} + + +\section{Strong Updates Off} +\begin{tabular}{|l|l|r|r|r|} \hline -# unique alias contexts & counting(not important) & # methods \\ +Benchmark & Sharing & Time (s) & Lines & Methods \\ \hline -1 & 65+66+91+115+109+44+28+59+9+8+30+49+10+42+88+73+76+79+28+66+93+96 & \\ -2 & 4+2+2+2+1+1+3+4+5+3+3+5+1+1 & \\ -3 & 1+1+4+1+1+1+2+1+2+2 & \\ -4 & 1+1+1+1+1+1 & \\ -5 & 1+1+2+1+2+1+1+1+1 & \\ -6 & & \\ -7 & 1 & \\ +Bank & 0 & 3.99 & 1825 & 67 \\ +Chat & 3 & 5.70 & 1510 & 71 \\ +Conglomerator & 0 & 3.11 & 1979 & 93 \\ +jHTTPp2 & 0 & 4.89 & 2583 & 122 \\ +MapReduce1 & 2 & 12.48 & 2274 & 114 \\ +MultiGame & 10 & 35.61 & 3003 & 46 \\ +Performance & 0 & 1.30 & 1760 & 30 \\ +PERT & 0 & 1.60 & 1950 & 61 \\ +FilterBank & 0 & 0.83 & 1321 & 9 \\ +Fractal & 1 & 0.61 & 1334 & 8 \\ +MolDynamics & 2 & 5.85 & 1902 & 31 \\ +MonteCarlo & 0 & 2.24 & 3542 & 49 \\ +Series & 0 & 0.86 & 1405 & 10 \\ +KMeans & 2 & 2.90 & 2659 & 45 \\ +MapReduce2 & 3 & 10.62 & 2218 & 95 \\ +FluidAnimate & 2 & 461.38 & 3587 & 82 \\ +Spider1 & 0 & 6.03 & 1593 & 80 \\ +Spider2 & 0 & 5.26 & 1597 & 83 \\ +TileSearch & 0 & 5.51 & 2050 & 34 \\ +TicTacToe & 0 & 2.12 & 1532 & 68 \\ +WebServer1 & 0 & 7.87 & 1856 & 97 \\ +WebServer2 & 0 & 6.23 & 1855 & 100 \\ \hline \end{tabular} +\section{Global Sweep Off} +\begin{tabular}{|l|l|r|r|r|} +\hline +Benchmark & Sharing & Time (s) & Lines & Methods \\ +\hline +Bank & 0 & 2.86 & 1825 & 67 \\ +Chat & 3 & 3.69 & 1510 & 71 \\ +Conglomerator & 0 & 2.61 & 1979 & 93 \\ +jHTTPp2 & 0 & 4.95 & 2583 & 122 \\ +MapReduce1 & 2 & 12.04 & 2274 & 114 \\ +MultiGame & 10 & 51.11 & 3003 & 46 \\ +Performance & 0 & 0.94 & 1760 & 30 \\ +PERT & 0 & 1.81 & 1950 & 61 \\ +FilterBank & 0 & 0.68 & 1321 & 9 \\ +Fractal & 1 & 0.57 & 1334 & 8 \\ +MolDynamics & 2 & 6.06 & 1902 & 31 \\ +MonteCarlo & 0 & 2.02 & 3542 & 49 \\ +Series & 0 & 0.61 & 1405 & 10 \\ +KMeans & 2 & 3.08 & 2659 & 45 \\ +MapReduce2 & 3 & 26.79 & 2218 & 95 \\ +FluidAnimate & 2 & 562.32 & 3587 & 82 \\ +Spider1 & 0 & 4.14 & 1593 & 80 \\ +Spider2 & 0 & 4.15 & 1597 & 83 \\ +TileSearch & 0 & 6.63 & 2050 & 34 \\ +TicTacToe & 0 & 1.77 & 1532 & 68 \\ +WebServer1 & 0 & 4.57 & 1856 & 97 \\ +WebServer2 & 0 & 5.27 & 1855 & 100 \\ +\hline +\end{tabular} + + + +\section{Strong Updates AND Global Sweep Off} +\begin{tabular}{|l|l|r|r|r|} +\hline +Benchmark & Sharing & Time (s) & Lines & Methods \\ +\hline +Bank & 0 & 3.28 & 1825 & 67 \\ +Chat & 3 & 4.22 & 1510 & 71 \\ +Conglomerator & 0 & 2.44 & 1979 & 93 \\ +jHTTPp2 & 0 & 4.74 & 2583 & 122 \\ +MapReduce1 & 2 & 10.88 & 2274 & 114 \\ +MultiGame & 10 & 41.70 & 3003 & 46 \\ +Performance & 0 & 1.14 & 1760 & 30 \\ +PERT & 0 & 1.71 & 1950 & 61 \\ +FilterBank & 0 & 0.71 & 1321 & 9 \\ +Fractal & 1 & 0.65 & 1334 & 8 \\ +MolDynamics & 2 & 6.24 & 1902 & 31 \\ +MonteCarlo & 0 & 2.16 & 3542 & 49 \\ +Series & 0 & 0.62 & 1405 & 10 \\ +KMeans & 2 & 3.12 & 2659 & 45 \\ +MapReduce2 & 3 & 24.33 & 2218 & 95 \\ +FluidAnimate & 2 & 509.12 & 3587 & 82 \\ +Spider1 & 0 & 4.02 & 1593 & 80 \\ +Spider2 & 0 & 4.21 & 1597 & 83 \\ +TileSearch & 0 & 6.40 & 2050 & 34 \\ +TicTacToe & 0 & 1.84 & 1532 & 68 \\ +WebServer1 & 0 & 6.06 & 1856 & 97 \\ +WebServer2 & 0 & 5.68 & 1855 & 100 \\ +\hline +\end{tabular} + + + \end{document} diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index dfb49813..9785db6c 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -66,6 +66,7 @@ public class State { public boolean OWNERSHIPWRITEDOTS=false; public boolean OWNERSHIPWRITEALL=false; public String OWNERSHIPALIASFILE=null; + public boolean OWNERSHIPALIASTAB=false; public boolean OPTIONAL=false; public boolean ARRAYBOUNDARYCHECK=true; public boolean RAW=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 7f6da0f1..49da3bdf 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -139,8 +139,12 @@ public class Main { if (args[++i].equals("all")) { state.OWNERSHIPWRITEALL=true; } - } else if (option.equals("-ownaliasfile")) + } else if (option.equals("-ownaliasfile")) { state.OWNERSHIPALIASFILE=args[++i]; + } else if (option.equals("-ownaliasfiletab")) { + state.OWNERSHIPALIASFILE=args[++i]; + state.OWNERSHIPALIASTAB=true; + } else if (option.equals("-optional")) state.OPTIONAL=true; else if (option.equals("-optimize")) diff --git a/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/makefile b/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/makefile new file mode 100644 index 00000000..d0c69a1b --- /dev/null +++ b/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/makefile @@ -0,0 +1,27 @@ +PROGRAM=test + +SOURCE_FILES=$(PROGRAM).java + +BUILDSCRIPT=~/research/Robust/src/buildscript +BSFLAGS= -recover -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions + +all: $(PROGRAM).bin + +view: PNGs + eog *.png & + +PNGs: DOTs + d2p *COMPLETE*.dot + +DOTs: $(PROGRAM).bin + +$(PROGRAM).bin: $(SOURCE_FILES) + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES) + +clean: + rm -f $(PROGRAM).bin + rm -fr tmpbuilddirectory + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f aliases.txt diff --git a/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/test.java b/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/test.java new file mode 100644 index 00000000..c24882e9 --- /dev/null +++ b/Robust/src/Tests/OwnershipAnalysisTest/proveStrongAndGlobal/test.java @@ -0,0 +1,66 @@ + +public class Parameter { + flag w; + int a; + int b; + Foo f; + Foo g; + Parameter p; + Parameter q; + public Parameter() {} +} + +public class Foo { + Foo f; + Foo g; + Parameter p; + Parameter q; + public Foo() {} + void noFlaggedAlias() { + this.f.p = new Parameter(); + } +} + +task Startup( StartupObject s{ initialstate } ) { + Parameter p0 = new Parameter(); + taskexit( s{ !initialstate } ); +} + +task noAliasAlways( Parameter p0{ w }, Parameter p1{ !w } ) { + p0.f = new Foo(); + p1.g = new Foo(); + taskexit( p0{ !w }, p1{ w } ); +} + +task noAliasWithStrong( Parameter p0{ w }, Parameter p1{ !w } ) { + p0.f = new Foo(); + p1.g = p0.f; + p1.g = new Foo(); + taskexit( p0{ !w }, p1{ w } ); +} + +task noAliasWithGlobal( Parameter p0{ w }, Parameter p1{ !w } ) { + Foo f0 = new Foo(); + f0.f = new Foo(); + + f0.p = p0; + f0.f.p = p1; + + f0.noFlaggedAlias(); + + taskexit( p0{ !w }, p1{ w } ); +} + +task noAliasWithGlobalAndStrong( Parameter p0{ w }, Parameter p1{ !w } ) { + p0.f = new Foo(); + p0.f.f = new Foo(); + p0.f.f.p = new Parameter(); + + p1.f = p0.f; + p1.f.f.p = new Parameter(); + + p0.f.f = null; + p0.f = null; + + taskexit( p0{ !w }, p1{ w } ); +} -- 2.34.1