You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2006/12/19 11:00:41 UTC

svn commit: r488608 - /harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp

Author: varlax
Date: Tue Dec 19 02:00:40 2006
New Revision: 488608

URL: http://svn.apache.org/viewvc?view=rev&rev=488608
Log:
Applied HARMONY-2542 [drlvm][jit][opt] instanceOf helper call into VTable comparison if targetType is final.
Tested on SUSE9

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp

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=488608&r1=488607&r2=488608
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp Tue Dec 19 02:00:40 2006
@@ -2272,7 +2272,53 @@
         return 3;
     }
     jitrino_assert(compilationInterface,type);
-    pushOpnd(irBuilder.genInstanceOf(popOpnd(),type));
+
+    Opnd* src = popOpnd();
+    Type* srcType = src->getType();
+    Opnd* res = NULL;
+
+
+    // if target type is final just compare VTables
+    // This can not be done by Simplifier as it can not generate branches
+    // (srcType->isExactType() case will be simplified by Simplifier)
+    if( !srcType->isInterface() &&
+        !Simplifier::isExactType(src) &&
+        ((ObjectType*)type)->isFinalClass() )
+    {
+        Type* intPtrType = typeManager.getIntPtrType();
+
+        LabelInst* ObjIsNullLabel = irBuilder.createLabel();
+        LabelInst* Exit = irBuilder.createLabel();
+        VarOpnd* resVar = irBuilder.genVarDef(intPtrType, false);
+
+        newFallthroughBlock();
+
+        Opnd * zero = irBuilder.genLdConstant((int32)0);
+        irBuilder.genBranch(Type::IntPtr,Cmp_EQ,ObjIsNullLabel,zero,src);        
+
+        // src is not null here
+        newFallthroughBlock();
+        Opnd* srcIsSafe = irBuilder.genTauSafe();
+        Opnd* dynamicVTable = irBuilder.genTauLdVTable(src, srcIsSafe, srcType);
+        Opnd* staticVTable = irBuilder.genGetVTable((ObjectType*) type);
+        irBuilder.genStVar(resVar, irBuilder.genCmp(intPtrType,Type::IntPtr,Cmp_EQ,staticVTable,dynamicVTable));
+        irBuilder.genJump(Exit);
+
+        // src is null, instanceOf returns 0
+        irBuilder.genLabel(ObjIsNullLabel);
+        cfgBuilder.genBlockAfterCurrent(ObjIsNullLabel);
+        irBuilder.genStVar(resVar, zero);
+        irBuilder.genJump(Exit);
+
+        irBuilder.genLabel(Exit);
+        cfgBuilder.genBlockAfterCurrent(Exit);
+        res = irBuilder.genLdVar(intPtrType,resVar);
+    } else {
+        res = irBuilder.genInstanceOf(src,type);
+    }
+
+    assert(res);
+    pushOpnd(res);
     return 3;
 }