You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2007/10/29 13:17:17 UTC

svn commit: r589594 - /harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp

Author: varlax
Date: Mon Oct 29 05:17:16 2007
New Revision: 589594

URL: http://svn.apache.org/viewvc?rev=589594&view=rev
Log:
Applied HARMONY-4995 [drlvm][jit] VM crash in struts tests

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp?rev=589594&r1=589593&r2=589594&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32DCE.cpp Mon Oct 29 05:17:16 2007
@@ -59,6 +59,37 @@
     for (Nodes::const_iterator it = nodes.begin(),end = nodes.end();it!=end; ++it) {
         Node* node = *it;
         if (node->isBlockNode()){
+            //Here we'll try to remove redundant branches that could appear after 
+            //branch translations. All such branches are supposed to be conditional.
+            Inst * inst = (Inst *)node->getLastInst();
+            if(inst && node->getOutEdges().size() > 1) {
+                Edges edges = node->getOutEdges();
+                for (Edges::const_iterator ite1 = ++edges.begin(), end = edges.end(); ite1 != end; ++ite1) {
+                    for (Edges::const_iterator ite2 = edges.begin(); ite1 != ite2; ++ite2) {
+                        Edge *edge1 = *ite1;
+                        Edge *edge2 = *ite2;
+                        assert(edge1 != edge2);
+
+                        //If this condition is satisfied then there are at least two branches with 
+                        //the same destination
+                        if (edge1->getTargetNode() == edge2->getTargetNode()) {
+                            //Check that edges are conditional and the last instruction is branch, 
+                            //the other situations are not permitted at the moment
+                            assert(inst->hasKind(Inst::Kind_BranchInst));
+                            assert(edge1->getKind() == Edge::Kind_True || 
+                                        edge1->getKind() == Edge::Kind_False);
+                            assert(edge2->getKind() == Edge::Kind_True || 
+                                        edge2->getKind() == Edge::Kind_False);
+                            
+                            //Remove last instruction if it is a branch
+                            inst->unlink();
+                            irManager->getFlowGraph()->removeEdge(edge2);
+                        }
+                    
+                    }
+                }
+           }
+
             irManager->getLiveAtExit(node, ls);
             for (Inst * inst=(Inst*)node->getLastInst(), * prevInst=NULL; inst!=NULL; inst=prevInst){
                 prevInst=inst->getPrevInst();
@@ -105,4 +136,5 @@
 }
 
 }}; //namespace Ia32
+