private TaskDescriptor td;
protected HashSet edges = new HashSet();
public EGTaskNode(){
- super("default");
- this.fs = null;
- this.td = null;
+ this("default", null, null);
}
public EGTaskNode(String name){
- super(name);
- this.fs = null;
- this.td = null;
+ this(name, null, null);
}
public EGTaskNode(String name, FlagState fs){
- super(name);
- this.fs = fs;
- this.td = null;
+ this(name, fs, null);
}
public EGTaskNode(String name, TaskDescriptor td){
- super(name);
- this.fs = null;
- this.td = td;
+ this(name, null, td);
}
public EGTaskNode(String name, FlagState fs, TaskDescriptor td){
public boolean equals(Object o){
if(o instanceof EGTaskNode){
EGTaskNode tn=(EGTaskNode) o;
- return (tn.getLabel().compareTo(this.getLabel())==0) ? true : false;
+ return tn.getLabel().equals(getLabel());
}
return false;
}
public int type(){
return type;
}
-
-
}
import Util.Edge;
public class ExecutionGraph {
-
private TaskAnalysis taskanalysis;
private State state;
- private Hashtable graph;
private Hashtable executiongraph;
- private SymbolTable tasks;
-
+ private HashSet marked;
+ private HashSet processed;
+
public ExecutionGraph(State state, TaskAnalysis ta){
this.taskanalysis=ta;
this.state=state;
- this.tasks = this.state. getTaskSymbolTable();
- this.graph=new Hashtable();
this.executiongraph = new Hashtable();
+ this.marked=new HashSet();
+ this.processed=new HashSet();
}
public Hashtable getExecutionGraph(){
}
public void createExecutionGraph() throws java.io.IOException {
- /*Explore the taskanalysis structure*/
- System.out.println("------- BUILDING THE EXECUTION GRAPH -------");
+ //Cycle through classes
Enumeration e=taskanalysis.flagstates.keys();
while (e.hasMoreElements()) {
- System.out.println("\nBuilding class :");
ClassDescriptor cdtemp=(ClassDescriptor)e.nextElement();
- System.out.println("\t"+(cdtemp.getSymbol())+ "\n");
- exploreGraph(cdtemp);
- test();
- adapt(cdtemp);
+ HashSet<EGTaskNode> graph=exploreGraph(cdtemp);
+ adapt(cdtemp,graph);
}
printDOTFile();
-
}
- private void exploreGraph(ClassDescriptor cd) {
-
- LinkedList fifo = new LinkedList();
- Vector sourceNodeList = new Vector();
- Enumeration e;
- graph.clear();
-
- /* Search for starting nodes */
- Collection nodes = ((Hashtable)taskanalysis.flagstates.get(cd)).values();
- Iterator it = nodes.iterator();
+ private HashSet<EGTaskNode> exploreGraph(ClassDescriptor cd) {
+ LinkedList<FlagState> fifo = new LinkedList<FlagState>();
+ HashSet<EGTaskNode> nodes=new HashSet<EGTaskNode>();
+ Hashtable<FEdge, EGTaskNode> map=new Hashtable<FEdge, EGTaskNode>();
+
+ // Go through nodes
+ Iterator<FlagState> it = taskanalysis.getFlagStates(cd).iterator();
while (it.hasNext()) {
- FlagState fs = (FlagState)it.next();
- if(fs.isSourceNode()){
- sourceNodeList.addElement(fs);
- }
- }
-
- /* Perform the Breadth first search algorithm and build ExecutionGraph */
- FlagState fstemp, fstemp2;
- Iterator sourceit = sourceNodeList.iterator();
- while( sourceit.hasNext() ){
- FlagState fs = (FlagState)sourceit.next();
-
- fs.doMarking();
- fifo.addLast(fs);
-
- while ( !fifo.isEmpty() ){
-
- fstemp = (FlagState)fifo.getFirst();
- fifo.removeFirst();
-
- System.out.println("IN FS : "+fstemp.getTextLabel());
-
- Iterator edges = fstemp.edges();
- if (edges.hasNext()){
-
- //build corresponding nodes of the ExecutionGraph
- createNode(fstemp);
-
- //add the other non marked (prevent looping) fses to the fifo
- while(edges.hasNext()){
-
+ FlagState fs = it.next();
+ if(fs.isSourceNode()) {
+ for (Iterator allocit = ((Vector)fs.getAllocatingTasks()).iterator(); allocit.hasNext();) {
+ TaskDescriptor alloctask=(TaskDescriptor)allocit.next();
+ EGTaskNode srcnode=new EGTaskNode(alloctask.getSymbol(),alloctask);
+ nodes.add(srcnode);
+ srcnode.setSource();
+ for (Iterator edges = fs.edges(); edges.hasNext();){
FEdge edge = (FEdge)edges.next();
- fstemp2 = (FlagState)edge.getTarget();
-
- if ( !fstemp2.isMarked() ) {
- fstemp2.doMarking();
- fifo.addLast(fstemp2);
- }
- }
-
- //if the flagstate is not entirely processed, back into fifo
- if (!isFinished(fstemp)){
- fifo.addLast(fstemp);
- }
- }
-
- }
- }
- }
-
- private void createNode(FlagState fs){
- Enumeration allocatingtasks;
- EGTaskNode tn;
- EGTaskNode target;
- FEdge edge;
- //the idea is to look at the inedges to find the "parents" nodes. Then create the "children" and link them to the "parents".
- if (fs.isSourceNode()){
- //in the case of sourcenode, "parents" are the allocating tasks
- for (Iterator inedges = ((Vector)fs.getAllocatingTasks()).iterator(); inedges.hasNext();){
- String tname = new String(((TaskDescriptor)inedges.next()).getSymbol());
- //the hashkey for source EGTaskNodes is : nextfs+taskname.
- String key1 = new String(fs.getTextLabel()+tname);
- //get the parent
- if (graph.containsKey(key1)){
- tn = (EGTaskNode)graph.get(key1);
- }
- else{//if not existing, create it
- tn = new EGTaskNode(tname,(TaskDescriptor)tasks.get(tname));
- tn.setSource();
- }
- //create the children. the key is : nextfs+taskname+previousfs (that ensures that only one node can have that key).
- for (Iterator edges = fs.edges(); edges.hasNext();){
- edge = (FEdge)edges.next();
- target=new EGTaskNode(edge.getLabel(), fs, (TaskDescriptor)tasks.get(edge.getLabel()));
- String key2 = new String(((FlagState)edge.getTarget()).getTextLabel()+target.getName()+((FlagState)edge.getSource()).getTextLabel());
- //mark if is self loop
- if (((FlagState)edge.getTarget()).isMarked()){
- target.doSelfLoopMarking();
- }
- //check if child already exists. if not, create it.
- //link to the parent.
- if (graph.containsKey(key2)){
- target = (EGTaskNode)graph.get(key2);
- EGEdge newedge=new EGEdge(target);
- tn.addEdge(newedge);
- }
- else {
- EGEdge newedge=new EGEdge(target);
- tn.addEdge(newedge);
+ EGTaskNode targetnode=getNode(edge, map, nodes);
+ EGEdge newedge=new EGEdge(targetnode);
+ srcnode.addEdge(newedge);
}
- //put child in graph
- graph.put(key2, target);
}
- //put parent in graph
- graph.put(key1, tn);
}
- }
-
- for (Iterator inedges = fs.inedges(); inedges.hasNext();){
- //regular case, "parents" are the inedges.
- FEdge in=(FEdge)inedges.next();
- if (!in.isProcessed()){
- //the key to search is : nextfs+taskname+previousfs.
- String key1 = new String(fs.getTextLabel()+in.getLabel()+((FlagState)in.getSource()).getTextLabel());
- tn = (EGTaskNode)graph.get(key1);
- //if the TaskNode does not exist, that means that we are in the case of a loop.
- //The fs will not be entirely processed, will be put back in the fifo until the TaskNode has finaly been created.
- if (tn != null){
- //same process than with the sourcenode.
- for (Iterator edges = fs.edges(); edges.hasNext();){
- edge = (FEdge)edges.next();
- target=new EGTaskNode(edge.getLabel(), fs, (TaskDescriptor)tasks.get(edge.getLabel()));
- String key2 = new String(((FlagState)edge.getTarget()).getTextLabel()+target.getName()+((FlagState)edge.getSource()).getTextLabel());
- if (((String)((FlagState)edge.getTarget()).getTextLabel()).compareTo(fs.getTextLabel())==0){
- target.doSelfLoopMarking();
- }
- if (graph.containsKey(key2)){
- target = (EGTaskNode)graph.get(key2);
- EGEdge newedge=new EGEdge(target);
- tn.addEdge(newedge);
- }
- else {
- EGEdge newedge=new EGEdge(target);
- tn.addEdge(newedge);
- }
- graph.put(key2, target);
- }
- graph.put(key1, tn);
- in.setProcessed();
+ for(Iterator init=fs.inedges();init.hasNext();) {
+ FEdge inedge=(FEdge)init.next();
+ EGTaskNode srcnode=getNode(inedge, map, nodes);
+ for(Iterator outit=fs.edges();outit.hasNext();) {
+ FEdge outedge=(FEdge)outit.next();
+ EGTaskNode dstnode=getNode(outedge, map, nodes);
+ EGEdge newedge=new EGEdge(dstnode);
+ srcnode.addEdge(newedge);
}
}
- }
- }
+
+ }
+ return nodes;
+ }
+ private EGTaskNode getNode(FEdge fedge, Hashtable<FEdge, EGTaskNode> map, HashSet<EGTaskNode> nodes) {
+ if (map.containsKey(fedge))
+ return map.get(fedge);
+ EGTaskNode egnode=new EGTaskNode(fedge.getLabel(), (FlagState) fedge.getSource(), fedge.getTask());
+ if (fedge.getTarget()==fedge.getSource())
+ egnode.doSelfLoopMarking();
+ map.put(fedge, egnode);
+ nodes.add(egnode);
+ return egnode;
+ }
+
//put the graph into executiongraph
- private void adapt(ClassDescriptor cd) {
+ private void adapt(ClassDescriptor cd, HashSet<EGTaskNode> nodes) {
Vector tasknodes = new Vector();
- tasknodes.addAll(graph.values());
+ tasknodes.addAll(nodes);
executiongraph.put(cd,tasknodes);
}
+
//print the contain of graph
- private void test() {
+ private void test(Hashtable graph) {
System.out.println("\nGraph contains :");
Collection c = graph.values();
for ( Iterator it = c.iterator(); it.hasNext();){
}
}
- //test if a flagstate has been entirely processed
- private boolean isFinished(FlagState fs){
-
- for (Iterator inedges = fs.inedges(); inedges.hasNext();){
-
- FEdge in=(FEdge)inedges.next();
-
- if (!in.isProcessed()){
- String key1 = new String(fs.getTextLabel()+in.getLabel()+((FlagState)in.getSource()).getTextLabel());
-
- if (graph.get(key1)==null){
- //except for the case of self loop, if the pointed tn is not present, fs is not totally processed
- if (((String)((FlagState)in.getSource()).getTextLabel()).compareTo(fs.getTextLabel())!=0){
- return false;
- }
- }
-
- }
- }
- return true;
- }
-
-
- //********DEBUG
//create dot files execution_classname_.dot
private void printDOTFile()throws java.io.IOException {
Enumeration e = executiongraph.keys();
if (tn.isMultipleParams()) output.println(", color=blue");
output.println("];");
-
for(Iterator it2 = tn.edges();it2.hasNext();){
output.println("\t"+tn.getLabel()+" -> "+((EGTaskNode)((EGEdge)it2.next()).getTarget()).getLabel()+";");
}
}
}
- //*********************
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
public class FEdge extends Edge {
private String label;
+ private TaskDescriptor td;
/** Class Constructor
*
*/
- public FEdge(FlagState target, String label) {
+ public FEdge(FlagState target, String label, TaskDescriptor td) {
super(target);
this.label = label;
+ this.td=td;
}
public String getLabel() {
public int hashCode(){
return target.hashCode()^label.hashCode();
}
+
+ public TaskDescriptor getTask() {
+ return td;
+ }
public boolean equals(Object o) {
if (o instanceof FEdge) {
FEdge e=(FEdge)o;
- return e.label.equals(label)&&
- e.target.equals(target);
+ if (e.label.equals(label)&&
+ e.target.equals(target)&&
+ e.td==td)
+ return true;
}
return false;
}
private boolean issourcenode;
private Vector tasks;
- private boolean marked=false;
-
-
/** Class constructor
* Creates a new flagstate with all flags set to false.
* @param cd ClassDescriptor
return uid;
}
- public boolean isMarked() {
- return marked;
- }
-
- public void doUnmarking() {
- marked = false;
- }
-
- public void doMarking() {
- marked = true;
- }
-
/** Accessor method
* @param fd FlagDescriptor
* @return true if the flagstate contains fd else false.
return issourcenode;
}
- /** Sets the flagstate as a source node.
+ /** Sets the flagstate as a source node.
*/
- public void setAsSourceNode(){
- if(!issourcenode){
- issourcenode=true;
- this.tasks=new Vector();
- }
- }
-
- public void addAllocatingTask(TaskDescriptor task){
- tasks.add(task);
- }
-
- public Vector getAllocatingTasks(){
- return tasks;
- }
-
+ public void setAsSourceNode(){
+ if(!issourcenode){
+ issourcenode=true;
+ this.tasks=new Vector();
+ }
+ }
+
+ public void addAllocatingTask(TaskDescriptor task){
+ tasks.add(task);
+ }
+
+ public Vector getAllocatingTasks(){
+ return tasks;
+ }
+
public String toString() {
return cd.toString()+getTextLabel();
import java.io.*;
import Util.Edge;
-public class OptionalTaskDescriptor{
+public class OptionalTaskDescriptor {
public TaskDescriptor td;
public HashSet flagstates;
public int depth;
private static int nodeid=0;
private int uid;
- protected OptionalTaskDescriptor(TaskDescriptor td, HashSet flagstates, int depth, Predicate predicate){
+ protected OptionalTaskDescriptor(TaskDescriptor td, HashSet flagstates, int depth, Predicate predicate) {
this.td = td;
this.flagstates = flagstates;
this.depth = depth;
this.exitfses = new HashSet();
this.predicate = predicate;
this.uid = OptionalTaskDescriptor.nodeid++;
-
}
public boolean equals(Object o){
if (o instanceof OptionalTaskDescriptor) {
OptionalTaskDescriptor otd = (OptionalTaskDescriptor) o;
- /*if (this.td.getSymbol().compareTo(otd.td.getSymbol())==0)
- if(this.flagstates.equals(otd.flagstates))
- if(this.predicate.equals(otd.predicate))
- return true;
- return false;*/
- if(this.hashCode()==otd.hashCode())
+ if (td==otd.td&&
+ flagstates.equals(otd.flagstates)&&
+ predicate.equals(otd.predicate))
return true;
- return false;
}
- else return false;
-
+ return false;
}
public int hashCode() {
public int getuid() {
return uid;
}
-
-
}
import IR.Flat.*;
import Util.Edge;
-public class Predicate{
+public class Predicate {
public Hashtable<String, VarDescriptor> vardescriptors;
public Hashtable<String, HashSet<FlagExpressionNode>> flags;
public Hashtable<String, TagExpressionList> tags; //if there is a tag change, we stop the analysis
}
public boolean equals(Object o){
- if(o instanceof Predicate){
+ if(o instanceof Predicate) {
Predicate p = (Predicate) o;
- if(this.vardescriptors.equals(p.vardescriptors))
+ if(vardescriptors.equals(p.vardescriptors))
return true;
- return false;
}
- else return false;
+ return false;
}
public int hashCode(){
return vardescriptors.hashCode();
}
-
-
}
System.out.println("\t"+classname+ "\n");
//get the graph result of executiongraph class
Vector nodes = new Vector();
- nodes = getConcernedClass( classname );
+ nodes = getConcernedClass(classname);
if(nodes==null) {
System.out.println("Impossible to find "+classname+". Unexpected.");
continue;
- }
- else if(nodes.size()==0){
+ } else if (nodes.size()==0) {
System.out.println("Nothing to do");
continue;
}
if (extremity.isMarked() || !((Iterator)extremity.edges()).hasNext()){
if (!((Iterator)extremity.edges()).hasNext()) extremity.mark();
reducedgraph.put(extremity.getuid(), extremity);
- }
- else {
+ } else {
//do the marking
process(extremity);
reducedgraph.put(extremity.getuid(), extremity);
extremity.mark();
- //calls doGraphMarking recursively with the next nodes as params
+ //calls doGraphMarking recursively with the next nodes as
+ //params
for( Iterator it = extremity.edges(); it.hasNext(); ){
EGEdge edge = (EGEdge)it.next();
doGraphMarking((EGTaskNode)edge.getTarget());
private HashSet createIntersection( HashSet A, HashSet B){
HashSet result = new HashSet();
- //HashSet processed = new HashSet();
for(Iterator b_it = B.iterator(); b_it.hasNext();){
OptionalTaskDescriptor otd_b = (OptionalTaskDescriptor)b_it.next();
for(Iterator a_it = A.iterator(); a_it.hasNext();){
OptionalTaskDescriptor otd_a = (OptionalTaskDescriptor)a_it.next();
if(((String)otd_a.td.getSymbol()).compareTo((String)otd_b.td.getSymbol())==0){
- //processed.add(otd_a);
- //processed.add(otd_b);
-
HashSet newfs = new HashSet();
newfs.addAll(otd_a.flagstates);
newfs.addAll(otd_b.flagstates);
int newdepth = (otd_a.depth < otd_b.depth) ? otd_a.depth : otd_b.depth;
OptionalTaskDescriptor newotd = new OptionalTaskDescriptor(otd_b.td, newfs, newdepth, combinePredicates(otd_a.predicate, otd_b.predicate));
if(optionaltaskdescriptors.get(processedclass).get(newotd)!=null){
- //System.out.println("OTD found");
- System.out.println("before "+newotd.getuid());
newotd = (OptionalTaskDescriptor)((Hashtable)optionaltaskdescriptors.get(processedclass)).get(newotd);
- System.out.println("after "+newotd.getuid());
}
else optionaltaskdescriptors.get(processedclass).put(newotd, newotd);
result.add(newotd);
}
}
- /* for(Iterator a_it = A.iterator(); a_it.hasNext();){
- OptionalTaskDescriptor otd = (OptionalTaskDescriptor)a_it.next();
- if(!processed.contains(otd))
- optionaltaskdescriptors.get(processedclass).remove(otd);
- }
- for(Iterator b_it = B.iterator(); b_it.hasNext();){
- OptionalTaskDescriptor otd = (OptionalTaskDescriptor)b_it.next();
- if(!processed.contains(otd))
- optionaltaskdescriptors.get(processedclass).remove(otd);
- } */
return result;
}
VarDescriptor vd = (VarDescriptor)varit.next();
if(result.vardescriptors.containsKey(vd.getName())) System.out.println("Already in ");
else {
- //System.out.println("Not already in...");
result.vardescriptors.put(vd.getName(), vd);
}
}
VarDescriptor vd = (VarDescriptor)varit.next();
HashSet bflags = B.flags.get(vd.getName());
if( bflags == null ){
- //System.out.println("not in B");
continue;
}
else{
if (fn1.kind()==FKind.FlatFlagActionNode) {
FlatFlagActionNode ffan=(FlatFlagActionNode)fn1;
if (ffan.getTaskType() == FlatFlagActionNode.TASKEXIT) {
- //***
- //System.out.println("TASKEXIT");
- //***
HashSet tempset = new HashSet();
for(Iterator it_fs = otd.flagstates.iterator(); it_fs.hasNext();){
FlagState fstemp = (FlagState)it_fs.next();
fstemp=fstemp.setFlag(tfp.getFlag(),ffan.getFlagChange(tfp));
}
}
- //System.out.println("new flag : "+fstemp.getTextLabel());
tempset.add(fstemp);
}
result.add(tempset);
continue; // avoid queueing the return node if reachable
}
}else if (fn1.kind()==FKind.FlatReturnNode) {
- //***
- //System.out.println("RETURN NODE REACHABLE WITHOUT TASKEXITS");
- //***
result.add(otd.flagstates);
}
}
otd.exitfses=result;
}
-
-
}
* @param state a flattened State object
* @see State
*/
- public TaskAnalysis(State state, TagAnalysis taganalysis)
- {
+ public TaskAnalysis(State state, TagAnalysis taganalysis) {
this.state=state;
this.typeutil=new TypeUtil(state);
this.taganalysis=taganalysis;
-
}
- /** Builds a table of flags for each class in the Bristlecone program.
- * It creates two hashtables: one which holds the ClassDescriptors and arrays of
- * FlagDescriptors as key-value pairs; the other holds the ClassDescriptor and the
- * number of external flags for that specific class.
+ /** Builds a table of flags for each class in the Bristlecone
+ * program. It creates two hashtables: one which holds the
+ * ClassDescriptors and arrays of * FlagDescriptors as key-value
+ * pairs; the other holds the ClassDescriptor and the * number of
+ * external flags for that specific class.
*/
private void getFlagsfromClasses() {
flags=new Hashtable();
extern_flags = new Hashtable();
- /** Iterate through the classes used in the program to build the table of flags
+ /** Iterate through the classes used in the program to build
+ * the table of flags
*/
for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator();it_classes.hasNext();) {
}
}
}
- /** Method which starts up the analysis
- *
+ /** Method which starts up the analysis
*/
public void taskAnalysis() throws java.io.IOException {
sourcenodes.put(fsstartup,fsstartup);
toprocess.add(fsstartup);
- /** Looping through the flagstates in the toprocess queue to perform the state analysis */
+ /** Looping through the flagstates in the toprocess queue to
+ * perform the state analysis */
while (!toprocess.isEmpty()) {
FlagState trigger=toprocess.poll();
createPossibleRuntimeStates(trigger);
TaskDescriptor td = (TaskDescriptor)it_tasks.next();
String taskname=td.getSymbol();
- /** counter to keep track of the number of parameters (of the task being analyzed) that
- * are satisfied by the flagstate.
+ /** counter to keep track of the number of parameters (of the
+ * task being analyzed) that are satisfied by the flagstate.
*/
int trigger_ctr=0;
TempDescriptor temp=null;
FlagExpressionNode fen=td.getFlag(td.getParameter(i));
TagExpressionList tel=td.getTag(td.getParameter(i));
- /** Checking to see if the parameter is of the same type/class as the
- * flagstate's and also if the flagstate fs triggers the given task*/
+ /** Checking to see if the parameter is of the same
+ * type/class as the flagstate's and also if the
+ * flagstate fs triggers the given task*/
+
if (typeutil.isSuperorType(td.getParamType(i).getClassDesc(),cd)
&& isTaskTrigger_flag(fen,fs)
&& isTaskTrigger_tag(tel,fs)) {
if (fn1.kind()==FKind.FlatReturnNode) {
/* Self edge */
- FEdge newedge=new FEdge(fs, taskname);
+ FEdge newedge=new FEdge(fs, taskname, td);
fs.addEdge(newedge);
continue;
} else if (fn1.kind()==FKind.FlatFlagActionNode) {
}
//seen this node already
fs_taskexit=canonicalizeFlagState(sourcenodes,fs_taskexit);
- FEdge newedge=new FEdge(fs_taskexit,taskname);
+ FEdge newedge=new FEdge(fs_taskexit,taskname, td);
fs.addEdge(newedge);
}
continue;
}
/** Returns the flag states for the class descriptor. */
- public Set getFlagStates(ClassDescriptor cd) {
+ public Set<FlagState> getFlagStates(ClassDescriptor cd) {
if (flagstates.containsKey(cd))
- return ((Hashtable)flagstates.get(cd)).keySet();
+ return ((Hashtable<FlagState, FlagState>)flagstates.get(cd)).keySet();
else
return null;
}
private void createPossibleRuntimeStates(FlagState fs) {
- ClassDescriptor cd = fs.getClassDescriptor();
- Hashtable<FlagState,FlagState> sourcenodes=(Hashtable<FlagState,FlagState>)flagstates.get(cd);
- FlagDescriptor[] fd=(FlagDescriptor[])flags.get(cd);
- int externs=((Integer)extern_flags.get(cd)).intValue();
-
- if(externs==0)
- return;
-
- int noOfIterations=(1<<externs) - 1;
- boolean BoolValTable[]=new boolean[externs];
-
-
- for(int i=0; i < externs ; i++) {
- BoolValTable[i]=fs.get(fd[i]);
- }
-
- for(int k=0; k<noOfIterations; k++) {
- for(int j=0; j < externs ;j++) {
- if ((k% (1<<j)) == 0)
- BoolValTable[j]=(!BoolValTable[j]);
- }
+ ClassDescriptor cd = fs.getClassDescriptor();
+ Hashtable<FlagState,FlagState> sourcenodes=(Hashtable<FlagState,FlagState>)flagstates.get(cd);
+ FlagDescriptor[] fd=(FlagDescriptor[])flags.get(cd);
+ int externs=((Integer)extern_flags.get(cd)).intValue();
- FlagState fstemp=fs;
+ if(externs==0)
+ return;
- for(int i=0; i < externs;i++) {
- fstemp=fstemp.setFlag(fd[i],BoolValTable[i]);
- }
- if (!sourcenodes.containsKey(fstemp))
- toprocess.add(fstemp);
-
- fstemp=canonicalizeFlagState(sourcenodes,fstemp);
- fs.addEdge(new FEdge(fstemp,"Runtime"));
- }
- }
+ int noOfIterations=(1<<externs) - 1;
+ boolean BoolValTable[]=new boolean[externs];
- public Vector getRootNodes(ClassDescriptor cd){
- return (Vector)cdtorootnodes.get(cd);
+
+ for(int i=0; i < externs ; i++) {
+ BoolValTable[i]=fs.get(fd[i]);
}
+
+ for(int k=0; k<noOfIterations; k++) {
+ for(int j=0; j < externs ;j++) {
+ if ((k% (1<<j)) == 0)
+ BoolValTable[j]=(!BoolValTable[j]);
+ }
+
+ FlagState fstemp=fs;
+
+ for(int i=0; i < externs;i++) {
+ fstemp=fstemp.setFlag(fd[i],BoolValTable[i]);
+ }
+ if (!sourcenodes.containsKey(fstemp))
+ toprocess.add(fstemp);
-
-
+ fstemp=canonicalizeFlagState(sourcenodes,fstemp);
+ fs.addEdge(new FEdge(fstemp,"Runtime", null));
+ }
+ }
+
+ public Vector getRootNodes(ClassDescriptor cd){
+ return (Vector)cdtorootnodes.get(cd);
+ }
}
return -1;
}
#ifdef MAC
- myIpAddr = getMyIpAddr("en0");
+ myIpAddr = getMyIpAddr("en1");
#else
myIpAddr = getMyIpAddr("eth0");
#endif
public class Edge {
protected GraphNode target;
protected GraphNode source;
- protected boolean processed = false;
-
protected String dotnodeparams = new String();
return target;
}
- public void setProcessed() {
- processed = true;
- }
-
- public boolean isProcessed(){
- return processed;
- }
-
public void setDotNodeParameters(String param) {
if (param == null) {
throw new NullPointerException();