harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfur...@apache.org
Subject svn commit: r573295 [3/3] - in /harmony/enhanced/drlvm/trunk/vm: include/open/ jitrino/src/jet/ jitrino/src/optimizer/ jitrino/src/shared/ jitrino/src/translator/java/ jitrino/src/vm/drl/ vmcore/src/class_support/
Date Thu, 06 Sep 2007 15:24:10 GMT
Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/escanalyzer.h Thu Sep  6 08:24:09
2007
@@ -73,24 +73,26 @@
 
     // Connection Graph Structure
 // CnG node types
-    static const uint32 NT_OBJECT   = 8;  // Op_LdRef,Op_NewObj,Op_NewArray,Op_NewMultiArray
   
-    static const uint32 NT_DEFARG   = NT_OBJECT+1;  // formal parameter - Op_DefArg
-    static const uint32 NT_RETVAL   = 16;           // Op_DirectCall,Op_IndirectMemoryCall-returned
by method 
-    static const uint32 NT_CATCHVAL = NT_RETVAL+1;  // catched value
-    static const uint32 NT_LDOBJ    = 32;           // Op_LdConstant,Op_TauLdInd,Op_LdVar,

+    enum CnGNodeTypes {
+        NT_OBJECT   = 8,  // Op_LdRef,Op_NewObj,Op_NewArray,Op_NewMultiArray    
+        NT_DEFARG   = NT_OBJECT+1,  // formal parameter - Op_DefArg
+        NT_RETVAL   = 16,           // Op_DirectCall,Op_IndirectMemoryCall-returned by method

+        NT_CATCHVAL = NT_RETVAL+1,  // catched value
+        NT_LDOBJ    = 32,           // Op_LdConstant,Op_TauLdInd,Op_LdVar, 
                                                     // Op_TauStaticCast,Op_TauCast 
-    static const uint32 NT_INTPTR   = NT_LDOBJ+1;   // Op_SaveRet
-    static const uint32 NT_VARVAL   = NT_LDOBJ+2;   // Op_StVar,Op_Phi
-    static const uint32 NT_ARRELEM  = NT_LDOBJ+3;   // Op_LdArrayBaseAddr,Op_AddScaledIndex
-    static const uint32 NT_REF      = NT_LDOBJ+4;   // reference value - Op_LdFieldAddr,
+        NT_INTPTR   = NT_LDOBJ+1,   // Op_SaveRet
+        NT_VARVAL   = NT_LDOBJ+2,   // Op_StVar,Op_Phi
+        NT_ARRELEM  = NT_LDOBJ+3,   // Op_LdArrayBaseAddr,Op_AddScaledIndex
+        NT_REF      = NT_LDOBJ+4,   // reference value - Op_LdFieldAddr,
                                                     // Op_LdStaticAddr, Op_TauCast, Op_TauStaticCast
-    static const uint32 NT_STFLD    = 64;           // Op_LdStaticAddr
-    static const uint32 NT_INSTFLD  = NT_STFLD+1;   // Op_LdFieldAddr
-    static const uint32 NT_ACTARG   = 128;          // Op_DirectCall,Op_IndirectMemoryCall
-    static const uint32 NT_EXITVAL  = 256;          // returned value - Op_Return
-    static const uint32 NT_THRVAL   = NT_EXITVAL+1; // thrown value - Op_Throw
-    static const uint32 NT_LDVAL    = 512;          // Op_TauLdInd, Op_TauStInd
-	static const uint32 NT_OBJS     = NT_OBJECT|NT_RETVAL|NT_LDOBJ;  //for findCnGNode_op
+        NT_STFLD    = 64,           // Op_LdStaticAddr
+        NT_INSTFLD  = NT_STFLD+1,   // Op_LdFieldAddr
+        NT_ACTARG   = 128,          // Op_DirectCall,Op_IndirectMemoryCall
+        NT_EXITVAL  = 256,          // returned value - Op_Return
+        NT_THRVAL   = NT_EXITVAL+1, // thrown value - Op_Throw
+        NT_LDVAL    = 512,          // Op_TauLdInd, Op_TauStInd
+        NT_OBJS     = NT_OBJECT|NT_RETVAL|NT_LDOBJ  //for findCnGNode_op
+    };
 // CnG node reference types
     static const uint32 NR_PRIM = 0;
     static const uint32 NR_REF = 1;
@@ -245,22 +247,8 @@
     // list of Op_Branch and Op_TauCheckNull instructions (for scalar replacement optimization)
     Insts* checkInsts;
 
-    // variable used to output debug information
-    int _cfgirun;
-    int _instrInfo;
-    int _instrInfo2;
-    int _cngnodes;
-    int _cngedges;
-    int _scanMtds;
-    int _setState;
-    int _printstat;
-    int _eainfo;
-    int _seinfo;
-    int _scinfo;
-#define  prsNum  10
-    int prsArr[prsNum];
-
-
+    bool shortLog;
+    bool verboseLog;
     // common method for both EscAnalyzer constructors
     void init();
     // output escape analysis flags
@@ -299,12 +287,12 @@
 /**
  * Creates new CnG node for specified call instruction argument. 
  * @param inst - instruction,
- * @param md - callee method description,
+ * @param mpt - callee method description,
  * @param ntype - CnG node type,
  * @param narg - method argument.
  * @return created CnGnode. 
  */
-    CnGNode* addCnGNode_mp(Inst* inst, MethodDesc* md, uint32 ntype, uint32 narg);
+    CnGNode* addCnGNode_mp(Inst* inst, MethodPtrType* mpt, uint32 ntype, uint32 narg);
 
 /**
  * Creates new CnG node for specified return or throw instruction. 
@@ -1003,6 +991,12 @@
  * @param scObjFlds - list to collect onode operand field usage.
  */
     void checkToScalarizeFinalFiels(CnGNode* onode, ScObjFlds* scObjFlds);
+
+
+    void instrExam_processLdFieldAddr(Inst* inst);
+    void instrExam2_processLdFieldAddr(Inst* inst);
+    static void getLdFieldAddrInfo(Inst* inst, Type*& type, uint32& nType);
+
 };
 
 } //namespace Jitrino 

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?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifier.cpp Thu Sep  6 08:24:09
2007
@@ -3037,7 +3037,7 @@
 Simplifier::simplifyTauCast(Opnd* src, Opnd *tauCheckedNull, Type* castType) {
     Type *opndType = src->getType();
     if (isNullObject(src) || 
-        irManager.getTypeManager().isSubClassOf(opndType, castType)) {
+        irManager.getTypeManager().isResolvedAndSubClassOf(opndType, castType)) {
         return genTauStaticCast(src, tauCheckedNull, castType)->getDst();
     }
     return NULL;
@@ -3047,10 +3047,10 @@
 Simplifier::simplifyTauAsType(Opnd* src, Opnd* tauCheckedNull, Type* type) {
     Type* srcType = src->getType();
     if (isNullObject(src) || 
-        irManager.getTypeManager().isSubClassOf(srcType, type))
+        irManager.getTypeManager().isResolvedAndSubClassOf(srcType, type))
         return src;
     if (isExactType(src) &&
-        !irManager.getTypeManager().isSubClassOf(srcType, type)) {
+        !irManager.getTypeManager().isResolvedAndSubClassOf(srcType, type)) {
         ConstInst::ConstValue val;
         val.i = NULL;
         return genLdConstant(irManager.getTypeManager().getNullObjectType(),
@@ -3065,7 +3065,7 @@
 
     bool srcIsNonNull = (tauCheckedNull->getInst()->getOpcode() != Op_TauUnsafe);
     if (srcIsNonNull &&
-        irManager.getTypeManager().isSubClassOf(srcType, type)) {
+        irManager.getTypeManager().isResolvedAndSubClassOf(srcType, type)) {
         return genLdConstant((int32)1)->getDst();
     } 
 
@@ -3075,7 +3075,7 @@
     }
 
     if (isExactType(src) &&
-        !irManager.getTypeManager().isSubClassOf(srcType, type))
+        !irManager.getTypeManager().isResolvedAndSubClassOf(srcType, type))
         return genLdConstant((int32)0)->getDst();
 
     return NULL;
@@ -3088,7 +3088,7 @@
     assert(arrayBase->getType()->isArrayType());
     Type *arrayElemType = ((ArrayType*)arrayBase->getType())->getElementType();
     if (isExactType(arrayBase) &&
-        irManager.getTypeManager().isSubClassOf(src->getType(), arrayElemType)) {
+        irManager.getTypeManager().isResolvedAndSubClassOf(src->getType(), arrayElemType))
{
         return genTauHasExactType(arrayBase,arrayBase->getType())->getDst();
     }
     // check to see if src was loaded from arrayBase
@@ -4354,9 +4354,9 @@
         return genTauSafe()->getDst();
     } else if (opndType->isUnresolvedType()) {
         return NULL;
-    } else if (irManager.getTypeManager().isSubClassOf(opndType, castType)) {
+    } else if (irManager.getTypeManager().isResolvedAndSubClassOf(opndType, castType)) {
         return genTauHasType(src, castType)->getDst();
-    } else if (!irManager.getTypeManager().isSubClassOf(castType, opndType)) {
+    } else if (!irManager.getTypeManager().isResolvedAndSubClassOf(castType, opndType)) {
         if (Log::isEnabled()) {
             Log::out() << "in simplifyTauCheckCast: castToType ";
             castType->print(Log::out());
@@ -4416,7 +4416,7 @@
                 return foundRecurse;
             }
             // couldn't be more precise, just use this one.
-            if (irManager.getTypeManager().isSubClassOf(typeInfo, castType)) {
+            if (irManager.getTypeManager().isResolvedAndSubClassOf(typeInfo, castType)) {
                 return tauCastChecked;
             }
         }

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?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/simplifytaus.cpp Thu Sep  6 08:24:09
2007
@@ -602,7 +602,7 @@
             TypeInst *srcTypeInst = srcInst->asTypeInst();
             assert(srcTypeInst);
             Type *castType = srcTypeInst->getTypeInfo();
-            if (irManager.getTypeManager().isSubClassOf(castType, type)) {
+            if (irManager.getTypeManager().isResolvedAndSubClassOf(castType, type)) {
                 // is guaranteed by the cast
                 Opnd *tauOpnd = srcInst->getSrc(1);
                 assert(tauOpnd->getType()->tag == Type::Tau);
@@ -625,7 +625,7 @@
             TypeInst *srcTypeInst = srcInst->asTypeInst();
             assert(srcTypeInst);
             Type *castType = srcTypeInst->getTypeInfo();
-            if (irManager.getTypeManager().isSubClassOf(castType, type)) {
+            if (irManager.getTypeManager().isResolvedAndSubClassOf(castType, type)) {
                 // is guaranteed
                 return genTauSafe();
             } else {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp Thu Sep  6 08:24:09 2007
@@ -169,6 +169,13 @@
     }
 }
 
+bool TypeManager::isResolvedAndSubClassOf(Type* type1, Type *type2) {
+    if (type1->isUnresolvedType() || type2->isUnresolvedType()) {
+        return false;
+    }
+    return isSubClassOf(type1, type2);
+}
+
 bool TypeManager::isSubTypeOf(Type *type1, Type *type2) {
     if (type1==type2) return true;
     bool oneIsCompressed = type1->isCompressedReference();
@@ -535,7 +542,7 @@
     UnresolvedMethodPtrType* methType = methodsPerClass->lookup((void*)(POINTER_SIZE_INT)cpIndex);
     if (!methType) {
         methType = new (memManager) UnresolvedMethodPtrType(enclosingClass, cpIndex, *this,

-            sig->getNumParams(), sig->getParamTypes(), sig->getRetType());
+            sig->getNumParams(), sig->getParamTypes(), sig->getRetType(), sig->getSignatureString());
         methodsPerClass->insert((void*)(POINTER_SIZE_INT)cpIndex, methType);
     }
     return methType;
@@ -667,6 +674,9 @@
 bool    
 NamedType::isFinalizable() {
     assert(!isUnresolvedType());
+    if (isInterface()) {
+        return false;
+    }
     return VMInterface::isFinalizable(vmTypeHandle);
 }
 
@@ -1009,12 +1019,7 @@
 }
 
 void UnresolvedMethodPtrType::print(::std::ostream& os) {
-    //TODO: think about caching signature string as a separate field to avoid VM calls here
-    Class_Handle ch = (Class_Handle)enclosingClass->getVMTypeHandle();
-    const char* method_class = const_pool_get_method_class_name(ch, (unsigned short)cpIndex);
-    const char* method_name = const_pool_get_method_name(ch, (unsigned short)cpIndex);
-    const char* signature = const_pool_get_method_descriptor(ch, (unsigned short)cpIndex);
-    os << method_class << "::" << messageStr(method_name) << signature;
+    os<<signatureStr;
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h Thu Sep  6 08:24:09 2007
@@ -446,11 +446,11 @@
 class UnresolvedMethodPtrType : public MethodPtrType {
 public:
     UnresolvedMethodPtrType(ObjectType* _enclosingClass, uint32 _cpIndex, TypeManager&
tm, 
-        uint32 _nParams, Type** _paramTypes, Type* _returnType, 
+        uint32 _nParams, Type** _paramTypes, Type* _returnType,  const char* _signatureStr,
         bool isCompressed=false, ValueName obj=NULL) 
         : MethodPtrType(NULL, tm, isCompressed, obj), 
         enclosingClass(_enclosingClass), cpIndex(_cpIndex),
-        nParams(_nParams), paramTypes(_paramTypes), returnType(_returnType)
+        nParams(_nParams), paramTypes(_paramTypes), returnType(_returnType), signatureStr(_signatureStr)
     {}
 
     virtual ~UnresolvedMethodPtrType() {}
@@ -472,6 +472,7 @@
     uint32 nParams;
     Type** paramTypes;
     Type* returnType;
+    const char* signatureStr;
 };
 
 
@@ -723,6 +724,7 @@
     void          initArrayType(Type* elemType, bool isCompressed, void* arrayVMTypeHandle);
     Type*         getCommonType(Type* type1, Type *type2);
     ObjectType*   getCommonObjectType(ObjectType *o1, ObjectType *o2);
+    bool          isResolvedAndSubClassOf(Type* type1, Type *type2);
     bool          isSubClassOf(Type* type1, Type *type2) { return isSubTypeOf(type1, type2);
}
     bool          isSubTypeOf(Type* type1, Type* type2);
 
@@ -853,6 +855,7 @@
     virtual uint32 getNumParams() const = 0;
     virtual Type** getParamTypes() const = 0;
     virtual Type* getRetType() const = 0;
+    virtual const char* getSignatureString() const = 0;
 };
 } //namespace Jitrino 
 

Added: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp?rev=573295&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp Thu Sep  6 08:24:09 2007
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Intel, Mikhail Y. Fursov
+ *
+ */
+
+#include "VMMagic.h"
+#include <string.h>
+
+namespace Jitrino {
+
+bool VMMagicUtils::isVMMagicClass(const char* kname) {
+    static const char magicPackage[] = "org/vmmagic/unboxed/";
+    static const unsigned magicPackageLen = sizeof(magicPackage)-1;
+    bool res = false;
+    if (*kname=='L') {
+        res = !strncmp(kname+1, magicPackage, magicPackageLen);
+    } else {
+        res = !strncmp(kname, magicPackage, magicPackageLen);
+    }
+    return res;
+}
+
+}//namespace Jitirno

Propchange: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h?rev=573295&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h Thu Sep  6 08:24:09 2007
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Intel, Mikhail Y. Fursov
+ *
+ */
+
+#ifndef _VMMAGIC_JITRINO_H_
+#define _VMMAGIC_JITRINO_H_
+namespace Jitrino {
+
+class VMMagicUtils {
+public:
+    // checks of class nams is vmmagic class
+    // both typenames and descriptor names are supported
+    static bool isVMMagicClass(const char* kname);
+};
+
+} //namespace Jitirno
+#endif
+
+

Propchange: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/VMMagic.h
------------------------------------------------------------------------------
    svn:eol-style = native

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?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
Thu Sep  6 08:24:09 2007
@@ -32,25 +32,13 @@
 #include "Jitrino.h"
 #include "EMInterface.h"
 #include "inliner.h"
+#include "VMMagic.h"
 
 #include <assert.h>
 #include <stdio.h>
 
 namespace Jitrino {
 
-// magics support: both typenames and descriptor names are supported
-static bool isVMMagicClass(const char* kname) {
-    static const char magicPackage[] = "org/vmmagic/unboxed/";
-    static const unsigned magicPackageLen = sizeof(magicPackage)-1;
-    bool res = false;
-    if (*kname=='L') {
-        res = !strncmp(kname+1, magicPackage, magicPackageLen);
-    } else {
-        res = !strncmp(kname, magicPackage, magicPackageLen);
-    }
-    return res;
-}
-
 static bool matchType(const char* candidate, const char* typeName) {
     if (candidate[0]=='L') {
         size_t typeLen = strlen(typeName);
@@ -62,7 +50,7 @@
 }
 
 static Type* convertVMMagicType2HIR(TypeManager& tm, const char* name) {
-    assert(isVMMagicClass(name));
+    assert(VMMagicUtils::isVMMagicClass(name));
 
     if (matchType(name, "org/vmmagic/unboxed/Address")
         //TODO: ObjectReference must have a ManagedPointer/Object type
@@ -184,7 +172,7 @@
                     //TODO: numX->numY auto conversion not tested
                 }
             } 
-            if (isVMMagicClass(type->getName())) {
+            if (VMMagicUtils::isVMMagicClass(type->getName())) {
                 type = convertVMMagicType2HIR(typeManager, type);
             }
             arg = irBuilder.genArgDef(DefArgNoModifier,type);
@@ -731,7 +719,7 @@
         bool fieldValueInlined = false;
         Type* fieldType = field->getFieldType();
         assert(fieldType);
-        bool fieldIsMagic = isVMMagicClass(fieldType->getName());
+        bool fieldIsMagic = VMMagicUtils::isVMMagicClass(fieldType->getName());
         if (fieldIsMagic) {
             fieldType = convertVMMagicType2HIR(typeManager, fieldType);
         }
@@ -774,7 +762,7 @@
             linkingException(constPoolIndex, OPCODE_GETSTATIC);
         }
         const char* fieldTypeName = const_pool_get_field_descriptor(methodToCompile.getParentHandle(),
constPoolIndex);
-        bool fieldIsMagic = isVMMagicClass(fieldTypeName);
+        bool fieldIsMagic = VMMagicUtils::isVMMagicClass(fieldTypeName);
         Type* fieldType = fieldIsMagic ? convertVMMagicType2HIR(typeManager, fieldTypeName)

                                        : compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
         Opnd* res = irBuilder.genLdStaticWithResolve(fieldType, methodToCompile.getParentType()->asObjectType(),
constPoolIndex);
@@ -788,7 +776,7 @@
     if (field && field->isStatic()) {
         Type* fieldType = getFieldType(field,constPoolIndex);
         assert(fieldType);
-        bool fieldIsMagic = isVMMagicClass(fieldType->getName());
+        bool fieldIsMagic = VMMagicUtils::isVMMagicClass(fieldType->getName());
         if (fieldIsMagic) {
             fieldType = convertVMMagicType2HIR(typeManager, fieldType);
         }
@@ -799,7 +787,7 @@
             linkingException(constPoolIndex, OPCODE_PUTSTATIC);
         }
         const char* fieldTypeName = const_pool_get_field_descriptor(methodToCompile.getParentHandle(),
constPoolIndex);
-        bool fieldIsMagic = isVMMagicClass(fieldTypeName);
+        bool fieldIsMagic = VMMagicUtils::isVMMagicClass(fieldTypeName);
         Type* fieldType = fieldIsMagic ? convertVMMagicType2HIR(typeManager, fieldTypeName)

                                        : compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
         Opnd* value = popOpnd();
@@ -812,7 +800,7 @@
     FieldDesc *field = compilationInterface.getNonStaticField(methodToCompile.getParentHandle(),
constPoolIndex, false);
     if (field && !field->isStatic()) {
         Type* fieldType = getFieldType(field, constPoolIndex);
-        if (isVMMagicClass(fieldType->getName())) {
+        if (VMMagicUtils::isVMMagicClass(fieldType->getName())) {
             fieldType = convertVMMagicType2HIR(typeManager, fieldType);
         }
         pushOpnd(irBuilder.genLdField(fieldType,popOpnd(),field));
@@ -822,7 +810,7 @@
             linkingException(constPoolIndex, OPCODE_GETFIELD);
         }
         Type* fieldType = compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
-        if (isVMMagicClass(fieldType->getName())) {
+        if (VMMagicUtils::isVMMagicClass(fieldType->getName())) {
             fieldType = convertVMMagicType2HIR(typeManager, fieldType);
         }
         Opnd* base = popOpnd();
@@ -1445,15 +1433,22 @@
     return srcOpnds;
 }
 
+//Helper class used to initialize unresolved method ptrs
 class JavaMethodSignature : public MethodSignature {
 public:
-    JavaMethodSignature(MemoryManager& mm, CompilationInterface ci, Class_Handle cl,
const char* sigStr){
-        nParams = JavaLabelPrepass::getNumArgsBySignature(sigStr);
+    JavaMethodSignature(MemoryManager& mm, CompilationInterface ci, bool instanceMethod,
Class_Handle cl, const char* sigStr){
+        signatureStr = sigStr;
+        nParams = JavaLabelPrepass::getNumArgsBySignature(sigStr) + (instanceMethod ? 1 :
0);
         const char* sigSuffix = sigStr;
         if (nParams > 0) {
-            sigSuffix++;
             paramTypes = new (mm) Type*[nParams];
-            for (uint32 i=0;i<nParams;i++) {
+            uint32 i = 0;
+            if (instanceMethod) {
+                paramTypes[0] = ci.getTypeManager().getUnresolvedObjectType();
+                i++;
+            }
+            sigSuffix++;
+            for (; i < nParams; i++) {
                 uint32 len = 0;
                 Type* type = JavaLabelPrepass::getTypeByDescriptorString(ci, cl, sigSuffix,
len);
                 assert(type!=NULL);
@@ -1470,10 +1465,12 @@
     virtual uint32 getNumParams() const { return nParams;}
     virtual Type** getParamTypes() const { return paramTypes;}
     virtual Type* getRetType() const {return retType;}
+    virtual const char* getSignatureString() const {return signatureStr;}
 private:
     uint32 nParams;
     Type** paramTypes;
     Type* retType;
+    const char* signatureStr;
 
 };
 
@@ -1486,9 +1483,9 @@
     assert(enclosingClass!=NULL);
     const char* methodSig = methodSignatureString(cpIndex);
     assert(methodSig);
-    JavaMethodSignature* sig = new (memManager) JavaMethodSignature(irBuilder.getIRManager()->getMemoryManager(),
-        compilationInterface, (Class_Handle)enclosingClass->getVMTypeHandle(), methodSig);
-    uint32 numArgs = sig->getNumParams() + (isStatic ? 0 : 1); 
+    JavaMethodSignature* sig = new (memManager) JavaMethodSignature(irBuilder.getIRManager()->getMemoryManager(),

+        compilationInterface, !isStatic, (Class_Handle)enclosingClass->getVMTypeHandle(),
methodSig);
+    uint32 numArgs = sig->getNumParams();
     assert(numArgs > 0 || isStatic);
 
     Opnd** args = popArgs(numArgs);
@@ -1498,7 +1495,7 @@
     if (bc != OPCODE_INVOKEINTERFACE) {
         const char* kname = const_pool_get_method_class_name(methodToCompile.getParentHandle(),
cpIndex);
         const char* mname = const_pool_get_method_name(methodToCompile.getParentHandle(),
cpIndex);
-        if (isVMMagicClass(kname)) {
+        if (VMMagicUtils::isVMMagicClass(kname)) {
             assert(bc == OPCODE_INVOKESTATIC || bc == OPCODE_INVOKEVIRTUAL);
             UNUSED bool res = genVMMagic(mname, numArgs, args, returnType);    
             assert(res);
@@ -1537,7 +1534,7 @@
     Opnd** srcOpnds = popArgs(numArgs);
     Type* returnType = methodDesc->getReturnType();
 
-    if (isVMMagicClass(methodDesc->getParentType()->getName())) {
+    if (VMMagicUtils::isVMMagicClass(methodDesc->getParentType()->getName())) {
         genVMMagic(methodDesc->getName(), numArgs, srcOpnds, returnType);
         return;
     }
@@ -1914,7 +1911,7 @@
 void 
 JavaByteCodeTranslator::genLdVar(uint32 varIndex,JavaLabelPrepass::JavaVarType javaType)
{
     Opnd *var = getVarOpndLdVar(javaType,varIndex);
-    if (isVMMagicClass(var->getType()->getName())) {
+    if (VMMagicUtils::isVMMagicClass(var->getType()->getName())) {
         var->setType(convertVMMagicType2HIR(typeManager, var->getType()));
     }
     Opnd *opnd;
@@ -2314,7 +2311,7 @@
 
     const char* kname = methodDesc->getParentType()->getName(); 
     const char* mname = methodDesc->getName(); 
-    if (isVMMagicClass(kname)) {
+    if (VMMagicUtils::isVMMagicClass(kname)) {
         UNUSED bool res = genVMMagic(mname, numArgs, srcOpnds, returnType);    
         assert(res);
         return;
@@ -2325,7 +2322,7 @@
     }
     Opnd *tauNullChecked = irBuilder.genTauSafe(); // always safe, is a static method call
     Type* resType = returnType;
-    if (isVMMagicClass(resType->getName())) {
+    if (VMMagicUtils::isVMMagicClass(resType->getName())) {
         resType = convertVMMagicType2HIR(typeManager, resType);
     }
     dst = irBuilder.genDirectCall(methodDesc, 
@@ -3535,7 +3532,7 @@
 
 
 bool JavaByteCodeTranslator::genVMHelper(const char* mname, uint32 numArgs, Opnd **srcOpnds,
Type *returnType) {
-    Type* resType = isVMMagicClass(returnType->getName()) ? convertVMMagicType2HIR(typeManager,
returnType) : returnType;
+    Type* resType = VMMagicUtils::isVMMagicClass(returnType->getName()) ? convertVMMagicType2HIR(typeManager,
returnType) : returnType;
 
     if (!strcmp(mname,"getTlsBaseAddress")) {
         assert(numArgs == 0);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaLabelPrepass.cpp Thu Sep
 6 08:24:09 2007
@@ -1411,20 +1411,12 @@
         len++;
     }
 
-    bool arrayIsWrapped = false;
     TypeManager& typeManager = ci.getTypeManager();
     switch( *descriptorString ) 
     {
     case 'L': 
         {
-            //TODO: check by name if type is already resolved!!!
-            if (!typeManager.isLazyResolutionMode()) {
-                resType = typeManager.getUnresolvedObjectType();
-            } else {
-                resType = ci.getTypeFromDescriptor(enclClass, descriptorString);
-                //in lazy resolution mode retType is already valid array type
-                arrayIsWrapped = true;
-            }
+            resType = ci.getTypeFromDescriptor(enclClass, descriptorString);
             while( *(++descriptorString) != ';' ) {
                 len++;
                 assert(*descriptorString);
@@ -1469,7 +1461,7 @@
     }
     assert(resType);
 
-    if (!arrayIsWrapped && arrayDim > 0) {
+    if (arrayDim > 0) {
         for (;arrayDim > 0; arrayDim--) {
             resType = typeManager.getArrayType(resType, false);
         }
@@ -1879,7 +1871,7 @@
         if (type) prepass.getVisited()->setBit(offset,false);
         return;
     }
-
+    
     Type* new_type = typeManager.getCommonType(in_type,type);
     if (new_type != NULL) {
         if (vars) {

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/vm/drl/DrlVMInterface.cpp Thu Sep  6 08:24:09
2007
@@ -34,6 +34,7 @@
 #include "JITInstanceContext.h"
 #include "PlatformDependant.h"
 #include "mkernel.h"
+#include "VMMagic.h"
 
 /**
 * @brief A lock used to protect method's data in multi-threaded compilation.
@@ -449,7 +450,12 @@
     } else if (type_info_is_reference(typeHandle)) {
         bool lazy = typeManager.isLazyResolutionMode();
         if (lazy && !type_info_is_resolved(typeHandle)) {
-            return typeManager.getUnresolvedObjectType();
+            const char* kname = type_info_get_type_name(typeHandle);
+            assert(kname!=NULL);
+            bool forceResolve = VMMagicUtils::isVMMagicClass(kname);
+            if (!forceResolve) {
+                return typeManager.getUnresolvedObjectType();
+            }
         }
         Class_Handle classHandle = type_info_get_class_no_exn(typeHandle);
         if (!classHandle) {
@@ -838,17 +844,19 @@
 NamedType* CompilationInterface::getNamedType(Class_Handle enclClass, uint32 cpIndex, ResolveNewCheck
checkNew) {
     Class_Handle ch = NULL;
     if (typeManager.isLazyResolutionMode() && !class_is_cp_entry_resolved(compileHandle,
enclClass, cpIndex)) {
-        NamedType * res = getUnresolvedType(typeManager, enclClass, cpIndex);
-        return res; 
-    } else {
-        if (checkNew == ResolveNewCheck_DoCheck) {
-            ch = resolve_class_new(compileHandle,enclClass,cpIndex);
-        } else {
-            ch = resolve_class(compileHandle,enclClass,cpIndex);
-        }
-        if (ch == NULL) {
-            return typeManager.getUnresolvedObjectType();
+        const char* className = const_pool_get_class_name(enclClass, cpIndex);
+        bool forceResolve = VMMagicUtils::isVMMagicClass(className);
+        if (!forceResolve) {
+            return getUnresolvedType(typeManager, enclClass, cpIndex);
         }
+    }
+    if (checkNew == ResolveNewCheck_DoCheck) {
+        ch = resolve_class_new(compileHandle,enclClass,cpIndex);
+    } else {
+        ch = resolve_class(compileHandle,enclClass,cpIndex);
+    }
+    if (ch == NULL) {
+        return typeManager.getUnresolvedObjectType();
     }
     if (class_is_primitive(ch)) {
         return typeManager.getValueType(ch);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?rev=573295&r1=573294&r2=573295&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Thu Sep  6 08:24:09
2007
@@ -2063,6 +2063,12 @@
 } //type_info_is_primitive
 
 
+const char* type_info_get_type_name(Type_Info_Handle tih) {
+    TypeDesc* td = (TypeDesc*)tih;
+    assert(td);
+    return td->get_type_name()->bytes;
+}
+
 Class_Handle type_info_get_class(Type_Info_Handle tih)
 {
     TypeDesc* td = (TypeDesc*)tih;



Mime
View raw message