harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r590063 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32: Ia32CgUtils.cpp Ia32CgUtils.h Ia32CodeEmitter.cpp Ia32GCSafePoints.cpp Ia32Inst.h Ia32InstCodeSelector.cpp
Date Tue, 30 Oct 2007 13:15:55 GMT
Author: varlax
Date: Tue Oct 30 06:15:53 2007
New Revision: 590063

URL: http://svn.apache.org/viewvc?rev=590063&view=rev
Log:
Final fix for HARMONY-5016 [drlvm][jit][opt] code patching may corrupt calls to helpers on
x86-64 in OPT mode

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.cpp?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.cpp Tue Oct
30 06:15:53 2007
@@ -229,6 +229,19 @@
     return m_opndFloatZero;
 }
 
+Opnd* OpndUtils::findImmediateSource(Opnd* opnd) 
+{
+    Opnd* res = opnd;
+    while (!res->isPlacedIn(OpndKind_Imm)) {
+        Inst* defInst = res->getDefiningInst();
+        if (!defInst || defInst->getMnemonic()!=Mnemonic_MOV) {
+            return NULL;
+        }
+        res = defInst->getOpnd(1);
+    }
+    return res;
+}
+
 //All CALL insts except some special helpers that never cause stacktrace printing
 bool InstUtils::instMustHaveBCMapping(Inst* inst) {
     if (!inst->hasKind(Inst::Kind_CallInst)) {
@@ -236,7 +249,8 @@
     }
     CallInst* callInst = (CallInst*)inst;
     Opnd * targetOpnd=callInst->getOpnd(callInst->getTargetOpndIndex());
-    Opnd::RuntimeInfo * ri=targetOpnd->getRuntimeInfo();
+    Opnd* immOpnd = OpndUtils::findImmediateSource(targetOpnd);
+    Opnd::RuntimeInfo * ri = immOpnd ? immOpnd->getRuntimeInfo() : NULL;
     if(!ri) {
         return true;
     } else if (ri->getKind() == Opnd::RuntimeInfo::Kind_InternalHelperAddress) { 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.h?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CgUtils.h Tue Oct 30
06:15:53 2007
@@ -177,6 +177,13 @@
      * Tests 2 operands for equality.
      */
     static bool equals(const Opnd* a, const Opnd* b);
+
+    /**
+     * Searches for a source of an immediate value (if any) of the specified operand.
+     * Returns the "defining" operand or \c NULL.
+     */
+    static Opnd* findImmediateSource(Opnd* opnd);
+
     //
     // The following are not static and require IRManager
     //

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeEmitter.cpp Tue
Oct 30 06:15:53 2007
@@ -641,9 +641,11 @@
                     Type* targetType = irManager->getTypeManager().getInt64Type();
 
                     Opnd* targetVal = irManager->newImmOpnd(targetType,(int64)targetCodeStartAddr);
+                    targetVal->setRuntimeInfo(inst->getOpnd(targetOpndIndex)->getRuntimeInfo());
                     Opnd* targetReg = irManager->newRegOpnd(targetType, RegName_R11);
                     
                     Inst* movInst = irManager->newInst(Mnemonic_MOV, targetReg, targetVal);
+                    targetReg->setDefiningInst(movInst);
 
                     inst->setOpnd(targetOpndIndex,targetReg);
 
@@ -684,8 +686,9 @@
             }   
         }
     }  
-    if (newOpndsCreated)
+    if (newOpndsCreated) {
         irManager->fixLivenessInfo();
+    }
 }
 
 //________________________________________________________________________________________

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp Tue
Oct 30 06:15:53 2007
@@ -23,6 +23,7 @@
 #include "Ia32GCSafePoints.h"
 #include "XTimer.h"
 #include "BitSet.h"
+#include "Ia32CgUtils.h"
 
 
 namespace Jitrino
@@ -334,18 +335,6 @@
 #endif
 }
 
-static Opnd* findImmediateSource(Opnd* opnd) {
-    Opnd* res = opnd;
-    while (!res->isPlacedIn(OpndKind_Imm)) {
-        Inst* defInst = res->getDefiningInst();
-        if (!defInst || defInst->getMnemonic()!=Mnemonic_MOV) {
-            return NULL;
-        }
-        res = defInst->getOpnd(1);
-    }
-    return res;
-}
-
 int32 GCSafePointsInfo::getOffsetFromImmediate(Opnd* offsetOpnd) const {
     if (offsetOpnd->isPlacedIn(OpndKind_Immediate)) {
         if (offsetOpnd->getImmValue() == 0 && offsetOpnd->getRuntimeInfo()!=NULL)
{
@@ -538,7 +527,7 @@
                 case Mnemonic_SUB:
                         fromOpnd = opnd;
                         Opnd* offsetOpnd = inst->getOpnd(useIndex1);
-                        Opnd* immOffset = findImmediateSource(offsetOpnd);
+                        Opnd* immOffset = OpndUtils::findImmediateSource(offsetOpnd);
                         if (immOffset) {
                            if (isHeapBase(immOffset)) {
                                offset = 0;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h Tue Oct 30 06:15:53
2007
@@ -289,7 +289,7 @@
     /** 
      * Returns the number of occurrences of the operand in LIR.
      * The value may take into account basic block execution count (profile information).
-     * Non-zero result means the operand is used in LIR and non-zero means it is not.
+     * Non-zero result means the operand is used in LIR and zero means it is not.
      * 
      * The refCount value is calculated during IRManager::calculateOpndStatistics.
      */
@@ -300,13 +300,18 @@
 
     /** 
      * Return the defining inst for operands with a single definition. 
-     * If the operand has multiple deinitions the method returns 0.
+     * If the operand has multiple definitions the method returns 0.
      *
-     * The definingInst value is calculated during IRManager::calculateOpndStatistics.
+     * The definingInst value is normally calculated during IRManager::calculateOpndStatistics.
      */
     Inst * getDefiningInst()const{ return definingInst; }
 
     /** 
+     * Assigns the defining inst for operands with a single definition. 
+     */
+    void setDefiningInst(Inst * inst);
+
+    /** 
      * Returns true if the operand is used in liveness analysis.
      * For example, immediate values and heap operands do not participate
      * in liveness analysis.
@@ -333,8 +338,6 @@
 
     void addRefCount(uint32& index, uint32 blockExecCount);
 
-    void setDefiningInst(Inst * inst);
-
 #ifdef _DEBUG
     void checkConstraints();
 #else
@@ -344,7 +347,9 @@
 
     //-------------------------------------------------------------------------
     Opnd(uint32 _id, Type * t, Constraint c)
-        :id(_id), firstId(_id), type(t), memOpndKind(MemOpndKind_Null), segReg(RegName_Null),
immValue(0), runtimeInfo(NULL)
+        :id(_id), firstId(_id), type(t), memOpndKind(MemOpndKind_Null), 
+        defScope(DefScope_Null), definingInst(NULL), refCount(0),
+        segReg(RegName_Null), immValue(0), runtimeInfo(NULL)
         { constraints[ConstraintKind_Initial]=constraints[ConstraintKind_Calculated]=c; }
 
     //-------------------------------------------------------------------------

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?rev=590063&r1=590062&r2=590063&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
Tue Oct 30 06:15:53 2007
@@ -207,7 +207,7 @@
 {
     assert(currentBasicBlock);
     inst->setBCOffset(currentHIRInstBCOffset);
-    assert(!InstUtils::instMustHaveBCMapping(inst) || currentHIRInstBCOffset!=ILLEGAL_BC_MAPPING_VALUE);
+    assert(currentHIRInstBCOffset!=ILLEGAL_BC_MAPPING_VALUE || !InstUtils::instMustHaveBCMapping(inst));
     if (Log::isEnabled()){
         Inst * i=inst; 
         do {



Mime
View raw message