From b85fecf5e9498428a6ee652125a208a381e1123c Mon Sep 17 00:00:00 2001 From: jjenista Date: Wed, 4 Feb 2009 00:46:18 +0000 Subject: [PATCH] Handle multi-dimensional arrays in disjointness analysis --- .../OwnershipAnalysis/OwnershipAnalysis.java | 10 +++---- .../OwnershipAnalysisTest/testArrays/makefile | 27 +++++++++++++++++++ .../testArrays/test.java | 24 +++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile create mode 100644 Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index cc5b0a55..850445b8 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -629,7 +629,7 @@ public class OwnershipAnalysis { lhs = ffn.getDst(); rhs = ffn.getSrc(); fld = ffn.getField(); - if( !fld.getType().isImmutable() ) { + if( !fld.getType().isImmutable() || fld.getType().isArray() ) { og.assignTempXEqualToTempYFieldF(lhs, rhs, fld); } break; @@ -639,7 +639,7 @@ public class OwnershipAnalysis { lhs = fsfn.getDst(); fld = fsfn.getField(); rhs = fsfn.getSrc(); - if( !fld.getType().isImmutable() ) { + if( !fld.getType().isImmutable() || fld.getType().isArray() ) { og.assignTempXFieldFEqualToTempY(lhs, fld, rhs); } break; @@ -648,7 +648,7 @@ public class OwnershipAnalysis { FlatElementNode fen = (FlatElementNode) fn; lhs = fen.getDst(); rhs = fen.getSrc(); - if( !lhs.getType().isImmutable() ) { + if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) { og.assignTempXEqualToTempYFieldF(lhs, rhs, fdElement); } break; @@ -657,7 +657,7 @@ public class OwnershipAnalysis { FlatSetElementNode fsen = (FlatSetElementNode) fn; lhs = fsen.getDst(); rhs = fsen.getSrc(); - if( !rhs.getType().isImmutable() ) { + if( !rhs.getType().isImmutable() || rhs.getType().isArray() ) { og.assignTempXFieldFEqualToTempY(lhs, fdElement, rhs); } break; @@ -665,7 +665,7 @@ public class OwnershipAnalysis { case FKind.FlatNew: FlatNew fnn = (FlatNew) fn; lhs = fnn.getDst(); - if( !lhs.getType().isImmutable() ) { + if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) { AllocationSite as = getAllocationSiteFromFlatNewPRIVATE(fnn); og.assignTempEqualToNewAlloc(lhs, as); } diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile new file mode 100644 index 00000000..f0449643 --- /dev/null +++ b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile @@ -0,0 +1,27 @@ +PROGRAM=test + +SOURCE_FILES=$(PROGRAM).java + +BUILDSCRIPT=~/research/Robust/src/buildscript +BSFLAGS= -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -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 diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java new file mode 100644 index 00000000..5d424b8e --- /dev/null +++ b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java @@ -0,0 +1,24 @@ +// +// We should see b and c aliased +// +// Also, a and f aliased, and e references a sub region from there +// + +public class TestArrays { + + static public void main( String[] args ) { + + int[] b = new int[10]; + int[] c = b; + + int[][] a = new int[40][30]; + + int d = a[2][1]; + int[] e = a[1]; + int[][] f = a; + + int [][] g = disjoint l1 new int[10][]; + int [][] h = disjoint l2 new int[10][]; + g[0] = h[0] = new int[5]; + } +} -- 2.34.1