From 87e5d7f8503330106e70ffc2501597014c401af3 Mon Sep 17 00:00:00 2001 From: jjenista Date: Mon, 25 Apr 2011 23:23:43 +0000 Subject: [PATCH] update the way this analysis visits every method reachable from program entry --- Robust/src/Analysis/ArrayReferencees.java | 48 +++++++++++------------ Robust/src/Main/Main.java | 8 ++-- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Robust/src/Analysis/ArrayReferencees.java b/Robust/src/Analysis/ArrayReferencees.java index 0aa28df6..cea2ec57 100644 --- a/Robust/src/Analysis/ArrayReferencees.java +++ b/Robust/src/Analysis/ArrayReferencees.java @@ -13,12 +13,8 @@ package Analysis; -import IR.State; -import IR.Descriptor; -import IR.ClassDescriptor; -import IR.MethodDescriptor; -import IR.TaskDescriptor; -import IR.TypeDescriptor; +import IR.*; +import Analysis.CallGraph.*; import IR.Flat.TempDescriptor; import IR.Flat.FlatMethod; import IR.Flat.FlatNode; @@ -35,8 +31,8 @@ public class ArrayReferencees { //////////////////////////////// // public interface //////////////////////////////// - public ArrayReferencees( State state ) { - init( state ); + public ArrayReferencees( State state, TypeUtil typeUtil, CallGraph callGraph ) { + init( state, typeUtil, callGraph ); } public boolean doesNotCreateNewReaching( FlatSetElementNode fsen ) { @@ -48,7 +44,9 @@ public class ArrayReferencees { - protected State state; + protected State state; + protected TypeUtil typeUtil; + protected CallGraph callGraph; // maintain the relation at every program point protected Hashtable fn2rel; @@ -60,27 +58,29 @@ public class ArrayReferencees { protected ArrayReferencees() {} - protected void init( State state ) { - this.state = state; + protected void init( State state, + TypeUtil typeUtil, + CallGraph callGraph ) { + this.state = state; + this.typeUtil = typeUtil; + this.callGraph = callGraph; fn2rel = new Hashtable(); noNewReaching = new HashSet(); buildRelation(); } protected void buildRelation() { - // just analyze every method of every class that the - // compiler has code for, fix if this is too costly - Iterator classItr = state.getClassSymbolTable().getDescriptorsIterator(); - while( classItr.hasNext() ) { - ClassDescriptor cd = (ClassDescriptor)classItr.next(); - - Iterator methodItr = cd.getMethods(); - while( methodItr.hasNext() ) { - MethodDescriptor md = (MethodDescriptor)methodItr.next(); - - FlatMethod fm = state.getMethodFlat( md ); - analyzeMethod( fm ); - } + + // analyze all methods transitively reachable from main + MethodDescriptor mdSourceEntry = typeUtil.getMain(); + FlatMethod fmMain = state.getMethodFlat( mdSourceEntry ); + + Set descriptorsToAnalyze = callGraph.getAllMethods( mdSourceEntry ); + descriptorsToAnalyze.add( mdSourceEntry ); + + for( MethodDescriptor md: descriptorsToAnalyze ) { + FlatMethod fm = state.getMethodFlat( md ); + analyzeMethod( fm ); } } diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 56dce135..6d6a192e 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -518,7 +518,7 @@ public class Main { if (state.OWNERSHIP) { Liveness liveness = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); + ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph); OwnershipAnalysis oa = new OwnershipAnalysis(state, tu, callgraph, @@ -533,13 +533,13 @@ public class Main { if (state.DISJOINT && !state.OOOJAVA) { Liveness l = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); + ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph); DisjointAnalysis da = new DisjointAnalysis(state, tu, callgraph, l, ar, null, null); } if (state.OOOJAVA) { Liveness l = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); + ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph); oooa = new OoOJavaAnalysis(state, tu, callgraph, l, ar); } @@ -575,7 +575,7 @@ public class Main { if (state.SCHEDULING) { // Use ownership analysis to get alias information Liveness liveness = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); + ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph); OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state, tu, callGraph, -- 2.34.1