You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by mf...@apache.org on 2007/07/20 11:40:10 UTC

svn commit: r557942 [2/2] - in /harmony/enhanced/drlvm/trunk/vm: jitrino/config/ia32/ jitrino/src/codegenerator/ jitrino/src/codegenerator/ia32/ jitrino/src/codegenerator/ipf/include/ jitrino/src/optimizer/ jitrino/src/shared/ vmcore/src/jit/

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp Fri Jul 20 02:40:02 2007
@@ -1931,70 +1931,6 @@
 }
 
 Opnd*
-Simplifier::simplifyPredCmp(Type* dstType,
-                            Type::Tag instType, // source type
-                            ComparisonModifier mod,
-                            Opnd* src1,
-                            Opnd* src2) {
-    assert(0);
-    ConstInst::ConstValue res;
-    if (ConstantFolder::isConstant(src1)) {
-        if (ConstantFolder::isConstant(src2)) {
-            return foldComparison(mod, 
-                                  instType, 
-                                  src1->getInst()->asConstInst(), 
-                                  src2->getInst()->asConstInst());
-        } else {
-            // can fold if (src1 == 0) and comparison is Cmp_Gt_Un
-            if (ConstantFolder::isConstantZero(src1) && 
-                ((mod & Cmp_Mask)==Cmp_GT_Un)) {
-                switch (dstType->tag) {
-                case Type::Int32: return genLdConstant((int32)0)->getDst();
-                default:
-                    break;
-                }
-            }
-        }
-    } else if (ConstantFolder::isConstantZero(src2) &&
-               ((mod & Cmp_Mask) == Cmp_GTE_Un)) {
-        switch (dstType->tag) {
-        case Type::Int32: return genLdConstant((int32)1)->getDst();
-        default:
-            break;
-        }
-    }
-    // if operands are identical and not FP, then we can simplify it now
-    if ((src1 == src2) && !Type::isFloatingPoint(instType)) {
-        switch (mod & Cmp_Mask) {
-        case Cmp_EQ: case Cmp_GTE: case Cmp_GTE_Un:
-            return genLdConstant((int32)1)->getDst();
-        case Cmp_NE_Un: case Cmp_GT: case Cmp_GT_Un:
-            return genLdConstant((int32)0)->getDst();
-        default:
-            assert(0);
-        }
-    }
-    
-    // try to simplify to a new comparison
-    { 
-        ComparisonModifier newMod;
-        Type::Tag newInstType;
-        Opnd *newSrc1;
-        Opnd *newSrc2;
-        if (simplifyCmpToCmp(instType, mod, src1, src2,
-                             newInstType, newMod, newSrc1, newSrc2)) {
-            // can simplify it.
-            Inst *res = genCmp(dstType, newInstType, newMod, 
-                               newSrc1, (newSrc2 
-                                         ? newSrc2
-                                         : OpndManager::getNullOpnd()));
-            return res->getDst();
-        }
-    }
-    return NULL;
-}
-
-Opnd*
 Simplifier::simplifyCmp3(Type* dstType,
                          Type::Tag instType,
                          ComparisonModifier mod,
@@ -3198,14 +3134,6 @@
     return NULL;
 }
 
-Opnd*
-Simplifier::simplifyScaledDiffRef(Opnd* src1, Opnd* src2) {
-    if (src1 == src2) {
-    } else {
-    }
-    return NULL;
-}
-
 //
 // Compressed reference operations
 //
@@ -4530,97 +4458,6 @@
     return NULL;
 }
 
-bool
-Simplifier::simplifyPredBranch(LabelInst *label, Opnd *src)
-{
-    Inst *inst = src->getInst();
-    if (inst->getOpcode() != Op_PredCmp) {
-        return false;
-    }
-    bool isTaken;
-    Type::Tag type = inst->getType();
-    ComparisonModifier mod = inst->getComparisonModifier();
-    switch (inst->getNumSrcOperands()) {
-    case 1:
-        if(canFoldBranch(type,
-            mod,
-            inst->getSrc(0),
-            isTaken)) { 
-            if (isTaken) {
-                genJump(label);
-            } else {
-                // just fall through
-            }
-            return true;
-        }
-        else {
-            if(simplifyBranch(type, mod, label, inst->getSrc(0)))
-                return true;
-        }
-        break;
-    case 2:
-        if(canFoldBranch(type,
-            mod,
-            inst->getSrc(0),
-            inst->getSrc(1),
-            isTaken)) {
-            if (isTaken) {
-                genJump(label);
-            } else {
-                // just fall through
-            }
-            return true;
-        }
-        else {
-            if(simplifyBranch(type, mod, label, inst->getSrc(0), inst->getSrc(1)))
-                return true;
-        }
-        break;
-    }
-    return false;
-}
-
-Inst*
-Simplifier::casePredBranch(BranchInst* pbInst) {
-    assert(pbInst->getNumSrcOperands() == 1);
-    Opnd *srcOpnd = pbInst->getSrc(0);
-    Inst *inst = srcOpnd->getInst();
-    if (inst->getOpcode() != Op_PredCmp) return 0;
-    bool isTaken;
-    Type::Tag type = inst->getType();
-    ComparisonModifier mod = inst->getComparisonModifier();
-    switch (inst->getNumSrcOperands()) {
-    case 1:
-        if(canFoldBranch(type,
-                         mod,
-                         inst->getSrc(0),
-                         isTaken)) { 
-            foldBranch(pbInst, isTaken);
-            return NULL;
-        }
-        else {
-            if(simplifyBranch(type, mod, pbInst->getTargetLabel(), inst->getSrc(0)))
-                return NULL;
-        }
-        break;
-    case 2:
-        if(canFoldBranch(type,
-            mod,
-            inst->getSrc(0),
-            inst->getSrc(1),
-            isTaken)) {
-            foldBranch(pbInst, isTaken);
-            return NULL;
-        }
-        else {
-            if(simplifyBranch(type, mod, pbInst->getTargetLabel(), inst->getSrc(0), inst->getSrc(1)))
-                return NULL;
-        }
-        break;
-    }
-
-    return inst;
-}
 
 void
 SimplifierWithInstFactory::genThrowSystemException(CompilationInterface::SystemExceptionId exceptionId)

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h Fri Jul 20 02:40:02 2007
@@ -127,7 +127,6 @@
         return NULL;
     }
     Opnd* simplifyAddScaledIndex(Opnd* base, Opnd* index);
-    Opnd* simplifyScaledDiffRef(Opnd* src1, Opnd* src2);
     // stores
     void simplifyTauStInd(Inst *inst); // modifies instr in place if possible
     void simplifyTauStField(Inst *inst); // modifies instr in place if possible
@@ -169,11 +168,6 @@
     // tau operations
     Opnd* simplifyTauAnd(MultiSrcInst *tauAndInst);
 
-    // predicate operations
-    Opnd* simplifyPredCmp(Type* dstType, Type::Tag srcType, ComparisonModifier, Opnd* src1, Opnd* src2);
-    // if branch can be simplified, generates alternate instructions and returns true;
-    bool simplifyPredBranch(LabelInst* label, Opnd *src);
-
     Opnd* propagateCopy(Opnd*);
 
     static bool isNonNullObject(Opnd*);
@@ -635,14 +629,7 @@
             return opnd->getInst();
         return inst;
     }
-    Inst* caseScaledDiffRef(Inst* inst) {
-        Opnd* opnd = simplifyScaledDiffRef(inst->getSrc(0),
-                                           inst->getSrc(1));
-        if (opnd != NULL)
-            return opnd->getInst();
-        return inst;
-    }
-
+    
     // stores
     Inst* caseStVar(Inst* inst) {return caseDefault(inst);}
 
@@ -980,19 +967,6 @@
             return opnd->getInst();
         return inst;
     }
-
-    Inst* casePredCmp(Inst* inst) {
-        Opnd* opnd = simplifyPredCmp(inst->getDst()->getType(),
-                                     inst->getType(),
-                                     inst->getComparisonModifier(),
-                                     inst->getSrc(0),
-                                     inst->getSrc(1));
-        if (opnd != NULL)
-            return opnd->getInst();
-        return inst;
-    }
-
-    Inst* casePredBranch(BranchInst* inst);
 
     // default
     Inst* caseDefault(Inst* inst)  {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp Fri Jul 20 02:40:02 2007
@@ -552,7 +552,6 @@
     case Op_TauArrayLen:
     case Op_LdArrayBaseAddr:
     case Op_AddScaledIndex:
-    case Op_ScaledDiffRef:
         assert(0);        // not an object type
         
     case Op_StVar:
@@ -713,8 +712,6 @@
     case Op_TauHasType:
     case Op_TauHasExactType:
     case Op_TauIsNonNull:
-    case Op_PredCmp:
-    case Op_PredBranch:
         assert(0); // none of the above yield objects
         
     default:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.cpp Fri Jul 20 02:40:02 2007
@@ -423,7 +423,7 @@
 Node* ControlFlowGraph::splitNodeAtInstruction(CFGInst *inst, bool splitAfter, bool keepDispatch, CFGInst* labelInst) {
     Node *node = inst->getNode();
     Node* dispatchNode = keepDispatch ? node->getExceptionEdgeTarget() : NULL;
-    Node* nextNode =  splitNode(node, splitAfter, labelInst);
+    Node* newNode =  splitNode(node, splitAfter, labelInst);
     if (inst == node->getLastInst()) {
         assert(!splitAfter || (node->getOutDegree() == 1 && node->getUnconditionalEdge()!=NULL)
             || (node->getOutDegree()==2 && node->getExceptionEdgeTarget()!=NULL));
@@ -439,12 +439,12 @@
     for (CFGInst *ins = splitAfter ? inst->next() : inst; ins != NULL; ) {
         CFGInst *nextins = ins->next();
         ins->unlink();
-        nextNode->appendInst(ins);
+        newNode->appendInst(ins);
         ins = nextins;
     } 
-    nextNode->setExecCount(node->getExecCount());
-    node->findTargetEdge(nextNode)->setEdgeProb(1.0);
-    return nextNode;
+    newNode->setExecCount(node->getExecCount());
+    node->findTargetEdge(newNode)->setEdgeProb(1.0);
+    return newNode;
 }
 
 // Splice a new empty block on the CFG edge.

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=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/ControlFlowGraph.h Fri Jul 20 02:40:02 2007
@@ -1300,7 +1300,7 @@
    *
    * @param[in] edge        - the edge to change the target
    * @param[in] newTarget   - a new <code>Target</code> node
-   * @param[in] keepOldBody - modify old or create a new edge
+   * @param[in] keepOldEdge - modify old or create a new edge
    * 
    * @return The edge connecting the <code>Source</code> node of the  
    *         edge and the </code>newTarget</code> node.
@@ -1308,7 +1308,7 @@
    * @note The removal of the old edge is needed
    *       while inlining CFG: edge IDs must be renewed.
    */
-    Edge* replaceEdgeTarget(Edge* edge, Node *newTarget, bool keepOldBody = false);
+    Edge* replaceEdgeTarget(Edge* edge, Node *newTarget, bool keepOldEdge = false);
 
   /** 
    * Checks if CFG is annotated with the edge profile information.

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/LoopTree.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/LoopTree.cpp?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/LoopTree.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/LoopTree.cpp Fri Jul 20 02:40:02 2007
@@ -216,13 +216,12 @@
         Edge* e = *ite;
         assert(e->getTargetNode() == header);  // must share the same header
 
-        fg->replaceEdgeTarget(e, block);
+        fg->replaceEdgeTarget(e, block, true);
         block->setExecCount(block->getExecCount()+e->getSourceNode()->getExecCount()*e->getEdgeProb());
     }
 
     // create factored edge <block,header>
-    Edge* edge = fg->addEdge(block,header);
-    edge->setEdgeProb(1.0);
+    Edge* edge = fg->addEdge(block,header, 1.0);
     return edge;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?view=diff&rev=557942&r1=557941&r2=557942
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Fri Jul 20 02:40:02 2007
@@ -349,6 +349,7 @@
 // General stats update
 static void rth_type_test_update_stats(VTable* sub, Class* super)
 {
+    UNSAFE_REGION_START
     VM_Statistics::get_vm_stats().num_type_checks ++;
     if (sub->clss == super)
         VM_Statistics::get_vm_stats().num_type_checks_equal_type ++;
@@ -360,6 +361,7 @@
         VM_Statistics::get_vm_stats().num_type_checks_super_is_interface ++;
     else if (super->get_depth() >= vm_max_fast_instanceof_depth())
         VM_Statistics::get_vm_stats().num_type_checks_super_is_too_deep ++;
+    UNSAFE_REGION_END
 }
 
 // Checkcast stats update
@@ -382,6 +384,7 @@
 // Instanceof stats update
 static void rth_update_instanceof_stats(ManagedObject* o, Class* super)
 {
+    UNSAFE_REGION_START
     VM_Statistics::get_vm_stats().num_instanceof++;
     super->instanceof_slow_path_taken();
     if (o == (ManagedObject*)VM_Global_State::loader_env->managed_null) {
@@ -393,6 +396,7 @@
             VM_Statistics::get_vm_stats().num_instanceof_fast_decision ++;
         rth_type_test_update_stats(o->vt(), super);
     }
+    UNSAFE_REGION_END
 }
 #endif // VM_STATS
 
@@ -2777,6 +2781,7 @@
 static void update_general_type_checking_stats(VTable *sub, Class *super)
 {
 #ifdef VM_STATS
+    UNSAFE_REGION_START
     VM_Statistics::get_vm_stats().num_type_checks++;
     if (sub->clss == super)
         VM_Statistics::get_vm_stats().num_type_checks_equal_type++;
@@ -2788,6 +2793,7 @@
         VM_Statistics::get_vm_stats().num_type_checks_super_is_interface++;
     else if (super->get_depth() >= vm_max_fast_instanceof_depth())
         VM_Statistics::get_vm_stats().num_type_checks_super_is_too_deep++;
+    UNSAFE_REGION_END
 #endif // VM_STATS
 }