From: jjenista Date: Tue, 25 Oct 2011 17:42:33 +0000 (+0000) Subject: implementing def reach transfer funcs for R X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=79bf3b82df6eece90b9b830a37d114647dfa2537;p=IRC.git implementing def reach transfer funcs for R --- diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java index f22da374..0ebfbdd2 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java @@ -40,9 +40,10 @@ public class DefiniteReachAnalysis { public void load( FlatNode fn, TempDescriptor x, TempDescriptor y, - FieldDescriptor f ) { + FieldDescriptor f, + Set edgeKeysForLoad ) { DefiniteReachState state = makeIn( fn ); - state.load( x, y, f ); + state.load( x, y, f, edgeKeysForLoad ); fn2state.put( fn, state ); } diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachState.java b/Robust/src/Analysis/Disjoint/DefiniteReachState.java index 699ea9ae..710a6954 100644 --- a/Robust/src/Analysis/Disjoint/DefiniteReachState.java +++ b/Robust/src/Analysis/Disjoint/DefiniteReachState.java @@ -133,8 +133,9 @@ public class DefiniteReachState { public void load( TempDescriptor x, TempDescriptor y, - FieldDescriptor f ) { - loadR( x, y, f ); + FieldDescriptor f, + Set edgeKeysForLoad ) { + loadR( x, y, f, edgeKeysForLoad ); // Rs' := (Rs - ) U {} //Rs.put( x, DefReachKnown.UNKNOWN ); } @@ -180,31 +181,66 @@ public class DefiniteReachState { public void copyR( TempDescriptor x, TempDescriptor y ) { - // R' := (R - - <*,x>) U - // {->e | ->e in R} U - // {->e | ->e in R} - // R' = new Map(R) - // R'.remove(view0, x); - // R'.remove(view1, x); - // setYs = R.get(view0, y); - // for each ->e: R'.put(, e); - // setYs = R.get(view1, y); - // for each ->e: R'.put(, e); + // consider that x and y can be the same, so do the + // parts of the update in the right order: + + // first get all info for update + MultiKey keyY = MultiKey.factory( y ); + Map mapY0 = R.get( viewR0, keyY ); + Map mapY1 = R.get( viewR1, keyY ); + + // then remove anything + MultiKey keyX = MultiKey.factory( x ); + R.remove( viewR0, keyX ); + R.remove( viewR1, keyX ); + + // then insert new stuff + for( MultiKey fullKeyY : mapY0.keySet() ) { + MultiKey fullKeyX = MultiKey.factory( x, + fullKeyY.get( 1 ), + fullKeyY.get( 2 ) ); + R.put( fullKeyX, MultiViewMap.dummyValue ); + } + for( MultiKey fullKeyY : mapY1.keySet() ) { + MultiKey fullKeyX = MultiKey.factory( fullKeyY.get( 0 ), + x, + fullKeyY.get( 2 ) ); + R.put( fullKeyX, MultiViewMap.dummyValue ); + } } public void loadR( TempDescriptor x, TempDescriptor y, - FieldDescriptor f ) { - // R' := (R - - <*,x>) U - // ({} x Eo(y,f)) U - // U {} x (Eo(y,f)U{e}) - // ->e in R - // R' = new Map(R) - // R'.remove(view0, x); - // R'.remove(view1, x); - // R'.put(, eee!); - // setYs = R.get(view0, y); - // for each ->e: R'.put(, eee!Ue); + FieldDescriptor f, + Set edgeKeysForLoad ) { + // consider that x and y can be the same, so do the + // parts of the update in the right order: + + // first get all info for update + MultiKey keyY = MultiKey.factory( y ); + Map mapY0 = R.get( viewR0, keyY ); + + // then remove anything + MultiKey keyX = MultiKey.factory( x ); + R.remove( viewR0, keyX ); + R.remove( viewR1, keyX ); + + // then insert new stuff + for( EdgeKey e : edgeKeysForLoad ) { + R.put( MultiKey.factory( x, y, e ), MultiViewMap.dummyValue ); + + for( MultiKey fullKeyY : mapY0.keySet() ) { + R.put( MultiKey.factory( x, + fullKeyY.get( 1 ), + e ), + MultiViewMap.dummyValue ); + + R.put( MultiKey.factory( x, + fullKeyY.get( 1 ), + fullKeyY.get( 2 ) ), + MultiViewMap.dummyValue ); + } + } } public void storeR( TempDescriptor x, diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 00f0735f..176bba26 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -1302,6 +1302,7 @@ public class DisjointAnalysis implements HeapAnalysis { FlatSESEEnterNode sese; FlatSESEExitNode fsexn; + Set edgeKeysForLoad; Set edgeKeysRemoved; //Stores the flatnode's reach graph at enter @@ -1455,12 +1456,17 @@ public class DisjointAnalysis implements HeapAnalysis { } } + edgeKeysForLoad = null; + if( doDefiniteReachAnalysis ) { + edgeKeysForLoad = new HashSet(); + } + if( shouldAnalysisTrack(fld.getType() ) ) { // transfer func - rg.assignTempXEqualToTempYFieldF(lhs, rhs, fld, fn); + rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld, fn, edgeKeysForLoad ); if( doDefiniteReachAnalysis ) { - definiteReachAnalysis.load( fn, lhs, rhs, fld ); + definiteReachAnalysis.load( fn, lhs, rhs, fld, edgeKeysForLoad ); } } @@ -1549,12 +1555,17 @@ public class DisjointAnalysis implements HeapAnalysis { } } + edgeKeysForLoad = null; + if( doDefiniteReachAnalysis ) { + edgeKeysForLoad = new HashSet(); + } + if( shouldAnalysisTrack(lhs.getType() ) ) { // transfer func - rg.assignTempXEqualToTempYFieldF(lhs, rhs, fdElement, fn); + rg.assignTempXEqualToTempYFieldF( lhs, rhs, fdElement, fn, edgeKeysForLoad ); if( doDefiniteReachAnalysis ) { - definiteReachAnalysis.load( fn, lhs, rhs, fdElement ); + definiteReachAnalysis.load( fn, lhs, rhs, fdElement, edgeKeysForLoad ); } } diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 02037c79..8d5038c0 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -494,7 +494,8 @@ public class ReachGraph { public void assignTempXEqualToTempYFieldF(TempDescriptor x, TempDescriptor y, FieldDescriptor f, - FlatNode currentProgramPoint + FlatNode currentProgramPoint, + Set edgeKeysForLoad ) { VariableNode lnX = getVariableNodeFromTemp(x); @@ -533,6 +534,16 @@ public class ReachGraph { continue; } + // for definite reach analysis only + if( edgeKeysForLoad != null ) { + assert f != null; + edgeKeysForLoad.add( new EdgeKey( hrnY.getID(), + hrnHrn.getID(), + f ) + ); + } + + TypeDescriptor tdNewEdge = mostSpecificType(edgeHrn.getType(), hrnHrn.getType() diff --git a/Robust/src/Util/MultiViewMap.java b/Robust/src/Util/MultiViewMap.java index 79e4eac2..a9ee707f 100644 --- a/Robust/src/Util/MultiViewMap.java +++ b/Robust/src/Util/MultiViewMap.java @@ -35,7 +35,7 @@ public class MultiViewMap { // for MultiViewMaps that don't need to use the value, // template on type Object and map every key to this dummy - public static Object dummy = new Integer( -12345 ); + public static Object dummyValue = new Integer( -12345 ); // If the entire contents of this map are fullKey -> value: