From: jjenista Date: Fri, 15 Aug 2008 22:34:17 +0000 (+0000) Subject: strong updates, everything ready to do method calls X-Git-Tag: buildscript^4~24 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f8c52e590c3ca37850d4e3f8a3f9fb5e06af192a;p=IRC.git strong updates, everything ready to do method calls --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index e9fb2494..2604b21f 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -114,6 +114,11 @@ public class HeapRegionNode extends OwnershipNode { return clone.iterator(); } + public int getNumReferencers() { + return referencers.size(); + } + + public void addReferencer( ReferenceEdge edge ) { assert edge != null; diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 3c68b4ae..43e27528 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -449,8 +449,34 @@ public class OwnershipGraph { false, edgeY.getBetaNew().pruneBy( hrnX.getAlpha() ) ); + if( f != null ) { + // we can do a strong update here if one of two cases holds + if( (hrnX.getNumReferencers() == 1) || + ( lnX.getNumReferencees() == 1 && hrnX.isSingleObject() ) + ) { + clearReferenceEdgesFrom( hrnX, f, false ); + } + + addReferenceEdge( hrnX, hrnY, edgeNew ); - addReferenceEdge( hrnX, hrnY, edgeNew ); + } else { + // if the field is null, or "any" field, then + // look to see if an any field already exists + // and merge with it, otherwise just add the edge + ReferenceEdge edgeExisting = hrnX.getReferenceTo( hrnY, f ); + + if( edgeExisting != null ) { + edgeExisting.setBetaNew( + edgeExisting.getBetaNew().union( edgeNew.getBeta() ) + ); + // a new edge here cannot be reflexive, so existing will + // always be also not reflexive anymore + edgeExisting.setIsInitialParamReflexive( false ); + + } else { + addReferenceEdge( hrnX, hrnY, edgeNew ); + } + } } } @@ -815,22 +841,10 @@ public class OwnershipGraph { } - // some notes: - // the heap regions that are specially allocated as multiple-object - // regions for method parameters need to be remembered in order to - // resolve a function call. So actually, we need a mapping from - // caller argument descriptors to the callee parameter heap regions - // to apply reference edges in the callee to the caller graph. - // - // also, Constructors and virtual dispatch methods have a "this" - // argument that make the mapping of arguments to parameters a little - // tricky. What happens to that this region? - - - public void resolveMethodCall( FlatCall fc, - boolean isStatic, - FlatMethod fm, - OwnershipGraph ogCallee ) { + public void resolveMethodCall( FlatCall fc, + boolean isStatic, + FlatMethod fm, + OwnershipGraph ogCallee ) { /* // verify the existence of allocation sites and their @@ -975,8 +989,8 @@ public class OwnershipGraph { } } } - } - */ + } + */ } /* diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java index f005fff1..88b786bb 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipNode.java @@ -22,6 +22,9 @@ public abstract class OwnershipNode { return clone.iterator(); } + public int getNumReferencees() { + return referencees.size(); + } public void addReferencee( ReferenceEdge edge ) { assert edge != null; diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile index 3d08d27a..65cc0bbd 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/makefile @@ -1,48 +1,17 @@ PROGRAM=test01 -SOURCE_FILES=test01.java +SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript 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 *COMPLETE*.png & - #eog *debug*.png & - -printable: - rm -f *Startup*.dot - rm -f *FlatMethod*.dot - rm -f *FlatOpNode*.dot - rm -f *FlatFieldNode*.dot - rm -f *FlatSetFieldNode*.dot - rm -f *FlatCall*.dot - rm -f *Parameter*.dot - rm -f *Penguin*.dot - rm -f *Voo*.dot - rm -f *Baw*.dot - rm -f *COMPLETE.dot - dot2eps *.dot + eog *.png PNGs: DOTs - #rm -f *Startup*.dot - #rm -f *COMPLETE*.dot - rm -f *FlatIR*.dot - rm -f *FlatMethod*.dot - rm -f *FlatOpNode*.dot - rm -f *FlatFieldNode*.dot - rm -f *FlatSetFieldNode*.dot - rm -f *FlatCall*.dot - rm -f *Parameter*.dot - rm -f *Penguin*.dot - rm -f *Voo*.dot - rm -f *Baw*.dot - d2p *.dot + d2p *COMPLETE*.dot DOTs: $(PROGRAM).bin diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index 7cfb7de9..0213b85a 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -1,4 +1,3 @@ -/* public class Parameter { flag w; int a, b; @@ -33,7 +32,6 @@ public class Baw { public void doTheBaw( Voo v ) { v = new Voo(); } } -*/ public class Foo { flag f; @@ -41,14 +39,13 @@ public class Foo { public Foo() {} public Foo x; + public Foo y; - /* public void ruinSomeFoos( Foo a, Foo b ) { a.x = b.x; } - */ - static public void test( Foo p0, Foo p1 ) { + static public void aStaticMethod( Foo p0, Foo p1 ) { Foo f0 = new Foo(); Foo f1 = new Foo(); Foo f2 = new Foo(); @@ -66,124 +63,10 @@ public class Foo { // look for the parameter s as a label referencing // a heap region that is multi-object, flagged, not summary task Startup( StartupObject s{ initialstate } ) { - - - while( false ) { - Foo a = new Foo(); - a.x = new Foo(); - a.x.x = new Foo(); - - //Foo z = a.x; - //z.x = new Foo(); - } - - - - Foo d = new Foo(); - Foo e = new Foo(); - Foo f = new Foo(); - Foo g = new Foo(); - - d.x = e; - e.x = f; - f.x = g; - - - Foo h = new Foo(); - Foo i = new Foo(); - Foo j = new Foo(); - Foo k = new Foo(); - - j.x = k; - i.x = j; - h.x = i; - - - - - // to look like Foo a above - //d.x.x = f; - - - Foo b; - while( false ) { - Foo c = new Foo(); - c.x = b; - b = c; - } - - taskexit( s{ !initialstate } ); } -task basics( Foo p0{ f }, Foo p1{ f } ) { - - //Foo a = new Foo(); - //Foo b = new Foo(); - - Foo q = p0; - p0.x = p1; - - Foo a = new Foo(); - a.x = new Foo(); - a.x.x = new Foo(); - - //p0.x = a; - //a.x = b; - - taskexit( p0{ !f }, p1{ !f } ); -} - - -task methodTest( Foo p0{ f } ) { - - Foo up0 = new Foo(); - Foo up1 = new Foo(); - Foo up2 = new Foo(); - - Foo a0; - Foo a1; - - if( false ) { - a0 = new Foo(); - up0.x = a0; - a0.x = new Foo(); - //Foo temp = new Foo(); - } - - if( false ) { - a0 = new Foo(); - a0.x = new Foo(); - a1 = a0; - up1.x = a0; - } - - if( false ) { - a1 = new Foo(); - up2.x = a1; - } - - // Foo.test( a0, a1 ); - - taskexit( p0{ !f } ); -} - - - - -/* -task NewObject( Foo a{ f }, Foo b{ f } ) { - - Foo c = new Foo(); - - a.x = c; - - taskexit( a{ !f }, b{ !f } ); -} -*/ - -/* task NewObjectA( Foo a{ f }, Foo b{ f } ) { Foo c = new Foo(); @@ -205,10 +88,8 @@ task NewObjectB( Foo a{ f }, Foo b{ f } ) { taskexit( a{ !f }, b{ !f } ); } -*/ -/* -task NewObject2( Foo a{ f }, Foo b{ f } ) { +task NewObjectC( Foo a{ f }, Foo b{ f } ) { Foo c; @@ -219,15 +100,15 @@ task NewObject2( Foo a{ f }, Foo b{ f } ) { taskexit( a{ !f }, b{ !f } ); } -*/ -/* + + // this task allocates a new object, so there should // be a heap region for the parameter, and several // heap regions for the allocation site, but the label // merely points to the newest region -task NewObject( Voo v{ f } ) { +task NewObjectInMethod( Voo v{ f } ) { Voo w = new Voo(); Baw b = new Baw(); b.doTheBaw( w ); @@ -236,52 +117,94 @@ task NewObject( Voo v{ f } ) { } -// this task -task Branch( Voo v{ f } ) { - Voo w = new Voo(); - Baw j = new Baw(); - Baw k = new Baw(); +task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) { + v.b = v.bb; + + taskexit( v{ !f }, w{ !f } ); +} + - if( v.x == 0 ) { - w.b = j; - } else { - w.b = k; +task SummaryNodeTokens( Foo p0{ f } ) { + + while( false ) { + Foo a = new Foo(); + a.x = new Foo(); + a.x.x = new Foo(); + } + + Foo b; + while( false ) { + Foo c = new Foo(); + c.x = b; + b = c; } - taskexit( v{ !f } ); + taskexit( p0{ !f } ); } -task NoAliasNewInLoop( Voo v{ f } ) { +task strongUpdates( Foo p0{ f } ) { - for( int i = 0; i < 10; ++i ) { - Voo w = new Voo(); - w.b = new Baw(); - w.b.f = new Foo(); + Foo b = new Foo(); + + Foo a = new Foo(); + if( false ) { + a.x = new Foo(); + a.y = new Foo(); + } else if( false ) { + a.x = new Foo(); + a.y = new Foo(); } - taskexit( v{ !f } ); + // this should effect a strong update + a.x = b; + + + if( false ) { + p0.x = new Foo(); + p0.y = new Foo(); + } else if( false ) { + p0.x = new Foo(); + p0.y = new Foo(); + } + + // p0 points to a multiple-object heap region + // so this should not make a strong update + p0.x = b; + + taskexit( p0{ !f } ); } -task NoAliasNewInLoopAnotherWay( Voo v{ f } ) { +task methodTest( Foo p0{ f } ) { + + Foo up0 = new Foo(); + Foo up1 = new Foo(); + Foo up2 = new Foo(); - for( int i = 0; i < 10; ++i ) { - Voo w = new Voo(); - Baw b = new Baw(); - Foo f = new Foo(); + Foo a0; + Foo a1; - w.b = b; - b.f = f; + if( false ) { + a0 = new Foo(); + up0.x = a0; + a0.x = new Foo(); + //Foo temp = new Foo(); } - taskexit( v{ !f } ); -} + if( false ) { + a0 = new Foo(); + a0.x = new Foo(); + a1 = a0; + up1.x = a0; + } + if( false ) { + a1 = new Foo(); + up2.x = a1; + } -task ClobberInitParamReflex( Voo v{ f }, Voo w{ f } ) { - v.b = v.bb; + // Foo.test( a0, a1 ); - taskexit( v{ !f }, w{ !f } ); + taskexit( p0{ !f } ); } -*/ \ No newline at end of file diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile index b93cb876..65cc0bbd 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test02/makefile @@ -1,29 +1,17 @@ -PROGRAM=test02 +PROGRAM=test01 -SOURCE_FILES=test02.java +SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript 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 *.png & + eog *.png PNGs: DOTs - #rm -f *Startup*.dot - rm -f *FlatMethod*.dot - rm -f *FlatOpNode*.dot - rm -f *FlatFieldNode*.dot - rm -f *FlatSetFieldNode*.dot - rm -f *FlatCall*.dot - rm -f *Parameter*.dot - rm -f *Penguin*.dot - d2p *.dot + d2p *COMPLETE*.dot DOTs: $(PROGRAM).bin @@ -36,3 +24,6 @@ clean: rm -f *~ rm -f *.dot rm -f *.png + rm -f *.ps + rm -f *.eps + rm -f identifiedAliases.txt diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java index 118668d2..03aedb9b 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test02/test02.java @@ -173,3 +173,29 @@ task newPossibleAlias taskexit( p1{w}, p2{w} ); } + +task NoAliasNewInLoop( Voo v{ f } ) { + + for( int i = 0; i < 10; ++i ) { + Voo w = new Voo(); + w.b = new Baw(); + w.b.f = new Foo(); + } + + taskexit( v{ !f } ); +} + + +task NoAliasNewInLoopAnotherWay( Voo v{ f } ) { + + for( int i = 0; i < 10; ++i ) { + Voo w = new Voo(); + Baw b = new Baw(); + Foo f = new Foo(); + + w.b = b; + b.f = f; + } + + taskexit( v{ !f } ); +} diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test03/makefile b/Robust/src/Tests/OwnershipAnalysisTest/test03/makefile index 4944b686..65cc0bbd 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test03/makefile +++ b/Robust/src/Tests/OwnershipAnalysisTest/test03/makefile @@ -1,45 +1,17 @@ -PROGRAM=test03 +PROGRAM=test01 -SOURCE_FILES=test03.java +SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript -BSFLAGS= -recover -flatirtasks -ownership #-enable-assertions -#BSFLAGS= -recover -ownership -enable-assertions +BSFLAGS= -recover -flatirtasks -ownership -enable-assertions all: $(PROGRAM).bin view: PNGs - eog *flatIRGraph*.png & - #eog *FN*.png & - #eog *Ownership*.png & - eog *.png & - -printable: - rm -f *Startup*.dot - rm -f *FlatMethod*.dot - rm -f *FlatOpNode*.dot - rm -f *FlatFieldNode*.dot - rm -f *FlatSetFieldNode*.dot - rm -f *FlatCall*.dot - rm -f *Parameter*.dot - rm -f *Penguin*.dot - rm -f *Voo*.dot - rm -f *Baw*.dot - rm -f *COMPLETE.dot - dot2eps *.dot + eog *.png PNGs: DOTs - #rm -f *Startup*.dot - rm -f *FlatMethod*.dot - rm -f *FlatOpNode*.dot - rm -f *FlatFieldNode*.dot - rm -f *FlatSetFieldNode*.dot - rm -f *FlatCall*.dot - rm -f *Parameter*.dot - rm -f *Penguin*.dot - rm -f *Voo*.dot - rm -f *Baw*.dot - d2p *.dot + d2p *COMPLETE*.dot DOTs: $(PROGRAM).bin