From fab31961e2c65a856dc405c3e4ed136498aec33d Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 23 Mar 2010 18:52:42 +0000 Subject: [PATCH] bug fix for primitive parameters, made a simple method for encapsulating the primitive/immutable test, leaving a hook for debugging the graph equals method that was useful, easy to turn back on --- .../Analysis/Disjoint/DisjointAnalysis.java | 34 +++++++++++++++---- Robust/src/Analysis/Disjoint/ReachGraph.java | 30 ++++++++++++++-- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 03714144..87df1db5 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -606,6 +606,14 @@ public class DisjointAnalysis { if( !rg.equals( rgPrev ) ) { setPartial( d, rg ); + /* + if( d.getSymbol().equals( "getInterpolatePatch" ) ) { + ReachGraph.dbgEquals = true; + rg.equals( rgPrev ); + ReachGraph.dbgEquals = false; + } + */ + // results for d changed, so enqueue dependents // of d for further analysis Iterator depsItr = getDependents( d ).iterator(); @@ -800,7 +808,7 @@ public class DisjointAnalysis { lhs = ffn.getDst(); rhs = ffn.getSrc(); fld = ffn.getField(); - if( !fld.getType().isImmutable() || fld.getType().isArray() ) { + if( shouldAnalysisTrack( fld.getType() ) ) { rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld ); } break; @@ -810,7 +818,7 @@ public class DisjointAnalysis { lhs = fsfn.getDst(); fld = fsfn.getField(); rhs = fsfn.getSrc(); - if( !fld.getType().isImmutable() || fld.getType().isArray() ) { + if( shouldAnalysisTrack( fld.getType() ) ) { rg.assignTempXFieldFEqualToTempY( lhs, fld, rhs ); } break; @@ -819,7 +827,7 @@ public class DisjointAnalysis { FlatElementNode fen = (FlatElementNode) fn; lhs = fen.getDst(); rhs = fen.getSrc(); - if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) { + if( shouldAnalysisTrack( lhs.getType() ) ) { assert rhs.getType() != null; assert rhs.getType().isArray(); @@ -841,7 +849,7 @@ public class DisjointAnalysis { lhs = fsen.getDst(); rhs = fsen.getSrc(); - if( !rhs.getType().isImmutable() || rhs.getType().isArray() ) { + if( shouldAnalysisTrack( rhs.getType() ) ) { assert lhs.getType() != null; assert lhs.getType().isArray(); @@ -856,7 +864,7 @@ public class DisjointAnalysis { case FKind.FlatNew: FlatNew fnn = (FlatNew) fn; lhs = fnn.getDst(); - if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) { + if( shouldAnalysisTrack( lhs.getType() ) ) { AllocSite as = getAllocSiteFromFlatNewPRIVATE( fnn ); rg.assignTempEqualToNewAlloc( lhs, as ); } @@ -970,7 +978,7 @@ public class DisjointAnalysis { case FKind.FlatReturnNode: FlatReturnNode frn = (FlatReturnNode) fn; rhs = frn.getReturnTemp(); - if( rhs != null && !rhs.getType().isImmutable() ) { + if( rhs != null && shouldAnalysisTrack( rhs.getType() ) ) { rg.assignReturnEqualToTemp( rhs ); } setRetNodes.add( frn ); @@ -1125,6 +1133,18 @@ public class DisjointAnalysis { } + public static boolean shouldAnalysisTrack( TypeDescriptor type ) { + // don't track primitive types, but an array + // of primitives is heap memory + if( type.isImmutable() ) { + return type.isArray(); + } + + // everything else is an object + return true; + } + + /* // return all allocation sites in the method (there is one allocation // site per FlatNew node in a method) @@ -1560,7 +1580,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) { for (Iterator it = classDesc.getFields(); it.hasNext();) { FieldDescriptor fd = (FieldDescriptor) it.next(); TypeDescriptor fieldType = fd.getType(); - if (!fieldType.isImmutable() || fieldType.isArray()) { + if (shouldAnalysisTrack( fieldType )) { HashMap newMap = new HashMap(); newMap.put(hrnNewest, fd); workSet.add(newMap); diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 501a62a8..3560467a 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -2121,8 +2121,14 @@ public class ReachGraph { for( int i = 0; i < fmCallee.numParameters(); ++i ) { // parameter defined here is the symbol in the callee - TempDescriptor tdParam = fmCallee.getParameter( i ); - VariableNode vnCallee = rgCallee.getVariableNodeFromTemp( tdParam ); + TempDescriptor tdParam = fmCallee.getParameter( i ); + + if( !DisjointAnalysis.shouldAnalysisTrack( tdParam.getType() ) ) { + // skip primitive/immutable parameters + continue; + } + + VariableNode vnCallee = rgCallee.getVariableNodeFromTemp( tdParam ); Iterator reItr = vnCallee.iteratorToReferencees(); while( reItr.hasNext() ) { @@ -2483,7 +2489,9 @@ public class ReachGraph { // 3.d) handle return value assignment if needed TempDescriptor returnTemp = fc.getReturnTemp(); - if( returnTemp != null && !returnTemp.getType().isImmutable() ) { + if( returnTemp != null && + DisjointAnalysis.shouldAnalysisTrack( returnTemp.getType() ) + ) { VariableNode vnLhsCaller = getVariableNodeFromTemp( returnTemp ); clearRefEdgesFrom( vnLhsCaller, null, null, true ); @@ -3501,6 +3509,10 @@ public class ReachGraph { } + + static boolean dbgEquals = false; + + // it is necessary in the equals() member functions // to "check both ways" when comparing the data // structures of two graphs. For instance, if all @@ -3514,18 +3526,30 @@ public class ReachGraph { public boolean equals( ReachGraph rg ) { if( rg == null ) { + if( dbgEquals ) { + System.out.println( "rg is null" ); + } return false; } if( !areHeapRegionNodesEqual( rg ) ) { + if( dbgEquals ) { + System.out.println( "hrn not equal" ); + } return false; } if( !areVariableNodesEqual( rg ) ) { + if( dbgEquals ) { + System.out.println( "vars not equal" ); + } return false; } if( !areRefEdgesEqual( rg ) ) { + if( dbgEquals ) { + System.out.println( "edges not equal" ); + } return false; } -- 2.34.1