java: out of heap space bug fix
authoradash <adash>
Tue, 19 Feb 2008 21:14:14 +0000 (21:14 +0000)
committeradash <adash>
Tue, 19 Feb 2008 21:14:14 +0000 (21:14 +0000)
Robust/src/Analysis/Prefetch/PrefetchAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/buildscript

index 6296abdc8d01fde738cc550cbc4353d12d8623c0..97017bcce5813819595380bed30d9fa6295b7a65 100644 (file)
@@ -29,7 +29,7 @@ public class PrefetchAnalysis {
        public static final float PREFETCH_THRESHOLD_PROB = (float)0.30;
        public static final float BRANCH_TRUE_EDGE_PROB = (float)0.5;
        public static final float BRANCH_FALSE_EDGE_PROB = (float)0.5;
-
+       
        public PrefetchAnalysis(State state, CallGraph callgraph, TypeUtil typeutil) {
                this.typeutil=typeutil;
                this.state=state;
@@ -37,6 +37,8 @@ public class PrefetchAnalysis {
                prefetch_hash = new Hashtable<FlatNode, Hashtable<PrefetchPair,Float>>();
                pmap_hash = new Hashtable<FlatNode, Hashtable<FlatNode, PairMap>>();
                DoPrefetch();
+               prefetch_hash = null;
+               pmap_hash = null;
        }
 
        /** This function returns true if a tempdescriptor object is found in the array of descriptors
@@ -115,6 +117,8 @@ public class PrefetchAnalysis {
                        if(newprefetchset.size() > 0) {
                                addFlatPrefetchNode(newprefetchset);
                        }
+                       newprefetchset = null;
+                       pset1_hash = null;
                }
        }
 
@@ -128,6 +132,9 @@ public class PrefetchAnalysis {
                        prefetch_hash.put(fn, nodehash);
                        tovisit.remove(fn);
                }
+
+               nodehash = null;
+
                /* Visit and process nodes */
                tovisit = fm.getNodeSet(); 
                while(!tovisit.isEmpty()) {
@@ -191,7 +198,9 @@ public class PrefetchAnalysis {
                                                child_prefetch_set_copy = (Hashtable<PrefetchPair,Float>) prefetch_hash.get(child_node).clone();
                                        }
                                        processFlatCondBranch(curr, child_prefetch_set_copy, i, branch_prefetch_set, parentpmap);
+                                       parentpmap = null;
                                }
+                               branch_prefetch_set = null;
                                break;
                        case FKind.FlatOpNode:
                                processFlatOpNode(curr, child_prefetch_set_copy, parentpmap);
@@ -230,6 +239,10 @@ public class PrefetchAnalysis {
                                System.out.println("NO SUCH FLATNODE");
                                break;
                }
+
+               /* Free Heap Memory */
+               child_prefetch_set_copy = null;
+               parentpmap = null;
        }
 
        /**This function compares all the prefetch pairs in a Prefetch set hashtable and
@@ -377,6 +390,11 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+
+               /* Free Heap Memory */
+               currcopy = null;
+               tocompare = null;
+               pm = null;
        }
 
        /** This function processes the prefetch set of a FlatElementNode
@@ -487,6 +505,11 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+
+               /* Free heap memory */
+               currcopy = null;
+               tocompare = null;
+               pm = null;
        }
 
        /** This function processes the prefetch set of a FlatSetFieldNode
@@ -566,6 +589,10 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function processes the prefetch set of a FlatSetElementNode
@@ -645,6 +672,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function applies rules and does analysis for a FlatOpNode 
@@ -686,6 +716,8 @@ public class PrefetchAnalysis {
                                                }
                                                child_prefetch_set_copy.remove(newpp);
                                        }
+                                       newdesc = null;
+                                       newpp = null;
                                        /* For cases like x=y  with child prefetch set r[i].x, r[x].p, r[p+x].q*/
                                } else if(isTempDescFound(copyofchildpp, currfopn.getDest())) {
                                        ArrayList<Descriptor> newdesc = new ArrayList<Descriptor>();
@@ -706,6 +738,8 @@ public class PrefetchAnalysis {
                                                }
                                                child_prefetch_set_copy.remove(newpp);
                                        }
+                                       newdesc = null;
+                                       newpp = null;
                                }else {
                                        continue;
                                }
@@ -769,6 +803,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function processes a FlatLiteralNode where cases such as
@@ -851,6 +888,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function processes a FlatMethod where the method propagates
@@ -886,6 +926,8 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               tocompare = null;
+               pm = null;
        }
 
        /** This Function processes the FlatCalls 
@@ -930,6 +972,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function handles the processes the FlatNode of type FlatCondBranch
@@ -1022,6 +1067,9 @@ public class PrefetchAnalysis {
                                prefetch_hash.put(curr,branch_prefetch_set); 
                        } 
                }
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** If FlatNode is not concerned with the prefetch set of its Child then propagate 
@@ -1058,6 +1106,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                }
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This functions processes for FlatNewNode
@@ -1146,6 +1197,9 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This functions processes for FlatTagDeclaration
@@ -1190,6 +1244,10 @@ public class PrefetchAnalysis {
                        /* Overwrite the new prefetch set to the global hash table */
                        prefetch_hash.put(curr,tocompare); 
                } 
+
+               /* Free heap memory */
+               tocompare = null;
+               pm = null;
        }
 
        /** This function prints the Prefetch pairs of a given flatnode */
@@ -1226,6 +1284,11 @@ public class PrefetchAnalysis {
                        }
                }
 
+               /* Free Heap Memory */
+               pset1_init = null;
+               newtovisit = null;
+
+               /* Delete redundant and subset prefetch pairs */
                delSubsetPPairs();
        
                /* Start with a top down sorted order of nodes */
@@ -1278,6 +1341,11 @@ public class PrefetchAnalysis {
                                        ppairs.remove(pp);
                                }
                        }
+
+                       /* Free heap memory */
+                       pplist = null;
+                       pplength = null;
+                       ppisMod = null;
                }
        }
 
@@ -1464,6 +1532,12 @@ public class PrefetchAnalysis {
                                newprefetchset.put(fn, s); 
                        }
                }
+
+               /* Free heap memory */
+               pset1 = null;
+               pset2 = null;
+               newpset = null;
+               prefetchset = null;
        }
 
        private void addFlatPrefetchNode(Hashtable<FlatNode, HashSet<PrefetchPair>> newprefetchset) {
index 44c7efcddfb42df3d7de708223f11f55dc3777b0..8b24c523349e24ca3ea273ddeacd167e838dd1a0 100644 (file)
@@ -1298,7 +1298,6 @@ public class BuildCode {
                    current_node=current_node.getNext(0);
            } else throw new Error();
        }
-
        output.println("}\n\n");
     }
 
@@ -1432,25 +1431,9 @@ public class BuildCode {
            int i,j;
           
            if (state.PREFETCH) {
-                   Iterator it = fpn.hspp.iterator();
                    output.println("/* prefetch */");
                    output.println("; /* empty statement to avoid compiler error */");
-
-                   /* TODO Add support for arrays, Currently handles only field pointers*/
-                   /* The while loop below removes all prefetch tuples with arrays from the set of prefetches */
-                   /*
-                   while(it.hasNext()) {
-                           PrefetchPair pp = (PrefetchPair) it.next();
-                           for(i = 0; i < pp.desc.size(); i++) {
-                                   if(pp.getDescAt(i) instanceof IndexDescriptor) {
-                                           fpn.hspp.remove((PrefetchPair) pp);
-                                           it = fpn.hspp.iterator();
-                                           break;
-                                   }
-                           }
-                   }
-                   */
-                   //it = fpn.hspp.iterator();
+                   Iterator it = fpn.hspp.iterator();
                    String oidlist = new String();
                    while(it.hasNext()) {
                            PrefetchPair pp = (PrefetchPair) it.next();
@@ -1513,10 +1496,15 @@ public class BuildCode {
                                    count+", fieldarry_"+count+");");
                    count++;
            }   
+
+           /* Free heap memory */
+           fieldoffset = null;
+           endoffset = null;
+           oids = null;
     }   
 
     public void generateInsideTransCode(FlatMethod fm, LocalityBinding lb,PrintWriter output,PrefetchPair pp,Vector oids, Vector fieldoffset,Vector endoffset, int tuplecount){
-           int i;
+           int i,j;
            short offsetcount = 0;
 
            Object newdesc = pp.desc.get(0);
@@ -1543,6 +1531,7 @@ public class BuildCode {
                                    generateTemp(fm, pp.base, lb) + "[" + tstlbl + "] : NULL)");
                    oids.add(oid);
            }
+
            for(i = 1; i < pp.desc.size(); i++) {
                    TypeDescriptor newtd;
                    String newfieldoffset;
@@ -1551,10 +1540,12 @@ public class BuildCode {
                    if(desc instanceof FieldDescriptor) {
                            Object prevdesc = pp.getDescAt(i-1);
                            if(prevdesc instanceof IndexDescriptor){
-                                   if((i-1) == 0)
+                                   if((i-1) == 0) {
                                            newtd = pp.base.getType(); 
-                                   //FIXME currently handles one dimensional arrays
-                                   newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+                                   } else {
+                                           //FIXME currently handles one dimensional arrays
+                                           newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+                                   }
                            } else {
                                    newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType();
                            }
@@ -1563,8 +1554,8 @@ public class BuildCode {
                            fieldoffset.add(newfieldoffset);
                    } else {
                            String tstlbl = new String();
-                           for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
-                                   tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+                           for(j = 0; j < ((IndexDescriptor)desc).tddesc.size(); j++) {
+                                   tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+";
                            }
                            tstlbl += ((IndexDescriptor)desc).offset.toString();
                            newfieldoffset = new String("(short)("+tstlbl+")");
@@ -1581,7 +1572,7 @@ public class BuildCode {
     }
 
     public void generateOutsideTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp, Vector oids, Vector fieldoffset, Vector endoffset, int tuplecount) {
-           int i;
+           int i,j;
            short offsetcount = 0;
 
            String oid = new String(" (unsigned int) (" + generateTemp(fm, pp.base, lb)+ ")");
@@ -1597,8 +1588,12 @@ public class BuildCode {
                            } else {
                                    Object prevdesc = pp.getDescAt(i-1);
                                    if(prevdesc instanceof IndexDescriptor){
-                                           //FIXME currently handles one dimensional arrays
-                                           newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+                                           if((i-1) == 0) {
+                                                   newtd = pp.base.getType(); 
+                                           } else {
+                                                   //FIXME currently handles one dimensional arrays
+                                                   newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType();
+                                           }
                                    } else {
                                            newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType();
                                    }
@@ -1607,8 +1602,8 @@ public class BuildCode {
                                            ((FieldDescriptor)desc).getSafeSymbol()+ "))");
                    } else {
                            String tstlbl = new String();
-                           for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
-                                   tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+                           for(j = 0; j < ((IndexDescriptor)desc).tddesc.size(); j++) {
+                                   tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+";
                            }
                            tstlbl += ((IndexDescriptor)desc).offset.toString();
                            newfieldoffset = new String("(short)("+tstlbl+")");
@@ -1626,7 +1621,7 @@ public class BuildCode {
     }
 
     public void generateLocalTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp,Vector oids, Vector fieldoffset,Vector endoffset, int tuplecount) {
-           int i, j;
+           int i, j, k;
            short offsetcount = 0;
 
            Vector prefix = new Vector();
@@ -1646,7 +1641,7 @@ public class BuildCode {
                                    tstlbl += fd.getSafeSymbol() + ": NULL";
                                    oid += tstlbl+ " )";
                                    oids.add(oid);
-                                   for(j=i+1; j < pp.desc.size(); j++) {
+                                   for(j = i+1; j < pp.desc.size(); j++) {
                                            TypeDescriptor newtd;
                                            String newfieldoffset;
                                            Object desc = pp.getDescAt(j);
@@ -1663,8 +1658,8 @@ public class BuildCode {
                                                                    ((FieldDescriptor)desc).getSafeSymbol()+ "))");
                                            } else {
                                                    String indexlbl = new String();
-                                                   for(i=0; i<((IndexDescriptor)desc).tddesc.size(); i++) {
-                                                           indexlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(i), lb) + "+";
+                                                   for(k = 0; k < ((IndexDescriptor)desc).tddesc.size(); k++) {
+                                                           indexlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(k), lb) + "+";
                                                    }
                                                    indexlbl += ((IndexDescriptor)desc).offset.toString();
                                                    newfieldoffset = new String("(short)("+indexlbl+")");
@@ -1701,7 +1696,7 @@ public class BuildCode {
                                    tstlbl += prefix.get(j) + "[";
                            }
                            indexstring += "[";
-                           for(j=0; j<id.tddesc.size(); j++) {
+                           for(j = 0; j < id.tddesc.size(); j++) {
                                    tstlbl += generateTemp(fm, id.getTempDescAt(j), lb) + "+"; 
                                    indexstring += generateTemp(fm,id.getTempDescAt(j), lb) + "+";
                            }
index 67d09e44d46ad10fbb9d1a62de4de481d6cc1491..3ff1fd5de872d8e8c6efd0e0d75a593e953611c6 100755 (executable)
@@ -163,6 +163,7 @@ fi
 
 # Build bristlecone/java sources
 
+#if ! java -Xms5m -Xmx100m $JAVAFORWARDOPTS -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
 if ! java $JAVAFORWARDOPTS -cp $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
 $ROBUSTROOT/ClassLibrary/ -dir $BUILDDIR -precise \
 $JAVAOPTS $SRCFILES