harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r490935 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src: dynopt/StaticProfiler.cpp shared/ControlFlowGraph.h
Date Fri, 29 Dec 2006 07:29:47 GMT
Author: varlax
Date: Thu Dec 28 23:29:46 2006
New Revision: 490935

URL: http://svn.apache.org/viewvc?view=rev&rev=490935
Log:
Applied HARMONY-2832 [drlvm][jitrino] Static profiler related fixes
Tested on SLES9

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/dynopt/StaticProfiler.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/dynopt/StaticProfiler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/dynopt/StaticProfiler.cpp?view=diff&rev=490935&r1=490934&r2=490935
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/dynopt/StaticProfiler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/dynopt/StaticProfiler.cpp Thu Dec 28 23:29:46
2006
@@ -53,6 +53,7 @@
 #define PROB_DEVIRT_GUARD_HEURISTIC 0.62
 #define PROB_REFERENCE              0.60
 #define PROB_STORE_HEURISTIC        0.55
+#define PROB_FALLTHRU_HEURISTIC     0.45
 
 #define ACCEPTABLE_DOUBLE_PRECISION_LOSS  0.000000001 
 
@@ -70,6 +71,7 @@
 static double storeHeuristic(const StaticProfilerContext*);
 static double referenceHeuristic(const StaticProfilerContext*);
 static double devirtGuardHeuristic(const StaticProfilerContext*);
+static double fallThruHeuristic(const StaticProfilerContext*);
 static void setHeatThreshold(IRManager& irm);
 typedef std::vector<std::string> StringList;
 static void splitString(const char* string, StringList& result, char separator, bool
notEmptyTokensOnly);
@@ -90,6 +92,7 @@
     Heuristics("store", storeHeuristic),
     Heuristics("ref", referenceHeuristic),
     Heuristics("guard", devirtGuardHeuristic),
+    Heuristics("ft", fallThruHeuristic),
     Heuristics("", NULL)
 };
 
@@ -154,14 +157,15 @@
         if (!defaultHeuristicsInited) {
             initMutex.lock();
             if (!defaultHeuristicsInited) {
-                getHeuristicsByNamesList("loop,ret,guard", defaultHeuristics);
+                getHeuristicsByNamesList("loop,ret,ft,guard", defaultHeuristics);
+                defaultHeuristicsInited = true;
             }
             initMutex.unlock();
         }
     }
     
     template <class Container> 
-    static void getHeuristicsByNamesList(const char* list, Container result) {
+    static void getHeuristicsByNamesList(const char* list, Container& result) {
         StringList nameList;
         splitString(list, nameList, ',', true);
         for (StringList::const_iterator it = nameList.begin(), end = nameList.end(); it!=end;
++it) {
@@ -332,21 +336,26 @@
         c->edge2 = falseEdge;
         if (c->doLoopHeuristicsOverride && isLoopHeuristicAcceptable(c)) {
             prob = c->loopTree->isLoopExit(trueEdge) ? PROB_LOOP_EXIT : 1 - PROB_LOOP_EXIT;
-        } else {
+        } else if (c->node->getTraversalNum() == c->fg->getTraversalNum()) {//node
is reachable
             // from this point we can apply general heuristics
             for (StlVector<Heuristics*>::const_iterator it = c->heuristics.begin(),
end = c->heuristics.end(); it!=end; ++it) {
                 Heuristics* h = *it;
                 HeuristicsFn fn = h->fn;
                 double dprob = (*fn)(c);
+                assert(dprob>0 && dprob<1);
                 if (dprob!=PROB_HEURISTIC_FAIL) {
-                    prob = prob * dprob / (prob*dprob + (1-prob)*(1-dprob));
+                    double newprob = prob * dprob / (prob*dprob + (1-prob)*(1-dprob));
+                    assert(newprob>0 && newprob<1);
+                    prob = newprob;
                 }
             }
         }
         // all other edges (exception, catch..) have lower probability
         double othersProb = edges.size() == 2 ? 0.0 : PROB_ALL_EXCEPTIONS;
-        trueEdge->setEdgeProb(MAX(PROB_ALL_EXCEPTIONS, prob - othersProb/2));
-        falseEdge->setEdgeProb(MAX(PROB_ALL_EXCEPTIONS, 1 - prob - othersProb/2));
+        trueEdge->setEdgeProb(prob - othersProb/2);
+        falseEdge->setEdgeProb(1 - prob - othersProb/2);
+        assert(trueEdge->getEdgeProb()!=0);
+        assert(falseEdge->getEdgeProb()!=0);
         probLeft = othersProb;
         edgesLeft-=2;
     }
@@ -567,6 +576,16 @@
         return PROB_HEURISTIC_FAIL;
     }
     return node1Accepted ? 1 - PROB_STORE_HEURISTIC: PROB_STORE_HEURISTIC;
+}
+/**
+ * Give more prob to fallthru branch
+ */
+static double fallThruHeuristic(const StaticProfilerContext * c) {
+    Inst* inst = (Inst*)c->node->getLastInst();
+    if (inst->getOpcode() != Op_Branch) {
+        return PROB_HEURISTIC_FAIL;
+    }
+    return PROB_FALLTHRU_HEURISTIC;
 }
 
 /** Reference heuristic (RH)

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h?view=diff&rev=490935&r1=490934&r2=490935
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h Thu Dec 28 23:29:46
2006
@@ -1664,8 +1664,9 @@
     template <class Container>
     void runDFS(Container* preOrderContainer, Container* postOrderContainer, bool isForward)
{
         Node* startNode;
+        traversalNumber++;
         if (isForward) {
-            lastOrderingTraversalNumber = ++traversalNumber;
+            lastOrderingTraversalNumber = traversalNumber;
             postOrderCache.clear();
             if (entryNode==NULL) {
                 return;
@@ -1685,7 +1686,7 @@
         }
     }
     
-  /// Helper for public <code>getNodesPre/PostOrder</code> methods above.
+  /// Helper for public <code>getNodesPre/PostOrder</code> methods above. Warn:
increment cfg traversal num before use.
    
     template <class Container>
     void getNodesDFS(Container* preOrderContainer, Container* postOrderContainer, Node* node,
bool isForward=true) {



Mime
View raw message