harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r512149 - in /harmony/enhanced/drlvm/trunk: src/test/microbenchmark/harmony-2247/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/translator/java/
Date Tue, 27 Feb 2007 06:20:05 GMT
Author: varlax
Date: Mon Feb 26 22:20:04 2007
New Revision: 512149

URL: http://svn.apache.org/viewvc?view=rev&rev=512149
Log:
Applied HARMONY-3063 [drlvm][jit] ArrayCopyRepMove does not work on EM64T

Modified:
    harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp

Modified: harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java?view=diff&rev=512149&r1=512148&r2=512149
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java (original)
+++ harmony/enhanced/drlvm/trunk/src/test/microbenchmark/harmony-2247/ArraycopyTest.java Mon
Feb 26 22:20:04 2007
@@ -6,148 +6,64 @@
 
     public static int length = 100000000;
 
-    public static void main(String[] args) {
+    public static void copy(int[] src, int srcPos, int[] dst, int dstPos,
+            int length) {
+
+        System.arraycopy(src, srcPos, dst, dstPos, length);
+    }
 
+    public static void main(String[] args) {
         int arrA[] = new int[length];
         int arrB[] = new int[length];
 
-        for (int i=0;i<length;i++) {
+        for (int i = 0; i < length; i++) {
             arrA[i] = i;
         }
-// this part is for debugging
-/*
-        printArr(arrA,0,10, "arrA initial");
-        printArr(arrB,0,10, "arrB initial");
-        
-        System.arraycopy(arrA,1,arrB,3,5);
-        printArr(arrB,0,10, "arrB changed");
-        
-        System.arraycopy(arrB,3,arrB,8,5);
-        printArr(arrB,0,10, "arrB self forward");
-        
-        System.arraycopy(arrB,4,arrB,0,3);
-        printArr(arrB,0,10, "arrB self backward");
-*/        
-        System.out.println("");
-        System.out.println("START!");
-
-        long start = System.currentTimeMillis();
-
-        System.arraycopy(arrA,1,arrB,0,length-1);
-        System.arraycopy(arrA,1,arrB,0,length-1);
-        System.arraycopy(arrA,1,arrB,0,length-1);
-        System.out.print(". ");
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.out.print(". ");
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.out.print(". ");
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.out.print(". ");
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.out.print(". ");
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.out.print(". ");
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.out.print(". ");
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.out.print(". ");
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.out.print(". ");
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.out.print(". ");
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.out.print(". ");
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.out.print(". ");
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.out.print(". ");
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.out.print(". ");
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.out.print(". ");
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.out.print(". ");
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.out.print(". ");
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.out.print(". ");
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.out.print(". ");
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.arraycopy(arrA,2,arrB,0,length-2);
-        System.out.print(". ");
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.arraycopy(arrA,3,arrB,0,length-3);
-        System.out.print(". ");
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.arraycopy(arrA,4,arrB,0,length-4);
-        System.out.print(". ");
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.arraycopy(arrA,5,arrB,0,length-5);
-        System.out.print(". ");
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.arraycopy(arrA,6,arrB,0,length-6);
-        System.out.println(". ");
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
-        System.arraycopy(arrA,7,arrB,0,length-7);
+        // this part is for debugging
+        /*
+        * printArr(arrA,0,10, "arrA initial"); printArr(arrB,0,10, "arrB
+        * initial");
+        * 
+        * System.arraycopy(arrA,1,arrB,3,5); printArr(arrB,0,10, "arrB
+        * changed");
+        * 
+        * System.arraycopy(arrB,3,arrB,8,5); printArr(arrB,0,10, "arrB self
+        * forward");
+        * 
+        * System.arraycopy(arrB,4,arrB,0,3); printArr(arrB,0,10, "arrB self
+        * backward");
+        */
+
+        if (args.length == 0) {
+            args = new String[]{"100"};
+        }
+        for (String s : args) {
+            int lim = Integer.parseInt(s);
+
+            System.out.println("");
+            System.out.println("START!");
+
+            long start = System.currentTimeMillis();
 
-        long end = System.currentTimeMillis();
+            for (int i = 0; i < lim; i++) {
+                copy(arrA, i, arrB, i + 2, length - i - 2);
+                // System.out.print(". ");
+            }
 
-        System.out.println("FINISHED");
+            long end = System.currentTimeMillis();
 
-        System.out.println("duration = "+(end - start)+" millis");
+            System.out.println("FINISHED");
 
+            System.out.println("duration = " + (end - start) + " millis");
+        }
     }
 
     public static void printArr(int[] arr, int pos, int count, String prefix) {
 
         String out = prefix + " : ";
-        for(int i=pos;i < pos+count; i++) {
+        for (int i = pos; i < pos + count; i++) {
             out = out + arr[i] + " ";
         }
         System.out.println(out);
     }
 }
-

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp?view=diff&rev=512149&r1=512148&r2=512149
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Mon Feb
26 22:20:04 2007
@@ -1752,9 +1752,9 @@
                         } else if (inst->getMnemonic() == Mnemonic_POP) {
                             stackDepth-=getByteSize(inst->getOpnd(it)->getSize());
                         } else if (inst->getMnemonic() == Mnemonic_PUSHFD) {
-                            stackDepth+=4;
+                            stackDepth+=sizeof(POINTER_SIZE_INT);
                         } else if (inst->getMnemonic() == Mnemonic_POPFD) {
-                            stackDepth-=4;
+                            stackDepth-=sizeof(POINTER_SIZE_INT);
                         } else if (inst->getMnemonic() == Mnemonic_CALL && ((CallInst
*)inst)->getCallingConventionClient().getCallingConvention()->calleeRestoresStack())
{
                             stackDepth -= ((CallInst *)inst)->getArgStackDepth();
                         }

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=512149&r1=512148&r2=512149
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
Mon Feb 26 22:20:04 2007
@@ -1817,9 +1817,6 @@
     Type * elemType=arrayType->getElementType();
     Type * dstType=irManager.getManagedPtrType(elemType);
 
-    uint32 elemSize = getByteSize(irManager.getTypeSize(elemType));
-
-    
 #ifdef _EM64T_
     Type * indexType = typeManager.getInt64Type();
     Type * offType = typeManager.getInt64Type();
@@ -1828,11 +1825,32 @@
     Type * offType = typeManager.getInt32Type();
 #endif
         
+    uint32 elemSize = 0;
+    if (elemType->isReference()
+        && Type::isCompressedReference(elemType->tag, compilationInterface) 
+        && !elemType->isCompressedReference()) {
+        elemSize = 4;
+    } else {
+        elemSize = getByteSize(irManager.getTypeSize(elemType));
+    }
+    Opnd * elemSizeOpnd  = irManager.newImmOpnd(indexType, elemSize);
+    
     Opnd * indexOpnd = (Opnd *)index;
     indexOpnd = convert(indexOpnd, indexType);
-    
-    Opnd * addr = irManager.newMemOpnd(dstType,(Opnd*)array, (Opnd*)index,
-                                       irManager.newImmOpnd(indexType, elemSize),
+
+    if ( indexOpnd->isPlacedIn(OpndKind_Imm) ) {
+        // we need to put index operand on a register to satisfy LEA constraint
+        int64 immValue = indexOpnd->getImmValue();
+        if (immValue == 0) {
+            indexOpnd = NULL;
+            elemSizeOpnd = NULL;
+        } else {
+            Opnd * indexReg = irManager.newOpnd(indexType);
+            copyOpnd(indexReg,indexOpnd);
+            indexOpnd = indexReg;
+        }
+    }    
+    Opnd * addr = irManager.newMemOpnd(dstType,(Opnd*)array, indexOpnd, elemSizeOpnd,
                                        irManager.newImmOpnd(offType, arrayType->getArrayElemOffset())
                                        );
     Opnd * dst = irManager.newOpnd(dstType);
@@ -2545,7 +2563,7 @@
 #endif
 
     // prepare counter
-    Type* counterType = typeManager.getInt32Type();
+    Type* counterType = typeManager.getIntPtrType();
     Opnd* counter = irManager.newRegOpnd(counterType,counterRegName);
     copyOpnd(counter,(Opnd*)args[4]);
 

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=512149&r1=512148&r2=512149
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp
Mon Feb 26 22:20:04 2007
@@ -2890,12 +2890,6 @@
                                             uint32       numArgs,
                                             Opnd **      srcOpnds) {
 
-#ifdef _EM64T_
-    // FIXME: this was not tested (and does not work) on EM64T.
-    if (true) {
-        return false;
-    }
-#endif
     if( !methodIsArraycopy(methodDesc) ||
         !arraycopyOptimizable(methodDesc,numArgs,srcOpnds) )
     {
@@ -2957,48 +2951,52 @@
     LabelInst * reverseCopying = irBuilder.createLabel();
     LabelInst * boundsException = irBuilder.createLabel();
     LabelInst * Exit = irBuilder.createLabel();
+
     Type * intType = typeManager.getInt32Type();
+    Type::Tag intTag = intType->tag;
     Type * voidType = typeManager.getVoidType();
 
     newFallthroughBlock();
     Opnd * zero = irBuilder.genLdConstant((int32)0);
-    irBuilder.genBranch(Type::Int32,Cmp_GT,boundsException,zero,srcPos);        
+    Opnd * minusone = irBuilder.genLdConstant((int32)-1);
+
+    irBuilder.genBranch(intTag,Cmp_GT,boundsException,zero,srcPos);        
 
     newFallthroughBlock();
-    irBuilder.genBranch(Type::Int32,Cmp_GT,boundsException,zero,dstPos);
+    irBuilder.genBranch(intTag,Cmp_GT,boundsException,zero,dstPos);
 
     newFallthroughBlock();
-    irBuilder.genBranch(Type::Int32,Cmp_GT,boundsException,zero,len);
+    irBuilder.genBranch(intTag,Cmp_GT,boundsException,zero,len);
 
     Modifier mod = Modifier(Overflow_None)|Modifier(Exception_Never)|Modifier(Strict_No);
 
     newFallthroughBlock();   
-    Opnd * srcLen = irBuilder.genArrayLen(intType,Type::Int32,src);
+    Opnd * srcLen = irBuilder.genArrayLen(intType,intTag,src);
     Opnd * srcEnd = irBuilder.genAdd(intType,mod,srcPos,len);
-    irBuilder.genBranch(Type::Int32,Cmp_GT,boundsException,srcEnd,srcLen);
+    irBuilder.genBranch(intTag,Cmp_GT,boundsException,srcEnd,srcLen);
     
     newFallthroughBlock();
     Opnd * dstEnd = irBuilder.genAdd(intType,mod,dstPos,len);
-    Opnd * dstLen = irBuilder.genArrayLen(intType,Type::Int32,dst);
-    irBuilder.genBranch(Type::Int32,Cmp_GT,boundsException,dstEnd,dstLen);
+    Opnd * dstLen = irBuilder.genArrayLen(intType,intTag,dst);
+    irBuilder.genBranch(intTag,Cmp_GT,boundsException,dstEnd,dstLen);
 
     newFallthroughBlock();
 
     // The case of same arrays and same positions
-    Opnd * diff = irBuilder.genCmp3(intType,Type::Int32,Cmp_GT,dstPos,srcPos);
+    Opnd * diff = irBuilder.genCmp3(intType,intTag,Cmp_GT,dstPos,srcPos);
     Opnd * sameArrays = irBuilder.genCmp(intType,Type::IntPtr,Cmp_EQ,src,dst);
-    Opnd * zeroDiff = irBuilder.genCmp(intType,Type::Int32,Cmp_EQ,diff,zero);
+    Opnd * zeroDiff = irBuilder.genCmp(intType,intTag,Cmp_EQ,diff,zero);
     Opnd * nothingToCopy = irBuilder.genAnd(intType,sameArrays,zeroDiff);
-    irBuilder.genBranch(Type::Int32,Cmp_GT,Exit,nothingToCopy,zero);
+    irBuilder.genBranch(intTag,Cmp_GT,Exit,nothingToCopy,zero);
 
     newFallthroughBlock();
 
     Opnd* tauTypesChecked = irBuilder.genTauSafe();
 
     // Choosing direction
-    Opnd * dstIsGreater = irBuilder.genCmp(intType,Type::Int32,Cmp_GT,diff,zero);
+    Opnd * dstIsGreater = irBuilder.genCmp(intType,intTag,Cmp_GT,diff,zero);
     Opnd * reverseCopy = irBuilder.genAnd(intType,sameArrays,dstIsGreater);
-    irBuilder.genBranch(Type::Int32,Cmp_GT,reverseCopying,reverseCopy,zero);
+    irBuilder.genBranch(intTag,Cmp_GT,reverseCopying,reverseCopy,zero);
 
     newFallthroughBlock();
 
@@ -3014,7 +3012,6 @@
     cfgBuilder.genBlockAfterCurrent(reverseCopying);
     {   // Reverse Copying
 
-    Opnd* minusone = irBuilder.genLdConstant((int32)-1);
     Opnd* lastSrcIdx = irBuilder.genAdd(srcPosType,mod,srcEnd,minusone);
     Opnd* lastDstIdx = irBuilder.genAdd(dstPosType,mod,dstEnd,minusone);
 
@@ -3034,8 +3031,7 @@
 
     irBuilder.genLabel(boundsException);
     cfgBuilder.genBlockAfterCurrent(boundsException);
-    Opnd * minusOne = irBuilder.genLdConstant((int32)-1);
-    irBuilder.genTauCheckBounds(src,minusOne,tauSrcNullChecked);
+    irBuilder.genTauCheckBounds(src,minusone,tauSrcNullChecked);
 
     irBuilder.genLabel(Exit);
     cfgBuilder.genBlockAfterCurrent(Exit);



Mime
View raw message