From 25d2fac30f5587182870fe8738ef2cd74208a504 Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 24 Mar 2009 05:39:27 +0000 Subject: [PATCH] edge matching bug fix and add alpha source states back --- .../OwnershipAnalysis/OwnershipAnalysis.java | 12 +++- .../OwnershipAnalysis/OwnershipGraph.java | 42 ++++++++++--- .../OwnershipAnalysisTest/test07/test.java | 61 ++++++++++++++----- 3 files changed, 89 insertions(+), 26 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 3605309b..e7128a88 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -1229,7 +1229,7 @@ public class OwnershipAnalysis { // insert a call to debugSnapshot() somewhere in the analysis // to get successive captures of the analysis state boolean takeDebugSnapshots = false; - String mcDescSymbolDebug = "StandardEngine"; + String mcDescSymbolDebug = "addFirst"; boolean stopAfterCapture = true; // increments every visit to debugSnapshot, don't fiddle with it @@ -1246,7 +1246,7 @@ public class OwnershipAnalysis { int iterStartCapture = 0; // the number of snapshots to take - int numIterToCapture = 100; + int numIterToCapture = 40; void debugSnapshot(OwnershipGraph og, FlatNode fn) { if( debugCounter > iterStartCapture + numIterToCapture ) { @@ -1266,6 +1266,14 @@ public class OwnershipAnalysis { graphName = graphName+fn; } try { + // arguments to writeGraph are: + // boolean writeLabels, + // boolean labelSelect, + // boolean pruneGarbage, + // boolean writeReferencers + // boolean writeParamMappings + + //og.writeGraph(graphName, true, true, true, false, false); og.writeGraph(graphName, true, true, true, false, false); } catch( Exception e ) { System.out.println("Error writing debug capture."); diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 96d20cc3..58c38d0e 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -231,8 +231,9 @@ public class OwnershipGraph { ReferenceEdge edge = i.next(); if( removeAll || - (type != null && edge.getType() .equals( type )) || - (field != null && edge.getField().equals( field )) + (edge.typeEquals( type ) && edge.fieldEquals( field )) + //(type != null && edge.getType() .equals( type )) || + //(field != null && edge.getField().equals( field )) ){ HeapRegionNode referencee = edge.getDst(); @@ -259,8 +260,9 @@ public class OwnershipGraph { ReferenceEdge edge = i.next(); if( removeAll || - (type != null && edge.getType() .equals( type )) || - (field != null && edge.getField().equals( field )) + (edge.typeEquals( type ) && edge.fieldEquals( field )) + //(type != null && edge.getType() .equals( type )) || + //(field != null && edge.getField().equals( field )) ){ OwnershipNode referencer = edge.getSrc(); @@ -379,6 +381,11 @@ public class OwnershipGraph { HashSet nodesWithNewAlpha = new HashSet(); HashSet edgesWithNewBeta = new HashSet(); + + + //boolean printDebug = f.getType() + + // first look for possible strong updates and remove those edges boolean strongUpdate = false; @@ -1540,7 +1547,7 @@ public class OwnershipGraph { HeapRegionNode n = (HeapRegionNode) me.getKey(); ChangeTupleSet C = (ChangeTupleSet) me.getValue(); - n.setAlphaNew( n.getAlpha().applyChangeSet( C, false ) ); + n.setAlphaNew( n.getAlpha().applyChangeSet( C, true ) ); nodesWithNewAlpha.add( n ); } @@ -1840,12 +1847,17 @@ public class OwnershipGraph { String debugCaller = "foo"; String debugCallee = "bar"; + //String debugCaller = "StandardEngine"; + //String debugCaller = "register_by_type"; + //String debugCaller = "register_by_type_front"; + //String debugCaller = "addFirst"; + //String debugCallee = "LinkedListElement"; if( mc.getDescriptor().getSymbol().equals( debugCaller ) && fm.getMethod().getSymbol().equals( debugCallee ) ) { try { - writeGraph( "debug1Before", true, true, true, false, false ); + writeGraph( "debug1BeforeCall", true, true, true, false, false ); ogCallee.writeGraph( "debug0Callee", true, true, true, false, false ); } catch( IOException e ) {} @@ -2833,6 +2845,15 @@ public class OwnershipGraph { } + if( mc.getDescriptor().getSymbol().equals( debugCaller ) && + fm.getMethod().getSymbol().equals( debugCallee ) ) { + try { + writeGraph( "debug7JustBeforeMergeToKCapacity", true, true, true, false, false ); + } catch( IOException e ) {} + } + + + // merge the shadow nodes of allocation sites back down to normal capacity Iterator allocItr = ogCallee.allocationSites.iterator(); while( allocItr.hasNext() ) { @@ -2903,7 +2924,7 @@ public class OwnershipGraph { if( mc.getDescriptor().getSymbol().equals( debugCaller ) && fm.getMethod().getSymbol().equals( debugCallee ) ) { try { - writeGraph( "debug2JustBeforeSweep", true, true, true, false, false ); + writeGraph( "debug8JustBeforeSweep", true, true, true, false, false ); } catch( IOException e ) {} } @@ -2919,10 +2940,15 @@ public class OwnershipGraph { writeGraph( "debug9endResolveCall", true, true, true, false, false ); } catch( IOException e ) {} System.out.println( " "+mc+" done calling "+fm ); - System.exit( -1 ); + ++x; + if( x > 2 ) { + System.exit( -1 ); + } } } + static int x = 0; + protected boolean hasMatchingField(HeapRegionNode src, ReferenceEdge edge) { diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test07/test.java b/Robust/src/Tests/OwnershipAnalysisTest/test07/test.java index 7090a143..c2e99187 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test07/test.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test07/test.java @@ -1,27 +1,56 @@ -public class Foo { - public Foo() {} +public class Engine { + LinkedList[] actions; - public Bar b; -} + public Engine() { + actions = new LinkedList[10]; + for( int i = 0; i < 10; ++i ) { + actions[i] = disjoint blah new LinkedList(); + } + } -public class Bar { - public Bar() {} + public add( Action a, int list, Action c ) { + actions[list].addFirst( a ); + } } -public class Test { +public class StandardEngine extends Engine { + public StandardEngine( Gen gen ) { + Engine(); - static public void main( String[] args ) { - Foo x = disjoint foo new Foo(); - Bar y = disjoint bar new Bar(); + Action c = new Action( gen ); - x.b = y; + Action a = new AntherAction( gen ); + add( a, 0, c ); + //add( a, 1, c ); + + + Action b = new AntherAction( gen ); + add( b, 0, c ); - virginia( x, y ); } +} - static public void virginia( Foo x, Bar y ) { - //x.b = y; - //x.b = new Bar(); - x.b = null; +public class Action { + Gen gen; + public Action( Gen g ) { + gen = g; + } +} + +public class AntherAction extends Action { + public AntherAction( Gen g ) { + Action( g ); + } +} + +public class Gen { + public Gen() {} +} + +public class Test { + + static public void main( String[] args ) { + Gen gen = new Gen(); + StandardEngine se = new StandardEngine( gen ); } } -- 2.34.1