harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r541293 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src: jet/cg.cpp jet/cg.h jet/cg_fld_arr.cpp jet/magics.cpp translator/java/JavaByteCodeTranslator.cpp
Date Thu, 24 May 2007 12:56:40 GMT
Author: varlax
Date: Thu May 24 05:56:39 2007
New Revision: 541293

URL: http://svn.apache.org/viewvc?view=rev&rev=541293
Log:
Applied HARMONY-3784 [drlvm][jit][jet] Incorrect support of vmmagic types and object fields
in JET compiler

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/magics.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp?view=diff&rev=541293&r1=541292&r2=541293
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.cpp Thu May 24 05:56:39 2007
@@ -49,12 +49,12 @@
 const CallSig ci_helper_io(CCONV_HELPERS, i32, jobj);
 const CallSig ci_helper_linkerr(CCONV_HELPERS, jobj, i32, i32);
 
-void CodeGen::do_mov(const Val& dst_s, const Val& src_s)
+void CodeGen::do_mov(const Val& dst_s, const Val& src_s, bool skipTypeCheck)
 {
     assert(!dst_s.is_imm());
     jtype sjt = jtmov(src_s.jt());
     jtype djt = jtmov(dst_s.jt());
-    assert(sjt == djt);
+    assert(skipTypeCheck || sjt == djt);
     
     if (dst_s.is_mem() && src_s.is_mem()) {
         // Need to allocate a reg

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h?view=diff&rev=541293&r1=541292&r2=541293
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg.h Thu May 24 05:56:39 2007
@@ -528,7 +528,7 @@
      * @param src - source operand.
      * @param dst - destination operand.
      */
-    void    do_mov(const Val& dst, const Val& src);
+    void    do_mov(const Val& dst, const Val& src, bool skipTypeCheck=false);
     /**
      * @brief Returns a stack item at the given depth.
      * 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp?view=diff&rev=541293&r1=541292&r2=541293
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp Thu May 24 05:56:39 2007
@@ -247,8 +247,8 @@
 
     jtype jt = to_jtype(class_get_cp_field_type(fieldOp.enclClass, fieldOp.cpIndex));
     
-    const char* fieldClassName = const_pool_get_field_class_name(fieldOp.enclClass, fieldOp.cpIndex);
-    bool fieldIsMagic = is_magic_class(fieldClassName);
+    const char* fieldDescName = const_pool_get_field_descriptor(fieldOp.enclClass, fieldOp.cpIndex);
+    bool fieldIsMagic = is_magic_class(fieldDescName);
     if (fieldIsMagic) {
         jt = iplatf;
     }
@@ -391,7 +391,7 @@
     else {
         vunref(jt, where);
         Val& val = vstack(0, vis_mem(0));
-        do_mov(where, val);
+        do_mov(where, val, fieldIsMagic);
         if (is_big(jt)) {
             Opnd where_hi(jt, where.base(), where.disp()+4, 
                               where.index(), where.scale());

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/magics.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/magics.cpp?view=diff&rev=541293&r1=541292&r2=541293
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/magics.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/magics.cpp Thu May 24 05:56:39 2007
@@ -43,6 +43,9 @@
     static const unsigned nameLen = sizeof(unboxedName)-1;
 
     assert(kname!=NULL);
+    if (*kname=='L') {
+        return !strncmp(kname+1, unboxedName, nameLen);
+    }
     return !strncmp(kname, unboxedName, nameLen);
 }
 

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=541293&r1=541292&r2=541293
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
Thu May 24 05:56:39 2007
@@ -39,39 +39,47 @@
 
 namespace Jitrino {
 
-// magics support    
-static bool isVMMagicClass(const char* name) {
+// 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 =  !strncmp(name, magicPackage, magicPackageLen);
+    bool res = false;
+    if (*kname=='L') {
+        res = !strncmp(kname+1, magicPackage, magicPackageLen);
+    } else {
+        res = !strncmp(kname, magicPackage, magicPackageLen);
+    }
     return res;
 }
 
-Type* convertVMMagicType2HIR(TypeManager& tm, Type* type) {
-    if (!type->isObject() || !type->isNamedType() || type->isSystemObject()) {
-        return type;
+static bool matchType(const char* candidate, const char* typeName) {
+    if (candidate[0]=='L') {
+        size_t typeLen = strlen(typeName);
+        size_t candLen = strlen(candidate);
+        bool res = typeLen+2 == candLen && !strncmp(typeName, candidate+1, typeLen);
+        return res;
     }
+    return !strcmp(typeName, candidate);
+}
 
-    const char* name = type->getName();    
-
+static Type* convertVMMagicType2HIR(TypeManager& tm, const char* name) {
     assert(isVMMagicClass(name));
 
-    if (!strcmp(name, "org/vmmagic/unboxed/Address") 
+    if (matchType(name, "org/vmmagic/unboxed/Address")
         //TODO: ObjectReference must have a ManagedPointer/Object type
-        || !strcmp(name, "org/vmmagic/unboxed/ObjectReference")) 
+        || matchType(name, "org/vmmagic/unboxed/ObjectReference"))
     {
         return tm.getUnmanagedPtrType(tm.getInt8Type());
-    } else if (!strcmp(name, "org/vmmagic/unboxed/Word") 
-        || !strcmp(name, "org/vmmagic/unboxed/Offset")
-        || !strcmp(name, "org/vmmagic/unboxed/Extent")) 
+    } else if (matchType(name, "org/vmmagic/unboxed/Word")
+        || matchType(name, "org/vmmagic/unboxed/Offset")
+        || matchType(name, "org/vmmagic/unboxed/Extent"))
     {
         return tm.getUIntPtrType();
-    } else if (!strcmp(name, "org/vmmagic/unboxed/WordArray")
-        || !strcmp(name, "org/vmmagic/unboxed/OffsetArray")
-        || !strcmp(name, "org/vmmagic/unboxed/ExtentArray") 
-        || !strcmp(name, "org/vmmagic/unboxed/AddressArray") 
-        || !strcmp(name, "org/vmmagic/unboxed/ObjectReferenceArray")) 
+    } else if (matchType(name, "org/vmmagic/unboxed/WordArray")
+        || matchType(name, "org/vmmagic/unboxed/OffsetArray")
+        || matchType(name, "org/vmmagic/unboxed/ExtentArray") 
+        || matchType(name, "org/vmmagic/unboxed/AddressArray") 
+        || matchType(name, "org/vmmagic/unboxed/ObjectReferenceArray")) 
     {
 #ifdef _EM64T_
         return tm.getArrayType(tm.getInt64Type(), false);
@@ -83,9 +91,17 @@
     return NULL;
 }
 
+static Type* convertVMMagicType2HIR(TypeManager& tm, Type* type) {
+    if (!type->isObject() || !type->isNamedType() || type->isSystemObject()) {
+        return type;
+    }
+    const char* name = type->getName();    
+    return convertVMMagicType2HIR(tm, name);
+}
+
 //vm helpers support
 
-bool isVMHelperClass(const char* name) {
+static bool isVMHelperClass(const char* name) {
 #ifdef _IPF_
     return false;//natives are not tested on IPF.
 #else
@@ -729,10 +745,15 @@
     FieldDesc *field = compilationInterface.getStaticField(methodToCompile.getParentHandle(),
constPoolIndex, false);
     if (field && field->isStatic()) {
         bool fieldValueInlined = false;
+        Type* fieldType = field->getFieldType();
+        assert(fieldType);
+        bool fieldIsMagic = isVMMagicClass(fieldType->getName());
+        if (fieldIsMagic) {
+            fieldType = convertVMMagicType2HIR(typeManager, fieldType);
+        }
         if (field->isInitOnly() && !field->getParentType()->needsInitialization())
{
             //the final static field of the initialized class
-            Type* fieldType = field->getFieldType();
-            if (field->getFieldType()->isNumeric() || field->getFieldType()->isBoolean())
{
+            if (field->getFieldType()->isNumeric() || field->getFieldType()->isBoolean()
|| fieldIsMagic) {
                 Opnd* constVal = NULL;
                 void* fieldAddr = field->getAddress();
                 switch(fieldType->tag) {
@@ -744,6 +765,14 @@
                     case Type::Single:  constVal=irBuilder.genLdConstant(*(float*)fieldAddr);break;
                     case Type::Double:  constVal=irBuilder.genLdConstant(*(double*)fieldAddr);break;
                     case Type::Boolean: constVal=irBuilder.genLdConstant(*(bool*)fieldAddr);break;
+                    case Type::UnmanagedPtr:  assert(fieldIsMagic); 
+#ifdef _IA32_
+                            constVal=irBuilder.genLdConstant(*(int32*)fieldAddr);break;
+#else
+                            assert(sizeof(void*)==8);
+                            constVal=irBuilder.genLdConstant(*(int64*)fieldAddr);break;
+#endif
+                            break;
                     default: assert(0); //??
                 }
                 if (constVal != NULL) {
@@ -753,16 +782,14 @@
             }
         } 
         if (!fieldValueInlined){
-            Type* fieldType = getFieldType(field,constPoolIndex);
-            assert(fieldType);
-            if (isVMMagicClass(fieldType->getName())) {
-                fieldType = convertVMMagicType2HIR(typeManager, fieldType);
-            }
-            pushOpnd(irBuilder.genLdStatic(fieldType,field));
+            pushOpnd(irBuilder.genLdStatic(fieldType, field));
         }
     } else if (typeManager.isLazyResolutionMode()) {
-        Type* type = compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
-        Opnd* res = irBuilder.genLdStaticWithResolve(type, methodToCompile.getParentType()->asObjectType(),
constPoolIndex);
+        const char* fieldTypeName = const_pool_get_field_descriptor(methodToCompile.getParentHandle(),
constPoolIndex);
+        bool fieldIsMagic = isVMMagicClass(fieldTypeName);
+        Type* fieldType = fieldIsMagic ? convertVMMagicType2HIR(typeManager, fieldTypeName)

+                                       : compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
+        Opnd* res = irBuilder.genLdStaticWithResolve(fieldType, methodToCompile.getParentType()->asObjectType(),
constPoolIndex);
         pushOpnd(res);
     } else {
         // generate helper call for throwing respective exception
@@ -779,11 +806,18 @@
     if (field && field->isStatic()) {
         Type* fieldType = getFieldType(field,constPoolIndex);
         assert(fieldType);
+        bool fieldIsMagic = isVMMagicClass(fieldType->getName());
+        if (fieldIsMagic) {
+            fieldType = convertVMMagicType2HIR(typeManager, fieldType);
+        }
         irBuilder.genStStatic(fieldType,field,popOpnd());
     } else  if (typeManager.isLazyResolutionMode()) {
-        Type* type = compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
+        const char* fieldTypeName = const_pool_get_field_descriptor(methodToCompile.getParentHandle(),
constPoolIndex);
+        bool fieldIsMagic = isVMMagicClass(fieldTypeName);
+        Type* fieldType = fieldIsMagic ? convertVMMagicType2HIR(typeManager, fieldTypeName)

+                                       : compilationInterface.getFieldType(methodToCompile.getParentHandle(),
constPoolIndex);
         Opnd* value = popOpnd();
-        irBuilder.genStStaticWithResolve(type, methodToCompile.getParentType()->asObjectType(),
constPoolIndex, value);
+        irBuilder.genStStaticWithResolve(fieldType, methodToCompile.getParentType()->asObjectType(),
constPoolIndex, value);
     } else {
         // generate helper call for throwing respective exception
         linkingException(constPoolIndex, OPCODE_PUTSTATIC);



Mime
View raw message