From 81973c240e46409bd203c40bc400b3e7ecd32df0 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 3 Mar 2008 23:55:53 +0000 Subject: [PATCH] Capture stable state. --- .../OwnershipAnalysis/OwnershipAnalysis.java | 43 ++++++++----------- .../OwnershipAnalysis/OwnershipGraph.java | 38 ++++++++++------ .../OwnershipAnalysisTest/test01/makefile | 21 ++++----- .../OwnershipAnalysisTest/test01/test01.java | 24 +++++++---- 4 files changed, 68 insertions(+), 58 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 81ae21c0..e045c8ca 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -117,15 +117,15 @@ public class OwnershipAnalysis { boolean isTask; FlatMethod fm; if( d instanceof MethodDescriptor ) { - isTask = false; + //isTask = false; fm = state.getMethodFlat( (MethodDescriptor) d ); } else { assert d instanceof TaskDescriptor; - isTask = true; + //isTask = true; fm = state.getMethodFlat( (TaskDescriptor) d ); } - OwnershipGraph og = analyzeFlatMethod( isTask, fm ); + OwnershipGraph og = analyzeFlatMethod( d, fm ); OwnershipGraph ogPrev = mapDescriptorToCompleteOwnershipGraph.get( d ); if( !og.equals( ogPrev ) ) { @@ -146,8 +146,10 @@ public class OwnershipAnalysis { } + // keep passing the Descriptor of the method along for debugging + // and dot file writing private OwnershipGraph - analyzeFlatMethod( boolean isTask, + analyzeFlatMethod( Descriptor mDesc, FlatMethod flatm ) throws java.io.IOException { // initialize flat nodes to visit as the flat method @@ -183,7 +185,7 @@ public class OwnershipAnalysis { // apply the analysis of the flat node to the // ownership graph made from the merge of the // parent graphs - analyzeFlatNode( isTask, fn, og ); + analyzeFlatNode( mDesc, fn, og ); // if the results of the new graph are different from // the current graph at this node, replace the graph @@ -216,7 +218,7 @@ public class OwnershipAnalysis { private void - analyzeFlatNode( boolean isTask, + analyzeFlatNode( Descriptor methodDesc, FlatNode fn, OwnershipGraph og ) throws java.io.IOException { @@ -241,20 +243,19 @@ public class OwnershipAnalysis { // adding parameters labels to new heap regions for( int i = 0; i < fm.numParameters(); ++i ) { TempDescriptor tdParam = fm.getParameter( i ); - og.parameterAllocation( isTask, tdParam ); + og.parameterAllocation( methodDesc instanceof TaskDescriptor, + tdParam ); + og.writeGraph( methodDesc, fn ); } break; - /* case FKind.FlatOpNode: FlatOpNode fon = (FlatOpNode) fn; if( fon.getOp().getOp() == Operation.ASSIGN ) { src = fon.getLeft(); dst = fon.getDest(); og.assignTempToTemp( src, dst ); - //nodeDescription = "Op"; - //writeGraph = true; - og.writeGraph( fn ); + og.writeGraph( methodDesc, fn ); } break; @@ -265,9 +266,7 @@ public class OwnershipAnalysis { fld = ffn.getField(); if( !fld.getType().isPrimitive() ) { og.assignTempToField( src, dst, fld ); - //nodeDescription = "Field"; - //writeGraph = true; - og.writeGraph( fn ); + og.writeGraph( methodDesc, fn ); } break; @@ -277,11 +276,10 @@ public class OwnershipAnalysis { dst = fsfn.getDst(); fld = fsfn.getField(); og.assignFieldToTemp( src, dst, fld ); - //nodeDescription = "SetField"; - //writeGraph = true; - og.writeGraph( fn ); + og.writeGraph( methodDesc, fn ); break; + /* case FKind.FlatNew: FlatNew fnn = (FlatNew) fn; dst = fnn.getDst(); @@ -304,23 +302,16 @@ public class OwnershipAnalysis { //MethodDescriptor md = fc.getMethod(); //descriptorsToVisit.add( md ); //System.out.println( " Descs to visit: " + descriptorsToVisit ); + og.writeGraph( methodDesc, fn ); break; case FKind.FlatReturnNode: //nodeDescription = "Return"; //writeGraph = true; //og.writeCondensedAnalysis( makeCondensedAnalysisName( methodname, flatnodetolabel.get(fn) ) ); - //og.writeGraph( fn ); + og.writeGraph( methodDesc, fn ); break; } - - /* - if( writeGraph ) { - og.writeGraph( makeNodeName( methodname, - flatnodetolabel.get( fn ), - nodeDescription ) ); - } - */ } static public Integer generateUniqueHeapRegionNodeID() { diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 63e83980..2b10d553 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -7,10 +7,10 @@ import java.io.*; public class OwnershipGraph { - /* + protected static final int VISIT_HRN_WRITE_FULL = 0; - protected static final int VISIT_HRN_WRITE_CONDENSED = 1; - */ + //protected static final int VISIT_HRN_WRITE_CONDENSED = 1; + private int allocationDepth; @@ -98,7 +98,6 @@ public class OwnershipGraph { } - /* //////////////////////////////////////////////////// // // New Reference Methods @@ -180,7 +179,6 @@ public class OwnershipGraph { // end new reference methods //////////////////////////////////////////////////// - */ protected HeapRegionNode createNewHeapRegionNode( Integer id, @@ -918,8 +916,19 @@ public class OwnershipGraph { } */ - public void writeGraph( String graphName ) throws java.io.IOException { + public void writeGraph( Descriptor methodDesc, + FlatNode fn ) throws java.io.IOException { + String graphName = + methodDesc.getSymbol() + + methodDesc.getNum() + + fn.toString(); + + // remove all non-word characters from the graph name so + // the filename and identifier in dot don't cause errors + graphName = graphName.replaceAll( "[\\W]", "" ); + + BufferedWriter bw = new BufferedWriter( new FileWriter( graphName+".dot" ) ); bw.write( "digraph "+graphName+" {\n" ); @@ -945,12 +954,14 @@ public class OwnershipGraph { bw.write( " }\n" ); } + */ + // then visit every heap region node HashSet visited = new HashSet(); - s = heapRoots.entrySet(); - i = s.iterator(); + Set s = heapRoots.entrySet(); + Iterator i = s.iterator(); while( i.hasNext() ) { Map.Entry me = (Map.Entry) i.next(); HeapRegionNode hrn = (HeapRegionNode) me.getValue(); @@ -981,7 +992,6 @@ public class OwnershipGraph { "\"];\n" ); } } - */ bw.write( "}\n" ); bw.close(); @@ -1025,6 +1035,7 @@ public class OwnershipGraph { bw.write( "}\n" ); bw.close(); } + */ protected void traverseHeapRegionNodes( int mode, HeapRegionNode hrn, @@ -1063,6 +1074,7 @@ public class OwnershipGraph { "\"];\n" ); break; + /* case VISIT_HRN_WRITE_CONDENSED: Iterator i = hrn.iteratorToAnalysisRegionAliases(); @@ -1089,11 +1101,11 @@ public class OwnershipGraph { hrn.addAnalysisRegionAlias( td ); break; + */ } - - OwnershipNode onRef = null; - Iterator refItr = hrn.iteratorToReferencers(); + OwnershipNode onRef = null; + Iterator refItr = hrn.iteratorToReferencers(); while( refItr.hasNext() ) { onRef = (OwnershipNode) refItr.next(); @@ -1130,6 +1142,4 @@ public class OwnershipGraph { traverseHeapRegionNodes( mode, hrnChild, bw, td, visited ); } } - */ - } diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile index 63f284cc..bf640f77 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile @@ -3,22 +3,23 @@ PROGRAM=test01 SOURCE_FILES=test01.java BUILDSCRIPT=~/research/Robust/src/buildscript -#BSFLAGS= -recover -flatirtasks -ownership -enable-assertions -BSFLAGS= -recover -ownership -enable-assertions +BSFLAGS= -recover -flatirtasks -ownership -enable-assertions +#BSFLAGS= -recover -ownership -enable-assertions all: $(PROGRAM).bin view: PNGs - eog *flatIRGraph*.png & - eog *FN*.png & - eog *Ownership*.png & + #eog *flatIRGraph*.png & + #eog *FN*.png & + #eog *Ownership*.png & + eog *.png & PNGs: DOTs - rm -f *Startup*.dot - rm -f *FN*Method*.dot - rm -f *FN*Op*.dot - rm -f *FN*Field*.dot - rm -f *FN*SetField*.dot + #rm -f *Startup*.dot + rm -f *FlatMethod*.dot + rm -f *FlatOpNode*.dot + rm -f *FlatFieldNode*.dot + rm -f *FlatSetFieldNode*.dot d2p *.dot DOTs: $(PROGRAM).bin diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index 8bac13c2..fe8258fa 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -2,19 +2,29 @@ public class Parameter { flag w; int a, b; Parameter f, g; - public Parameter() { - a = 0; b = 0; f = null; g = null; - } + + public Parameter() { a = 0; b = 0; f = null; g = null; } public void bar() { foo(); } public void foo() { bar(); } } +public class Penguin { + int x, y; + + public Penguin() { x = 0; y = 0; } + + public void bar() { x = 1; } +} + task Startup( StartupObject s{ initialstate } ) { Parameter p = new Parameter(){!w}; p.foo(); + Penguin g = new Penguin(); + g.bar(); + taskexit( s{ !initialstate } ); } @@ -80,7 +90,7 @@ task possibleAliasConditional taskexit( p1{w}, p2{w} ); } - +*/ task bunchOfPaths ( Parameter p1{!w}, Parameter p2{!w} ) { @@ -113,7 +123,7 @@ task bunchOfPaths taskexit( p1{w}, p2{w} ); } - +/* task literalTest( Parameter p1{!w} ) { Parameter x = null; int y = 5; @@ -121,9 +131,7 @@ task literalTest( Parameter p1{!w} ) { taskexit( p1{w} ); } -*/ -/* task newNoAlias ( Parameter p1{!w}, Parameter p2{!w} ) { @@ -152,4 +160,4 @@ task newPossibleAlias taskexit( p1{w}, p2{w} ); } -*/ +*/ \ No newline at end of file -- 2.34.1