harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r526726 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32: Ia32IRManager.cpp Ia32IRManager.h Ia32Inst.cpp Ia32Inst.h
Date Mon, 09 Apr 2007 12:22:17 GMT
Author: varlax
Date: Mon Apr  9 05:22:16 2007
New Revision: 526726

URL: http://svn.apache.org/viewvc?view=rev&rev=526726
Log:
HARMONY-3175 [drlvm][jit] Jitrino.OPT fails to compile some switch insts combinations when
is built in debug mode.
Redone the patch + cleaned up a mess in IRManager::newSwitchInst(). 

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp?view=diff&rev=526726&r1=526725&r2=526726
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Mon Apr
 9 05:22:16 2007
@@ -189,18 +189,6 @@
 }
 
 //_____________________________________________________________________________________________
-Opnd * IRManager::newSwitchTableConstantMemOpnd(uint32 numTargets, Opnd * index)
-{
-    ConstantAreaItem * item=newSwitchTableConstantAreaItem(numTargets);
-#ifdef _EM64T_
-    Opnd * switchTable=newImmOpnd(typeManager.getInt32Type(), Opnd::RuntimeInfo::Kind_ConstantAreaItem,
item);
-#else
-    Opnd * switchTable=newImmOpnd(typeManager.getIntPtrType(), Opnd::RuntimeInfo::Kind_ConstantAreaItem,
item);
-#endif
-    return newMemOpnd(typeManager.getIntPtrType(), MemOpndKind_ConstantArea, 0, index, newImmOpnd(typeManager.getInt32Type(),
sizeof(POINTER_SIZE_INT)), switchTable);
-}
-
-//_____________________________________________________________________________________________
 Opnd * IRManager::newInternalStringConstantImmOpnd(const char * str)
 {
     ConstantAreaItem * item=newInternalStringConstantAreaItem(str);
@@ -217,30 +205,25 @@
 //_____________________________________________________________________________________________
 SwitchInst * IRManager::newSwitchInst(uint32 numTargets, Opnd * index)
 {
-    Inst * instList = NULL;
-#ifndef _EM64T_
     assert(numTargets>0);
     assert(index!=NULL);
-    Opnd* targetOpnd=newSwitchTableConstantMemOpnd(numTargets, index);
-    // Extract the switch table constant address that is stored as 
-    // displacement on IA32. 
+    Inst * instList = NULL;
+    ConstantAreaItem * item=newSwitchTableConstantAreaItem(numTargets);
     // This tableAddress in SwitchInst is kept separately [from getOpnd(0)]
     // so it allows to replace an Opnd (used in SpillGen) and keep the table 
     // itself intact.
-    Opnd* tableAddr = targetOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Displacement);
-    SwitchInst * inst=new(memoryManager, 1) SwitchInst(Mnemonic_JMP, instId++, tableAddr);
+    Opnd * tableAddr=newImmOpnd(typeManager.getIntPtrType(), Opnd::RuntimeInfo::Kind_ConstantAreaItem,
item);
+#ifndef _EM64T_
+    Opnd * targetOpnd = newMemOpnd(typeManager.getIntPtrType(), 
+        MemOpndKind_ConstantArea, 0, index, newImmOpnd(typeManager.getInt32Type(), sizeof(POINTER_SIZE_INT)),
tableAddr);
 #else
-    
-    ConstantAreaItem * item=newSwitchTableConstantAreaItem(numTargets);
-    Opnd * tableAddr = newImmOpnd(typeManager.getInt64Type(), Opnd::RuntimeInfo::Kind_ConstantAreaItem,
item);
-
-    SwitchInst * inst=new(memoryManager, 1) SwitchInst(Mnemonic_JMP, instId++, tableAddr);
-    assert(numTargets>0);
-    assert(index!=NULL);
+    // on EM64T immediate displacement cannot be of 64 bit size, so move it to a register
first
     Opnd * baseOpnd = newOpnd(typeManager.getInt64Type());
     appendToInstList(instList, newCopyPseudoInst(Mnemonic_MOV, baseOpnd, tableAddr));
-    Opnd * targetOpnd =  newMemOpnd(typeManager.getUnmanagedPtrType(typeManager.getIntPtrType()),
MemOpndKind_ConstantArea, baseOpnd, index, newImmOpnd(typeManager.getInt32Type(), sizeof(POINTER_SIZE_INT)),
0);
+    Opnd * targetOpnd = newMemOpnd(typeManager.getUnmanagedPtrType(typeManager.getIntPtrType()),

+        MemOpndKind_ConstantArea, baseOpnd, index, newImmOpnd(typeManager.getInt32Type(),
sizeof(POINTER_SIZE_INT)), 0);
 #endif
+    SwitchInst * inst=new(memoryManager, 1) SwitchInst(Mnemonic_JMP, instId++, tableAddr);
     inst->insertOpnd(0, targetOpnd, Inst::OpndRole_Explicit);
     inst->assignOpcodeGroup(this);
     appendToInstList(instList, inst);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h?view=diff&rev=526726&r1=526725&r2=526726
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h Mon Apr
 9 05:22:16 2007
@@ -150,7 +150,6 @@
 
     Opnd * newFPConstantMemOpnd(float f, Opnd * baseOpnd=0, BasicBlock * bb=0);
     Opnd * newFPConstantMemOpnd(double f, Opnd * baseOpnd=0, BasicBlock * bb=0);
-    Opnd * newSwitchTableConstantMemOpnd(uint32 numTargets, Opnd * index);
 
     Opnd * newInternalStringConstantImmOpnd(const char * str);
     Opnd * newBinaryConstantImmOpnd(uint32 size, const void * pv);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp?view=diff&rev=526726&r1=526725&r2=526726
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp Mon Apr  9
05:22:16 2007
@@ -682,12 +682,14 @@
 //   class SwitchInst
 //=========================================================================================================
 
+ConstantAreaItem * SwitchInst::getConstantAreaItem() const 
+{
+    return (ConstantAreaItem *)tableAddrRI->getValue(0);
+}
+
 Node* SwitchInst::getTarget(uint32 i)const
 {
-    Opnd * tableAddr=getTableAddress();
-    Opnd::RuntimeInfo * ri=tableAddr->getRuntimeInfo();
-    assert(ri->getKind()==Opnd::RuntimeInfo::Kind_ConstantAreaItem);
-    ConstantAreaItem * cai = (ConstantAreaItem *)ri->getValue(0);
+    ConstantAreaItem * cai = getConstantAreaItem();
     assert(i<cai->getSize()/sizeof(Node*));
     return ((Node**)cai->getValue())[i];
 }
@@ -714,21 +716,15 @@
 //_________________________________________________________________________________________________
 uint32 SwitchInst::getNumTargets() const 
 {
-    Opnd * tableAddr=getTableAddress();
-    Opnd::RuntimeInfo * ri= tableAddr->getRuntimeInfo();
-    assert(ri->getKind()==Opnd::RuntimeInfo::Kind_ConstantAreaItem);
-    ConstantAreaItem * cai = (ConstantAreaItem *)ri->getValue(0);
-    return cai->getSize() / sizeof(Node*);
+    return getConstantAreaItem()->getSize() / sizeof(Node*);
 }
 
 //_________________________________________________________________________________________________
 void SwitchInst::setTarget(uint32 i, Node* bb)
 {
     assert(bb->isBlockNode());
-    Opnd * tableAddr=getTableAddress();
-    Opnd::RuntimeInfo * ri=tableAddr->getRuntimeInfo();
-    assert(ri->getKind()==Opnd::RuntimeInfo::Kind_ConstantAreaItem);
-    ConstantAreaItem * cai = (ConstantAreaItem *)ri->getValue(0);
+    
+    ConstantAreaItem * cai = getConstantAreaItem();
     assert(i<cai->getSize()/sizeof(Node*));
     ((Node**)cai->getValue())[i]=bb;
 }
@@ -737,10 +733,7 @@
 void SwitchInst::replaceTarget(Node * bbFrom, Node * bbTo)
 {
     assert(bbTo->isBlockNode());
-    Opnd * tableAddr=getTableAddress();
-    Opnd::RuntimeInfo * ri=tableAddr->getRuntimeInfo();
-    assert(ri->getKind()==Opnd::RuntimeInfo::Kind_ConstantAreaItem);
-    ConstantAreaItem * cai = (ConstantAreaItem *)ri->getValue(0);
+    ConstantAreaItem * cai = getConstantAreaItem();
     Node** bbs=(Node**)cai->getValue();
 #ifdef _DEBUG
     bool found = false;
@@ -771,7 +764,7 @@
 // called from CFG when 2 blocks are merging and one of  the branches is redundant.
 void SwitchInst::removeRedundantBranch()
 {
-    assert(0);
+   unlink();
 }
 
 //_________________________________________________________________________________________________
@@ -942,4 +935,5 @@
 
 
 }};  // namespace Ia32
+
 

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?view=diff&rev=526726&r1=526725&r2=526726
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h Mon Apr  9 05:22:16
2007
@@ -42,6 +42,7 @@
 class Inst;
 class BasicBlock;
 class I8Lowerer;
+class ConstantAreaItem;
 
 //=========================================================================================================
 //      class Opnd
@@ -1124,12 +1125,17 @@
     void setTarget(uint32 i, Node* bb);
 
     Opnd * getTableAddress() const;
+    ConstantAreaItem * getConstantAreaItem() const;
     
     virtual void verify() const;
 protected:
     SwitchInst(Mnemonic mnemonic,  int id, Opnd * addr = 0) : 
             ControlTransferInst(mnemonic, id), tableAddr(addr)
-        {kind=Kind_SwitchInst; }
+        {
+            kind=Kind_SwitchInst; 
+            tableAddrRI = addr->getRuntimeInfo();
+            assert(tableAddrRI->getKind()==Opnd::RuntimeInfo::Kind_ConstantAreaItem);
+        }
 
 
     // called by CFG to detect BB->BB block edges
@@ -1140,7 +1146,13 @@
     virtual void removeRedundantBranch();
 
     void replaceTarget(Node* bbFrom, Node* bbTo);
+
+private:
     Opnd * tableAddr;
+    //keep original opnd runtime info.
+    //if orig opnd is spilled by spillgen and it's replacement has no runtime info
+    Opnd::RuntimeInfo* tableAddrRI;
+    
 };
 
 //=========================================================================================================
@@ -1328,9 +1340,6 @@
 
 };
 
-}}; // namespace Ia32
-
-
 //=========================================================================================================
 //      class ConstantAreaItem
 //=========================================================================================================
@@ -1368,5 +1377,6 @@
     void *              address;
 };
 
+}}; // namespace Ia32
 
 #endif



Mime
View raw message