// reserved IDs for special purposes
static private int uniqueIDcount = 10;
+ // special purpose region for "null"
+ // included in every graph
+ static public int nullRegionID = 9;
+
// Use these data structures to track progress of
// processing all methods in the program, and by methods
}
break;
+ case FKind.FlatLiteralNode:
+ FlatLiteralNode fln = (FlatLiteralNode) fn;
+ if( fln.getValue() == null ) {
+ // when we set something to null, use the special
+ // "null" heap region as the target
+ lhs = fln.getDst();
+ og.assignTempXEqualToNull(lhs);
+ }
+ break;
+
case FKind.FlatOpNode:
FlatOpNode fon = (FlatOpNode) fn;
if( fon.getOp().getOp() == Operation.ASSIGN ) {
public Hashtable<Integer, TokenTuple> paramIndex2paramTokenSecondaryStar;
+ public HeapRegionNode hrnNull;
+
+
public OwnershipGraph(int allocationDepth, TypeUtil typeUtil) {
this.allocationDepth = allocationDepth;
this.typeUtil = typeUtil;
paramIndex2paramTokenSecondaryStar = new Hashtable<Integer, TokenTuple >();
allocationSites = new HashSet <AllocationSite>();
+
+ hrnNull = createNewHeapRegionNode( OwnershipAnalysis.nullRegionID,
+ false,
+ false,
+ false,
+ false,
+ null,
+ null,
+ null,
+ "null" );
}
}
+ public void assignTempXEqualToNull(TempDescriptor x) {
+
+ LabelNode lnX = getLabelNodeFromTemp(x);
+
+ clearReferenceEdgesFrom(lnX, null, null, true);
+
+ ReferenceEdge edgeNew = new ReferenceEdge(lnX,
+ hrnNull,
+ null,
+ null,
+ false,
+ null);
+
+ addReferenceEdge(lnX, hrnNull, edgeNew);
+ }
+
+
public void assignTypedTempXEqualToTempY(TempDescriptor x,
TempDescriptor y,
TypeDescriptor type) {
HashSet<HeapRegionNode> possibleCallerHRNs = new HashSet<HeapRegionNode>();
+ if( hrnCallee == ogCallee.hrnNull ) {
+ // this is the null heap region
+ possibleCallerHRNs.add( id2hrn.get( hrnCallee.getID() ) );
+ return possibleCallerHRNs;
+ }
+
Set<Integer> paramIndicesCallee_p = ogCallee.idPrimary2paramIndexSet .get( hrnCallee.getID() );
Set<Integer> paramIndicesCallee_s = ogCallee.idSecondary2paramIndexSet.get( hrnCallee.getID() );
--- /dev/null
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -mainclass Test -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+ eog *.png &
+
+PNGs: DOTs
+ d2p *COMPLETE*.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+ $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+ rm -f $(PROGRAM).bin
+ rm -fr tmpbuilddirectory
+ rm -f *~
+ rm -f *.dot
+ rm -f *.png
+ rm -f aliases.txt
--- /dev/null
+public class Foo {
+ public Foo() {}
+
+ Bar x;
+ Bar y;
+}
+
+public class Bar {
+ public Bar() {}
+}
+
+
+public class Test {
+
+ static public void main( String[] args ) {
+
+ Foo foo = new Foo();
+
+ foo.x = new Bar();
+ foo.y = new Bar();
+
+ Bar a1 = foo.x;
+ }
+}
--- /dev/null
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -mainclass Test -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+ eog *.png &
+
+PNGs: DOTs
+ d2p *COMPLETE*.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+ $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+ rm -f $(PROGRAM).bin
+ rm -fr tmpbuilddirectory
+ rm -f *~
+ rm -f *.dot
+ rm -f *.png
+ rm -f aliases.txt
--- /dev/null
+public class Foo {
+ public Foo() {}
+
+ Bar x;
+ Bar y;
+}
+
+public class Bar {
+ public Bar() {}
+}
+
+
+public class Test {
+
+ static public void main( String[] args ) {
+
+ Foo foo = new Foo();
+
+ foo.x = new Bar();
+ foo.y = new Bar();
+
+ Bar a1 = foo.x;
+
+ a1 = null;
+ }
+}