harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r518533 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src: codegenerator/ codegenerator/ia32/ codegenerator/ipf/ codegenerator/ipf/include/ optimizer/ translator/java/
Date Thu, 15 Mar 2007 09:14:52 GMT
Author: varlax
Date: Thu Mar 15 02:14:50 2007
New Revision: 518533

URL: http://svn.apache.org/viewvc?view=rev&rev=518533
Log:
Applied HARMONY-3374 [drlvm][jit] VMMagic EM64T port

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Thu Mar 15 02:14:50
2007
@@ -246,7 +246,7 @@
     /// convert object or integer to unmanaged pointer. Unboxing
     virtual CG_OpndHandle*  convToUPtr(PtrType * dstType, CG_OpndHandle* op) = 0;
 
-    virtual CG_OpndHandle*  convToInt(ConvertToIntOp::Types, bool isSigned, 
+    virtual CG_OpndHandle*  convToInt(ConvertToIntOp::Types, bool isSigned, bool isZeroExtend,

                                       ConvertToIntOp::OverflowMod,
                                       Type* dstType, CG_OpndHandle* src) = 0;
     virtual CG_OpndHandle*  convToFp(ConvertToFpOp::Types, Type* dstType, CG_OpndHandle*
src) = 0;

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?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
Thu Mar 15 02:14:50 2007
@@ -29,7 +29,6 @@
 #include "open/em_profile_access.h"
 #include "open/vm.h"
 
-
 #include <float.h>
 #include <math.h>
 
@@ -265,7 +264,7 @@
     appendInsts(irManager.newRuntimeHelperCallInst(CompilationInterface::Helper_Throw_LinkingException,
lengthof(args), args, NULL));
 }
 //_______________________________________________________________________________________________________________
-Opnd * InstCodeSelector::convertIntToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd)
+Opnd * InstCodeSelector::convertIntToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd,
bool isZeroExtend)
 {
     Type * srcType=srcOpnd->getType();
     assert(isIntegerType(srcType) && (isIntegerType(dstType) || dstType->isPtr()));
@@ -290,16 +289,15 @@
         if (dstOpnd==NULL)
             dstOpnd=irManager.newOpnd(dstType);
 #ifdef _EM64T_
-            appendInsts(irManager.newInstEx(srcType->isSignedInteger()?Mnemonic_MOVSX:Mnemonic_MOVZX,
1, dstOpnd, srcOpnd));
+            appendInsts(irManager.newInstEx(srcType->isSignedInteger() & !isZeroExtend
? Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
 #else
         if (dstSize<OpndSize_64){
-            appendInsts(irManager.newInstEx(srcType->isSignedInteger()?Mnemonic_MOVSX:Mnemonic_MOVZX,
1, dstOpnd, srcOpnd));
+            appendInsts(irManager.newInstEx(srcType->isSignedInteger() && !isZeroExtend
? Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
         }else{
             appendInsts(irManager.newI8PseudoInst(srcType->isSignedInteger()?Mnemonic_MOVSX:Mnemonic_MOVZX,
1, dstOpnd, srcOpnd));
         }
 #endif
     }
-
     return dstOpnd;
 }
 
@@ -370,15 +368,26 @@
 }
 
 //_______________________________________________________________________________________________________________
-Opnd * InstCodeSelector::convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd)
{
+Opnd * InstCodeSelector::convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd,
bool isZeroExtend) {
     assert(dstType->isUnmanagedPtr());
     Type* srcType = srcOpnd->getType();
     if (dstOpnd == NULL) {
         dstOpnd = irManager.newOpnd(dstType);
     }
-
     if (srcType->isObject()) {
-        appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dstOpnd, srcOpnd));
+        OpndSize srcSize=irManager.getTypeSize(srcType);
+        OpndSize dstSize=irManager.getTypeSize(dstType);
+        if (srcSize == dstSize) {
+            appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dstOpnd, srcOpnd));
+        } else {
+#ifdef _EM64T_
+            if (srcType->isInteger()) {
+                appendInsts(irManager.newInstEx(isZeroExtend?Mnemonic_MOVZX:Mnemonic_MOVSX,
1, dstOpnd, srcOpnd)); 
+            }       
+#else
+            assert(0);
+#endif
+        }
     } else if (srcType->isInteger()) {
         convertIntToInt(srcOpnd, dstType, dstOpnd);
     } else {
@@ -418,7 +427,7 @@
 }
 
 //_______________________________________________________________________________________________________________
-Opnd * InstCodeSelector::convert(CG_OpndHandle * oph, Type * dstType, Opnd * dstOpnd)
+Opnd * InstCodeSelector::convert(CG_OpndHandle * oph, Type * dstType, Opnd * dstOpnd, bool
isZeroExtend)
 {
     if (!oph)
         return NULL;
@@ -428,13 +437,13 @@
     bool converted=false;
     if (isIntegerType(srcType)){
         if (isIntegerType(dstType)){
-            dstOpnd=convertIntToInt(srcOpnd, dstType, dstOpnd);
+            dstOpnd=convertIntToInt(srcOpnd, dstType, dstOpnd, isZeroExtend);
             converted=true;
         } else if (dstType->isFP()){
             dstOpnd=convertIntToFp(srcOpnd, dstType, dstOpnd);
             converted=true;
         } else if (dstType->isUnmanagedPtr()) {
-            dstOpnd = convertToUnmanagedPtr(srcOpnd, dstType, dstOpnd);
+            dstOpnd = convertToUnmanagedPtr(srcOpnd, dstType, dstOpnd, isZeroExtend);
             converted = true;
         }
     }else if (srcType->isFP()){
@@ -452,7 +461,6 @@
         dstOpnd = convertToUnmanagedPtr(srcOpnd, dstType, dstOpnd);
         converted = true;
     }
-
     if (!converted){
         assert(irManager.getTypeSize(dstType)==srcOpnd->getSize());
         if (dstOpnd==NULL)
@@ -460,7 +468,6 @@
         else
             copyOpndTrivialOrTruncatingConversion(dstOpnd, srcOpnd);
     }
-
     return dstOpnd;
 }
 
@@ -470,6 +477,7 @@
 
 CG_OpndHandle* InstCodeSelector::convToInt(ConvertToIntOp::Types       opType,
                                                 bool                        isSigned,
+						bool                        isZeroExtend,
                                                 ConvertToIntOp::OverflowMod ovfMod,
                                                 Type*                       dstType, 
                                                 CG_OpndHandle*              src) 
@@ -482,17 +490,25 @@
         case ConvertToIntOp::I2:
             sizeType=isSigned?typeManager.getInt16Type():typeManager.getUInt16Type();
             break;
+
+#ifdef _IA32_	    
         case ConvertToIntOp::I:
+#endif	
         case ConvertToIntOp::I4:
             sizeType=isSigned?typeManager.getInt32Type():typeManager.getUInt32Type();
             break;
+
+#ifdef _EM64T_
+        case ConvertToIntOp::I:
+#endif	
         case ConvertToIntOp::I8:
-            sizeType=typeManager.getInt64Type();
+            sizeType=isSigned?typeManager.getInt64Type():typeManager.getUInt64Type();
             break;
         default: assert(0);
     }
-    Opnd * tmpOpnd=convert(src, sizeType); 
-    return convert(tmpOpnd, dstType);
+    Opnd * tmpOpnd = convert(src, sizeType, NULL, isZeroExtend); 
+    CG_OpndHandle* res =  convert(tmpOpnd, dstType, NULL, isZeroExtend);
+    return res;
 }
 
 //_______________________________________________________________________________________________________________
@@ -1930,7 +1946,7 @@
     copyOpnd(dst, opnd);
     return dst;
 #else
-    if(memType > Type::Float) {
+    if(memType > Type::Float && memType!=Type::UnmanagedPtr) {
         Opnd * opnd = irManager.newMemOpndAutoKind(typeManager.getInt32Type(), addr);
         Opnd * tmp =  irManager.newOpnd(typeManager.getInt32Type());
         Opnd * dst = irManager.newOpnd(typeManager.getInt64Type());
@@ -1963,7 +1979,11 @@
     Opnd * dst = irManager.newMemOpndAutoKind(irManager.getTypeFromTag(memType), addr);
     copyOpnd(dst, src);
 #else
-    if(memType > Type::Float) {
+    if (src->getType()->isUnmanagedPtr()) {
+        assert(src->getType()->asPtrType()->getPointedToType()->isInt1());
+        Opnd* dst = irManager.newMemOpndAutoKind(irManager.getTypeFromTag(memType), addr);
+        copyOpnd(dst, src);
+    } else  if(memType > Type::Float) {
         src = simpleOp_I8(Mnemonic_SUB, src->getType(), src, irManager.newImmOpnd(typeManager.getIntPtrType(),
(POINTER_SIZE_INT)compilationInterface.getHeapBase()));
         Opnd * opnd = irManager.newMemOpndAutoKind(typeManager.compressType(src->getType()),
addr);
         appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, opnd, src));
@@ -2780,10 +2800,21 @@
         Opnd** opnds = (Opnd**)args;
 
         //deal with constraints       
+#ifdef _EM64T_
+        Type* opnd1Type = opnds[1]->getType();
+        assert(irManager.getTypeSize(opnd1Type)==OpndSize_32 || irManager.getTypeSize(opnd1Type)==OpndSize_64);
+        assert(irManager.getTypeSize(opnds[1]->getType())==irManager.getTypeSize(opnds[2]->getType()));
+        bool is64bit = irManager.getTypeSize(opnd1Type) == OpndSize_64;
+//        Type* opType = is64bit ? typeManager.getInt64Type():typeManager.getInt32Type();
+        Constraint ceax(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, 1<<getRegIndex(is64bit?RegName_RAX:RegName_EAX));
+        Constraint cecx(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, 1<<getRegIndex(is64bit?RegName_RCX:RegName_ECX));
+        Opnd* eaxOpnd = irManager.newOpnd(opnds[1]->getType(), ceax);
+        Opnd* ecxOpnd = irManager.newOpnd(opnds[2]->getType(), cecx);
+#else
         Opnd* eaxOpnd = irManager.getRegOpnd(RegName_EAX);
         Opnd* ecxOpnd = irManager.getRegOpnd(RegName_ECX);
-        Opnd* memOpnd = irManager.newMemOpnd(opnds[0]->getType(), opnds[0]);
-        
+#endif
+        Opnd* memOpnd = irManager.newMemOpnd(opnds[1]->getType(), opnds[0]);//use opnd1
type for memopnd
         appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, eaxOpnd, opnds[1]));
         appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, ecxOpnd, opnds[2]));
         

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
Thu Mar 15 02:14:50 2007
@@ -113,7 +113,7 @@
     void           tableSwitch(CG_OpndHandle* src, uint32 nTargets);       
     void           throwException(CG_OpndHandle* exceptionObj, bool createStackTrace);
     void            throwSystemException(CompilationInterface::SystemExceptionId);
-    CG_OpndHandle* convToInt(ConvertToIntOp::Types,bool isSigned,
+    CG_OpndHandle* convToInt(ConvertToIntOp::Types,bool isSigned, bool isZeroExtend,
                               ConvertToIntOp::OverflowMod,Type* dstType, CG_OpndHandle* src);
     CG_OpndHandle* convToFp(ConvertToFpOp::Types, Type* dstType, CG_OpndHandle* src);
 
@@ -318,19 +318,19 @@
     //
     uint64 currentHIRInstrID;
 
-    Opnd *  convertIntToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
+    Opnd *  convertIntToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL, bool isZeroExtend=false);
     Opnd *  convertIntToFp(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
     Opnd *  convertFpToInt(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
     Opnd *  convertFpToFp(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
     Opnd*   convertUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
-    Opnd*   convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL);
+    Opnd*   convertToUnmanagedPtr(Opnd * srcOpnd, Type * dstType, Opnd * dstOpnd=NULL, bool
isZeroExtend=false);
     
     bool    isIntegerType(Type * type)
     { return type->isInteger()||type->isBoolean()||type->isChar(); }
     void    copyOpnd(Opnd *dst, Opnd *src);
     void    copyOpndTrivialOrTruncatingConversion(Opnd *dst, Opnd *src);
 
-    Opnd * convert(CG_OpndHandle * oph, Type * dstType, Opnd * dstOpnd=NULL);
+    Opnd * convert(CG_OpndHandle * oph, Type * dstType, Opnd * dstOpnd=NULL, bool isZeroExtend=false);
 
     Opnd * simpleOp_I8(Mnemonic mn, Type * dstType, Opnd * src1, Opnd * src2);
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/IpfInstCodeSelector.cpp
Thu Mar 15 02:14:50 2007
@@ -689,6 +689,7 @@
 
 CG_OpndHandle *IpfInstCodeSelector::convToInt(ConvertToIntOp::Types       opType,
                                               bool                        isSigned,
+					      bool                        isZeroExtend,
                                               ConvertToIntOp::OverflowMod ovfMod,
                                               Type                        *dstType, 
                                               CG_OpndHandle               *src_) {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ipf/include/IpfCodeSelector.h
Thu Mar 15 02:14:50 2007
@@ -144,7 +144,7 @@
     CG_OpndHandle *shru  (IntegerOp::Types, CG_OpndHandle*, CG_OpndHandle*);
     CG_OpndHandle *shladd(IntegerOp::Types, CG_OpndHandle*, uint32, CG_OpndHandle*);
 
-    CG_OpndHandle *convToInt(ConvertToIntOp::Types, bool, ConvertToIntOp::OverflowMod, Type*,
CG_OpndHandle*);
+    CG_OpndHandle *convToInt(ConvertToIntOp::Types, bool, bool, ConvertToIntOp::OverflowMod,
Type*, CG_OpndHandle*);
     CG_OpndHandle *convToFp(ConvertToFpOp::Types, Type*, CG_OpndHandle*);
 
     CG_OpndHandle *ldc_i4(int32);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeSelectors.cpp Thu Mar 15 02:14:50
2007
@@ -607,6 +607,7 @@
             }
             break;
         case Op_Conv:
+        case Op_ConvZE:
         case Op_ConvUnmanaged:
             {
                 assert(inst->getNumSrcOperands() == 1);
@@ -621,8 +622,10 @@
                     cgInst = instructionCallback.convToUPtr(dstType->asPtrType(), getCGInst(inst->getSrc(0)));
                 } else {
                     bool isSigned = Type::isSignedInteger(inst->getType());
+                    bool isZeroExtend = inst->getOpcode() == Op_ConvZE;
                     cgInst = instructionCallback.convToInt(mapToIntConvertOpType(inst),
                         isSigned, 
+                        isZeroExtend,
                         mapToIntConvertOvfMod(inst), 
                         dstType,
                         getCGInst(inst->getSrc(0)));
@@ -984,12 +987,19 @@
                 if (!genConsts) break;
                 ConstInst* constInst = (ConstInst*)inst;
                 switch (inst->getType()) {
-        case Type::UIntPtr://mfursov todo!
-        case Type::IntPtr://mfursov todo!
-        case Type::UnmanagedPtr://mfursov todo!
+#ifdef _IA32_
+        case Type::UIntPtr:
+        case Type::IntPtr:
+        case Type::UnmanagedPtr:
+#endif
         case Type::Int32:
             cgInst = instructionCallback.ldc_i4(constInst->getValue().i4);
             break;
+#ifdef _EM64T_
+        case Type::UIntPtr:
+        case Type::IntPtr:
+        case Type::UnmanagedPtr:
+#endif
         case Type::Int64:
             cgInst = instructionCallback.ldc_i8(constInst->getValue().i8);
             break;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.cpp Thu Mar 15 02:14:50
2007
@@ -109,6 +109,15 @@
     virtual Inst* genConv(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd* src){
         return irBuilder.genConv(dstType, toType, ovfMod, src)->getInst();
     }
+
+    virtual Inst* genConvZE(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd* src){
+        return irBuilder.genConvZE(dstType, toType, ovfMod, src)->getInst();
+    }
+    
+    virtual Inst* genConvUnmanaged(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd*
src){
+        return irBuilder.genConvUnmanaged(dstType, toType, ovfMod, src)->getInst();
+    }
+    
     // shifts
     virtual Inst* genShladd(Type* type, Opnd* src1, Opnd* src2, Opnd *src3){
         return irBuilder.genShladd(type, src1, src2, src3)->getInst();
@@ -944,13 +953,10 @@
 IRBuilder::genConv(Type* dstType,
                    Type::Tag toType,
                    Modifier ovfMod,
-                   Opnd* src) {
+                   Opnd* src) 
+{
     src = propagateCopy(src);
-    Opcode opcode = Op_Conv;
-    if ((dstType->isUnmanagedPtr() && src->getType()->isObject()) || (dstType->isObject()
&& src->getType()->isUnmanagedPtr())) {
-        opcode = Op_ConvUnmanaged;
-    }
-    Operation operation(opcode, toType, ovfMod);
+    Operation operation(Op_Conv, toType, ovfMod);
     uint32 hashcode = operation.encodeForHashing();
     Opnd* dst = lookupHash(hashcode, src->getId());
     if (dst) return dst;
@@ -960,7 +966,60 @@
     }
     if (!dst) {
         dst = createOpnd(dstType);
-        appendInst(instFactory->makeConv(ovfMod, toType, dst, src));
+	Inst* inst = instFactory->makeConv(ovfMod, toType, dst, src);
+        appendInst(inst);
+    }
+    insertHash(hashcode, src->getId(), dst->getInst());
+    return dst;
+}
+
+Opnd*
+IRBuilder::genConvUnmanaged(Type* dstType,
+                   Type::Tag toType,
+                   Modifier ovfMod,
+                   Opnd* src) 
+{
+    assert((dstType->isUnmanagedPtr() && src->getType()->isObject()) 
+            || (dstType->isObject() && src->getType()->isUnmanagedPtr()));
+    src = propagateCopy(src);
+    Operation operation(Op_ConvUnmanaged, toType, ovfMod);
+    uint32 hashcode = operation.encodeForHashing();
+    Opnd* dst = lookupHash(hashcode, src->getId());
+    if (dst) return dst;
+
+    if (irBuilderFlags.doSimplify) {
+        dst = simplifier->simplifyConvUnmanaged(dstType, toType, ovfMod, src);
+    }
+    if (!dst) {
+        dst = createOpnd(dstType);
+        Inst* inst = instFactory->makeConvUnmanaged(ovfMod, toType, dst, src);
+        appendInst(inst);
+    }
+    
+    insertHash(hashcode, src->getId(), dst->getInst());
+    return dst;
+}
+
+Opnd*
+IRBuilder::genConvZE(Type* dstType,
+                   Type::Tag toType,
+                   Modifier ovfMod,
+                   Opnd* src) 
+{
+    assert(src->getType()->isInteger() && (dstType->isInteger() || dstType->isUnmanagedPtr()));
+    src = propagateCopy(src);
+    Operation operation(Op_ConvZE, toType, ovfMod);
+    uint32 hashcode = operation.encodeForHashing();
+    Opnd* dst = lookupHash(hashcode, src->getId());
+    if (dst) return dst;
+
+    if (irBuilderFlags.doSimplify) {
+        dst = simplifier->simplifyConvZE(dstType, toType, ovfMod, src);
+    }
+    if (!dst) {
+        dst = createOpnd(dstType);
+	Inst* inst = instFactory->makeConvZE(ovfMod, toType, dst, src);
+        appendInst(inst);
     }
     insertHash(hashcode, src->getId(), dst->getInst());
     return dst;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h Thu Mar 15 02:14:50
2007
@@ -104,6 +104,8 @@
     Opnd* genNot(Type* dstType, Opnd* src);//TR //SI
     // Conversion
     Opnd* genConv(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd* src); //TR //SI
+    Opnd* genConvZE(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd* src); //TR //SI
+    Opnd* genConvUnmanaged(Type* dstType, Type::Tag toType, Modifier ovfMod, Opnd* src);
//TR //SI
     // Shift
     Opnd* genShl(Type* dstType, Modifier mod, Opnd* value, Opnd* shiftAmount);//TR //SI
     Opnd* genShr(Type* dstType, Modifier mods, Opnd* value, Opnd* shiftAmount);//TR //SI

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.cpp Thu Mar 15 02:14:50 2007
@@ -1781,13 +1781,18 @@
 
 // conversion
 Inst* InstFactory::makeConv(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src) {
-    Opcode opcode = Op_Conv;
-    if ((dst->getType()->isUnmanagedPtr() && src->getType()->isObject())

-        || (dst->getType()->isObject() && src->getType()->isUnmanagedPtr()))

-    {
-        opcode = Op_ConvUnmanaged;
-    }
-    return makeInst(opcode, mod, toType, dst, src);
+    return makeInst(Op_Conv, mod, toType, dst, src);
+}
+
+Inst* InstFactory::makeConvZE(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src) {
+    assert((dst->getType()->isInteger() || dst->getType()->isUnmanagedPtr())
&& src->getType()->isInteger());
+    return makeInst(Op_ConvZE, mod, toType, dst, src);
+}
+
+Inst* InstFactory::makeConvUnmanaged(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src)
{
+    assert ((dst->getType()->isUnmanagedPtr() && src->getType()->isObject())

+        || (dst->getType()->isObject() && src->getType()->isUnmanagedPtr()));

+    return makeInst(Op_ConvUnmanaged, mod, toType, dst, src);
 }
 
 // shifts
@@ -2657,6 +2662,7 @@
     case Op_Not:                return caseNot(inst);
     case Op_Select:             return caseSelect(inst);
     case Op_Conv:               return caseConv(inst);
+    case Op_ConvZE:             return caseConvZE(inst);
     case Op_ConvUnmanaged:      return caseConvUnmanaged(inst);
     case Op_Shladd:             return caseShladd(inst);
     case Op_Shl:                return caseShl(inst);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Inst.h Thu Mar 15 02:14:50 2007
@@ -1113,6 +1113,8 @@
     Inst*    makeSelect(Opnd* dst, Opnd* src1, Opnd* src2, Opnd* src3);
     // conversion
     Inst*    makeConv(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src);
+    Inst*    makeConvZE(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src);
+    Inst*    makeConvUnmanaged(Modifier mod, Type::Tag toType, Opnd* dst, Opnd* src);
     // shifts
     Inst*    makeShladd(Opnd* dst, Opnd* value, Opnd* shiftAmount, Opnd *addTo); // shiftAmount
must be constant
     Inst*    makeShl(Modifier mod, Opnd* dst, Opnd* value, Opnd* shiftAmount);
@@ -1614,6 +1616,10 @@
     // conversion
     virtual Inst*
     caseConv(Inst* inst)=0;//                {return caseDefault(inst);}
+
+    // conversion
+    virtual Inst*
+    caseConvZE(Inst* inst)=0;//                {return caseDefault(inst);}
 
     // conversion
     virtual Inst*

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.cpp Thu Mar 15 02:14:50 2007
@@ -92,7 +92,8 @@
     { Op_Not,                   false, MB::Movable,       MK::None,                     
            "not   ",        "not       %s -) %l",           },
     { Op_Select,                false, MB::Movable,       MK::None,                     
            "select",        "select %s -) %l",              }, // (src1 ? src2 : src3)
     { Op_Conv,                  false, MB::Movable,       MK::Overflow_and_Exception_and_Strict,
    "conv  ",        "conv%t%m %s -) %l",            }, 
-    { Op_ConvUnmanaged,         false, MB::StoreOrSync,   MK::Overflow_and_Exception_and_Strict,
    "convu ",        "convu%t%m %s -) %l",           }, 
+    { Op_ConvZE,                false, MB::Movable,       MK::Overflow_and_Exception_and_Strict,
    "convze ",        "conv_ze_%t%m %s -) %l",            }, 
+    { Op_ConvUnmanaged,         false, MB::StoreOrSync,   MK::Overflow_and_Exception_and_Strict,
    "convu ",        "conv_unm_%t%m %s -) %l",           }, 
     { Op_Shladd,                false, MB::Movable,       MK::None,                     
            "shladd",        "shladd %s -) %l",              }, // no mods, 2nd operand must
be LdConstant
     { Op_Shl,                   false, MB::Movable,       MK::ShiftMask,                
            "shl   ",        "shl%m  %s -) %l",              }, 
     { Op_Shr,                   false, MB::Movable,       MK::ShiftMask_and_Signed,     
            "shr   ",        "shr%m  %s -) %l",              }, 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/Opcode.h Thu Mar 15 02:14:50 2007
@@ -292,6 +292,7 @@
     Op_Select,                      // (src1 ? src2 : src3)
     // Conversion
     Op_Conv,                        // OverflowModifier, ExceptionModifier
+    Op_ConvZE,                      // OverflowModifier, ExceptionModifier    
     Op_ConvUnmanaged,               // OverflowModifier, ExceptionModifier
     // Shift
     Op_Shladd,                      // no mods, 2nd operand must be LdConstant

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/codelowerer.h Thu Mar 15 02:14:50
2007
@@ -104,6 +104,9 @@
     Inst* caseConv(Inst* inst) {return caseDefault(inst);}
 
     // conversion
+    Inst* caseConvZE(Inst* inst) {return caseDefault(inst);}
+
+    // conversion
     Inst* caseConvUnmanaged(Inst* inst) {return caseDefault(inst);}
 
     // shifts

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escapeanalyzer.cpp Thu Mar 15 02:14:50
2007
@@ -136,6 +136,7 @@
         // conversion to unmanaged pointer is also an escape!
         //
     case Op_Conv:
+    case Op_ConvZE:
     case Op_ConvUnmanaged:
         break;
         // in the absence of ssa form, stores to vars can conservatively escape

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/hashvaluenumberer.cpp Thu Mar 15
02:14:50 2007
@@ -157,6 +157,7 @@
     
     // conversion
     Inst* caseConv(Inst* inst)              { return hashIfNoException(inst); }
+    Inst* caseConvZE(Inst* inst)            { return hashIfNoException(inst); }
     Inst* caseConvUnmanaged(Inst* inst)     { return caseDefault(inst); }
     
     // shifts
@@ -2359,7 +2360,7 @@
 void InstValueNumberer::addInfoFromPEI(Inst *pei, bool isExceptionEdge)
 {
     switch (pei->getOpcode()) {
-    case Op_Add: case Op_Mul: case Op_Sub: case Op_Conv: case Op_ConvUnmanaged:
+    case Op_Add: case Op_Mul: case Op_Sub: case Op_Conv: case Op_ConvZE: case Op_ConvUnmanaged:
     case Op_TauCheckDivOpnds:
         break;
     case Op_DirectCall: case Op_TauVirtualCall: case Op_IndirectCall:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/lazyexceptionopt.cpp Thu Mar 15
02:14:50 2007
@@ -874,6 +874,7 @@
         case Op_Select:
             return false;
         case Op_Conv:
+        case Op_ConvZE:
         case Op_ConvUnmanaged:
             return true;
         case Op_Shladd:

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/memoryopt.cpp Thu Mar 15 02:14:50
2007
@@ -930,7 +930,7 @@
     case Op_Add: case Op_Mul: case Op_Sub: case Op_TauDiv: case Op_TauRem: 
     case Op_Neg: case Op_MulHi: case Op_Min: case Op_Max: case Op_Abs:
     case Op_And: case Op_Or: case Op_Xor: 
-    case Op_Not: case Op_Select: case Op_Conv: case Op_ConvUnmanaged: case Op_Shladd: case
Op_Shl: 
+    case Op_Not: case Op_Select: case Op_Conv: case Op_ConvZE: case Op_ConvUnmanaged: case
Op_Shladd: case Op_Shl: 
     case Op_Shr: case Op_Cmp: case Op_Cmp3: 
     case Op_Branch: case Op_Jump: case Op_Switch:
     case Op_LdConstant: 
@@ -1393,6 +1393,7 @@
     case Op_DefArg: //magic as method param
         break;
     case Op_Conv: //the result of a conversion
+    case Op_ConvZE:
     case Op_ConvUnmanaged:
     case Op_TauLdInd: // the result of static field load
         break;

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=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp Thu Mar 15 02:14:50
2007
@@ -1803,6 +1803,25 @@
 }
 
 Opnd*
+Simplifier::simplifyConvZE(Type* dstType,
+                         Type::Tag toType,
+                         Modifier ovfmod,
+                         Opnd* src) 
+{
+    return NULL;
+}
+
+Opnd*
+Simplifier::simplifyConvUnmanaged(Type* dstType,
+                         Type::Tag toType,
+                         Modifier ovfmod,
+                         Opnd* src) 
+{
+    return NULL;
+}
+
+
+Opnd*
 Simplifier::simplifyShladd(Type* dstType,
                            Opnd* value,
                            Opnd* shiftAmount,
@@ -4086,6 +4105,27 @@
 {
     Opnd* dst = opndManager.createSsaTmpOpnd(type);
     Inst* inst = instFactory.makeConv(ovfMod, toType, dst, src);
+    insertInst(inst);
+    return inst;
+}
+
+Inst* 
+SimplifierWithInstFactory::genConvZE(Type* type, Type::Tag toType, 
+                                   Modifier ovfMod, 
+                                   Opnd* src)
+{
+    Opnd* dst = opndManager.createSsaTmpOpnd(type);
+    Inst* inst = instFactory.makeConvZE(ovfMod, toType, dst, src);
+    insertInst(inst);
+    return inst;
+}
+Inst* 
+SimplifierWithInstFactory::genConvUnmanaged(Type* type, Type::Tag toType, 
+                                   Modifier ovfMod, 
+                                   Opnd* src)
+{
+    Opnd* dst = opndManager.createSsaTmpOpnd(type);
+    Inst* inst = instFactory.makeConvUnmanaged(ovfMod, toType, dst, src);
     insertInst(inst);
     return inst;
 }

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=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.h Thu Mar 15 02:14:50
2007
@@ -62,6 +62,8 @@
     Opnd* simplifyNot(Type*, Opnd* src1);
     Opnd* simplifySelect(Type*, Opnd* src1, Opnd* src2, Opnd* src3);
     Opnd* simplifyConv(Type*, Type::Tag toType, Modifier, Opnd* src);
+    Opnd* simplifyConvZE(Type*, Type::Tag toType, Modifier, Opnd* src);
+    Opnd* simplifyConvUnmanaged(Type*, Type::Tag toType, Modifier, Opnd* src);
     Opnd* simplifyShladd(Type* dstType, Opnd* value, Opnd* shiftAmount, Opnd *addto);
     Opnd* simplifyShl(Type* dstType, Modifier, Opnd* value, Opnd* shiftAmount);
     Opnd* simplifyShr(Type* dstType, Modifier, Opnd* value, Opnd* shiftAmount);
@@ -206,6 +208,10 @@
     // conversion
     virtual Inst* genConv(Type*, Type::Tag toType, Modifier, 
                           Opnd* src1) = 0;
+    virtual Inst* genConvZE(Type*, Type::Tag toType, Modifier, 
+                          Opnd* src1) = 0;
+    virtual Inst* genConvUnmanaged(Type*, Type::Tag toType, Modifier, 
+                          Opnd* src1) = 0;
     // shifts
     virtual Inst* genShladd(Type*, Opnd *value,
                             Opnd* shiftAmount, Opnd* addTo) = 0;
@@ -420,6 +426,11 @@
     Inst* caseConvUnmanaged(Inst* inst) {
         return inst;
     }
+    
+    Inst* caseConvZE(Inst* inst) {
+        return inst;
+    }
+
 
     // shifts
     Inst* caseShladd(Inst* inst) {
@@ -1114,6 +1125,11 @@
 
     virtual Inst* genConv(Type*, Type::Tag toType, Modifier, 
                           Opnd* src1);
+    virtual Inst* genConvZE(Type*, Type::Tag toType, Modifier, 
+                          Opnd* src1);
+    virtual Inst* genConvUnmanaged(Type*, Type::Tag toType, Modifier, 
+                          Opnd* src1);
+
     virtual Inst* genShladd(Type*, Opnd *value,
                             Opnd* shiftAmount, Opnd* addTo);
     virtual Inst* genShl(Type*, Modifier,

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp?view=diff&rev=518533&r1=518532&r2=518533
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
Thu Mar 15 02:14:50 2007
@@ -41,16 +41,12 @@
 
 // magics support    
 static bool isMagicClass(Type* type) {
-#ifdef _EM64T_
-    return false;//magics are not tested on EM64T.
-#else
     static const char magicPackage[] = "org/vmmagic/unboxed/";
     static const unsigned magicPackageLen = sizeof(magicPackage)-1;
 
     const char* name = type->getName();
     bool res =  !strncmp(name, magicPackage, magicPackageLen);
     return res;
-#endif    
 }
 
 static bool isMagicMethod(MethodDesc* md) {
@@ -3712,6 +3708,7 @@
 void JavaByteCodeTranslator::genMagic(MethodDesc *md, uint32 numArgs, Opnd **srcOpnds, Type
*magicRetType) {
     const char* mname = md->getName();
     Type* resType = convertMagicType2HIR(typeManager, magicRetType);
+    Type* cmpResType = typeManager.getInt32Type();
     Opnd* tauSafe = irBuilder.genTauSafe();
     Opnd* arg0 = numArgs > 0 ? srcOpnds[0]: NULL;
     Opnd* arg1 = numArgs > 1 ? srcOpnds[1]: NULL;
@@ -3719,15 +3716,21 @@
 
     
     // max, one, zero
-    int theConst = 0;
+    POINTER_SIZE_INT theConst = 0;
     bool loadConst = false;
-    if (!strcmp(mname, "max"))          { loadConst = true; theConst = -1;}
+    if (!strcmp(mname, "max"))          { loadConst = true; theConst = ~(POINTER_SIZE_INT)0;}
     else if (!strcmp(mname, "one"))     { loadConst = true; theConst =  1;}
     else if (!strcmp(mname, "zero"))    { loadConst = true; theConst =  0;}
     else if (!strcmp(mname, "nullReference")) { loadConst = true; theConst =  0;}
     if (loadConst) {
-        ConstInst::ConstValue v; v.i4 = theConst;
+        ConstInst::ConstValue v;
+#ifdef _EM64T_
+	v.i8 = theConst;
+#else
+	v.i4 = theConst;	
+#endif
         Opnd* res = irBuilder.genLdConstant(typeManager.getUIntPtrType(), v);
+	
         if (resType->isPtr()) {
             res = irBuilder.genConv(resType, resType->tag, mod, res);
         }
@@ -3754,11 +3757,22 @@
         || !strcmp(mname, "toOffset"))
     {
         assert(numArgs == 1);
-        if (resType == arg0->getType()) {
+        Type* srcType = arg0->getType();
+        if (resType == srcType) {
             pushOpnd(irBuilder.genCopy(arg0));
             return;
-        } 
-        Opnd* res = irBuilder.genConv(resType, resType->tag, mod, arg0);
+        }
+        Opnd* res = NULL;
+        
+        if ((srcType->isObject() && resType->isUnmanagedPtr())
+            || (resType->isObject() && srcType->isUnmanagedPtr())) 
+        {
+            res = irBuilder.genConvUnmanaged(resType, resType->tag, mod, arg0);
+        } else if (!strcmp(mname, "fromIntZeroExtend")) {
+            res = irBuilder.genConvZE(resType, resType->tag, mod, arg0);
+        } else {
+            res = irBuilder.genConv(resType, resType->tag, mod, arg0);
+        }
         pushOpnd(res);
         return;
     }
@@ -3768,11 +3782,11 @@
     //
     bool isOp = false;
     if (!strcmp(mname, "isZero")) { isOp = true; theConst = 0; }
-    else if (!strcmp(mname, "isMax")) { isOp = true; theConst = ~0; }
+    else if (!strcmp(mname, "isMax")) { isOp = true; theConst = ~(POINTER_SIZE_INT)0; }
     else if (!strcmp(mname, "isNull")) { isOp = true; theConst = 0; }
     if (isOp) {
         assert(numArgs == 1);
-        Opnd* res = irBuilder.genCmp(typeManager.getInt32Type(), Type::Int32, Cmp_EQ, arg0,
irBuilder.genLdConstant(theConst));
+        Opnd* res = irBuilder.genCmp(cmpResType, arg0->getType()->tag, Cmp_EQ, arg0,
irBuilder.genLdConstant((POINTER_SIZE_SINT)theConst));
         pushOpnd(res);
         return;
     }
@@ -3800,7 +3814,7 @@
         assert(arg0->getType() == arg1->getType());
         Opnd* op0 = commuteOpnds ? arg1 : arg0;
         Opnd* op1 = commuteOpnds ? arg0 : arg1;
-        Opnd* res = irBuilder.genCmp(typeManager.getInt32Type(), Type::Int32, cm, op0, op1);
+        Opnd* res = irBuilder.genCmp(cmpResType, arg0->getType()->tag, cm, op0, op1);
         pushOpnd(res);
         return;
     }
@@ -3821,7 +3835,8 @@
     if (!strcmp(mname, "minus")){ 
         assert(numArgs==2); 
         if (resType->isPtr()) {
-            Opnd* negArg1 = irBuilder.genNeg(typeManager.getInt32Type(), arg1);
+            Type* negType = arg1->getType()->isUIntPtr() ? typeManager.getIntPtrType()
: arg1->getType();
+            Opnd* negArg1 = irBuilder.genNeg(negType, arg1);
             pushOpnd(irBuilder.genAddScaledIndex(arg0, negArg1)); 
         } else {
             pushOpnd(irBuilder.genSub(resType, mod, arg0, arg1)); 



Mime
View raw message