harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r497005 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H1578/ vm/jitrino/src/codegenerator/ vm/jitrino/src/codegenerator/ia32/ vm/jitrino/src/optimizer/
Date Wed, 17 Jan 2007 12:32:03 GMT
Author: varlax
Date: Wed Jan 17 04:32:02 2007
New Revision: 497005

URL: http://svn.apache.org/viewvc?view=rev&rev=497005
Log:
Applied HARMONY-1578 [drlvm][jit][opt] Several bugs in Jitrino.OPT fixed
Tested on SUSE9@ia32 & SUSE9@x64

Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H1578/
    harmony/enhanced/drlvm/trunk/src/test/regression/H1578/NaNTest.java
    harmony/enhanced/drlvm/trunk/src/test/regression/H1578/dcmp1.j
    harmony/enhanced/drlvm/trunk/src/test/regression/H1578/fcmp1.j
    harmony/enhanced/drlvm/trunk/src/test/regression/H1578/run.test.xml
Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp
    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/optimizer/CodeGenerator.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1578/NaNTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1578/NaNTest.java?view=auto&rev=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1578/NaNTest.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1578/NaNTest.java Wed Jan 17 04:32:02
2007
@@ -0,0 +1,22 @@
+package org.apache.harmony.drlvm.tests.regression.H1578;
+
+import junit.framework.TestCase;
+
+public class NaNTest extends TestCase {
+    
+    public void testDcmp() throws Exception {
+        assertEquals(1, dcmp1.test());
+    }
+    
+    public void testFcmp() throws Exception {
+        assertEquals(-1, fcmp1.test());
+    }
+    
+    public void testFloatNaN() {
+        assertTrue(Float.isNaN(Float.NaN));
+    }
+    
+    public void testDoubleNaN() {
+        assertTrue(Double.isNaN(Double.NaN));
+    }
+}
\ No newline at end of file

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1578/dcmp1.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1578/dcmp1.j?view=auto&rev=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1578/dcmp1.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1578/dcmp1.j Wed Jan 17 04:32:02 2007
@@ -0,0 +1,26 @@
+.class public org.apache.harmony.drlvm.tests.regression.H1578.dcmp1
+.super java/lang/Object
+;
+; standard initializer
+.method public <init>()V
+   aload_0
+   invokenonvirtual java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; test method
+
+.method public static test()I
+   .limit stack 6
+   .limit locals 2
+  
+    ldc2_w -1.0d
+    ldc2_w -0.0d
+    ldc2_w 0.0d 
+    ddiv
+    dcmpg	
+    ireturn  
+
+.end method
+

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1578/fcmp1.j
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1578/fcmp1.j?view=auto&rev=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1578/fcmp1.j (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1578/fcmp1.j Wed Jan 17 04:32:02 2007
@@ -0,0 +1,28 @@
+.class public org.apache.harmony.drlvm.tests.regression.H1578.fcmp1
+.super java/lang/Object
+
+
+;
+; standard initializer
+.method public <init>()V
+   aload_0
+   invokenonvirtual java/lang/Object/<init>()V
+   return
+.end method
+
+;
+; test method
+
+.method public static test()I
+   .limit stack 2
+   .limit locals 2
+ 
+  ldc -0.0f
+  ldc 0.0f 
+  fdiv
+  ldc -3.4028235E39f
+  
+  fcmpl
+  ireturn
+.end method
+

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1578/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1578/run.test.xml?view=auto&rev=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1578/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1578/run.test.xml Wed Jan 17 04:32:02
2007
@@ -0,0 +1,9 @@
+<project name="RUN HARMONY-1578 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+            test="org.apache.harmony.drlvm.tests.regression.H1578.NaNTest"
+            vmarg="-Xem:opt">
+        </run-junit-test>
+    </target>
+</project>
+

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=497005&r1=497004&r2=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/CodeGenIntfc.h Wed Jan 17 04:32:02
2007
@@ -216,7 +216,7 @@
     virtual CG_OpndHandle*  select(CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle* src2,
                                    CG_OpndHandle* src3) = 0;
     // BEGIN PRED DEPRECATED
-    virtual CG_OpndHandle*  cmp(CompareOp::Operators,CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle*
src2) = 0;
+    virtual CG_OpndHandle*  cmp(CompareOp::Operators,CompareOp::Types, CG_OpndHandle* src1,CG_OpndHandle*
src2,int ifNaNResult=0) = 0;
     virtual CG_OpndHandle*  cmp3(CompareOp::Operators,CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle*
src2) { return 0; };
     virtual CG_OpndHandle*  czero(CompareZeroOp::Types,CG_OpndHandle* src) = 0;
     virtual CG_OpndHandle*  cnzero(CompareZeroOp::Types,CG_OpndHandle* src) = 0;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp?view=diff&rev=497005&r1=497004&r2=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CodeSelector.cpp Wed
Jan 17 04:32:02 2007
@@ -423,11 +423,11 @@
                     //now fix prev branch successors
                     BranchInst* prevBranch = (BranchInst*)prevInst;
                     assert(prevBranch->getTrueTarget() == NULL && prevBranch->getFalseTarget()
== NULL);
-                    prevBranch->setTrueTarget(nextDB);
+                    prevBranch->setTrueTarget(lastInst->getMnemonic() == Mnemonic_JZ?
nextFT : nextDB);
                     prevBranch->setFalseTarget(newBB);
               
                     
-                    fg->addEdge(node, nextDB, 0);
+                    fg->addEdge(node, lastInst->getMnemonic() == Mnemonic_JZ? nextFT
: nextDB, 0);
                     fg->addEdge(node, newBB, 0);
                     fg->addEdge(newBB, nextDB, 0); 
                     fg->addEdge(newBB, nextFT, 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=497005&r1=497004&r2=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
Wed Jan 17 04:32:02 2007
@@ -138,41 +138,13 @@
 
 // FP remainder internal helpers (temp solution to be optimized)
 float   __stdcall   remF4   (float v0, float v1)stdcall__;
-float   __stdcall   remF4   (float v0, float v1)    { 
-    if(_isnan(v0) || _isnan(v1)|| (!_finite(v0)) || (v1==float(0.0))) {
-        return fnan;
-    } else if (!_finite(v1)){
-        return v0;
-    }     
-    float result = v0-float(int64(v0/v1))*v1;
-    if (result == 0 && v1 < 0) {
-#ifdef PLATFORM_POSIX
-        return copysign(result, v1);
-#else
-        return (float)_copysign(result, v1);
-#endif
-    } else {
-        return result;  
-    }
+float   __stdcall   remF4   (float v0, float v1)   { 
+    return fmodf(v0,v1);
 }
 
 double  __stdcall   remF8   (double v0, double v1)stdcall__;
-double  __stdcall   remF8   (double v0, double v1)  {   
-    if(_isnan(v0) || _isnan(v1) || (!_finite(v0)) || (v1==double(0.0))) {
-        return dnan;
-    } else if (!_finite(v1)){
-        return v0;
-    } 
-    double result = v0-double(int64(v0/v1))*v1;
-    if (result == 0 && v1 < 0) {
-#ifdef PLATFORM_POSIX
-        return copysign(result, v1);
-#else
-        return _copysign(result, v1);
-#endif
-    } else {
-        return result;  
-    }
+double  __stdcall   remF8   (double v0, double v1)  {
+    return  fmod(v0,v1);
 } 
 
 void __stdcall initialize_array(uint8* array, uint32 elems_offset, uint8* data, uint32 num_elems)
stdcall__;
@@ -1211,7 +1183,7 @@
 CG_OpndHandle*  InstCodeSelector::cmp(CompareOp::Operators cmpOp,
                                          CompareOp::Types     opType,
                                          CG_OpndHandle*       src1,
-                                         CG_OpndHandle*       src2) 
+                                         CG_OpndHandle*       src2, int ifNaNResult) 
 {
     Opnd * dst=irManager.newOpnd(typeManager.getInt32Type());
     bool swapped=cmpToEflags(cmpOp, opType, (Opnd*)src1, (Opnd*)src2);
@@ -1220,11 +1192,9 @@
         cm=swapConditionMnemonic(cm);
     appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dst, irManager.newImmOpnd(typeManager.getInt32Type(),
0)));
     appendInsts(irManager.newInstEx(getMnemonic(Mnemonic_SETcc, cm), 1, dst,dst));
-#ifndef _EM64T_
-    if (((opType==CompareOp::F) ||(opType==CompareOp::S) ||(opType==CompareOp::D)) &&
((cmpOp == CompareOp::Geu) || (cmpOp == CompareOp::Gtu))) {
-        appendInsts(irManager.newInstEx(Mnemonic_CMOVP,1,dst,dst,irManager.newImmOpnd(typeManager.getInt32Type(),
0)));
+    if (ifNaNResult == 1 || (ifNaNResult ==0 && ((opType==CompareOp::F) ||(opType==CompareOp::S)
||(opType==CompareOp::D)) && ((cmpOp == CompareOp::Geu) || (cmpOp == CompareOp::Gtu)
|| (cmpOp == CompareOp::Ne) || (cmpOp == CompareOp::Eq)))) {
+        appendInsts(irManager.newInstEx(Mnemonic_CMOVP,1,dst,dst,irManager.newImmOpnd(typeManager.getInt32Type(),
ifNaNResult)));
     }
-#endif
     return dst;
 }
 
@@ -1314,14 +1284,6 @@
             Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((double)0.0);
 #endif
             appendInsts(irManager.newInst(Mnemonic_UCOMISD, srcOpnd1, srcOpnd2));
-#ifndef _EM64T_
-            if(cmpOp == CompareOp::Eq || cmpOp == CompareOp::Ne) {
-                Opnd * ah = irManager.newOpnd(typeManager.getInt32Type());
-                appendInsts(irManager.newInst(Mnemonic_LAHF,ah));
-                Opnd * dst = (Opnd *)and_(IntegerOp::I4, ah, irManager.newImmOpnd(typeManager.getInt32Type(),UNORD_FLAGS_MASK));
-                appendInsts(irManager.newInst(Mnemonic_CMP, dst, irManager.newImmOpnd(typeManager.getInt32Type(),ZF)));
-            }
-#endif
             break;
         }
         case CompareOp::S:
@@ -1335,14 +1297,6 @@
             Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((float)0.0);
 #endif
             appendInsts(irManager.newInst(Mnemonic_UCOMISS, srcOpnd1, srcOpnd2));
-#ifndef _EM64T_
-            if(cmpOp == CompareOp::Eq || cmpOp == CompareOp::Ne) {
-                Opnd * ah = irManager.newOpnd(typeManager.getInt32Type());
-                appendInsts(irManager.newInst(Mnemonic_LAHF,ah));
-                Opnd * dst = (Opnd *)and_(IntegerOp::I4, ah, irManager.newImmOpnd(typeManager.getInt32Type(),UNORD_FLAGS_MASK));
-                appendInsts(irManager.newInst(Mnemonic_CMP, dst, irManager.newImmOpnd(typeManager.getInt32Type(),ZF)));
-            }
-#endif
             break;
         }
         default:
@@ -1361,12 +1315,10 @@
 {
     bool swapped=cmpToEflags(cmpOp, opType, (Opnd*)src1, (Opnd*)src2);
     ConditionMnemonic cm=getConditionMnemonicFromCompareOperator(cmpOp, opType);
-#ifndef _EM64T_
-    if (((opType==CompareOp::F) ||(opType==CompareOp::S) ||(opType==CompareOp::D)) &&
((cmpOp == CompareOp::Geu) || (cmpOp == CompareOp::Gtu))) {
+    if (((opType==CompareOp::F) ||(opType==CompareOp::S) ||(opType==CompareOp::D)) &&
((cmpOp == CompareOp::Geu) || (cmpOp == CompareOp::Gtu)|| (cmpOp == CompareOp::Ne) || (cmpOp
== CompareOp::Eq))) {
         //! branch true&false edges & new block for this branch will be added in
CodeSelector::fixNodeInfo
         appendInsts(irManager.newBranchInst(Mnemonic_JP, NULL, NULL)); 
     }
-#endif
     //! branch true&false edges are added during genTrue|FalseEdge
     appendInsts(irManager.newBranchInst(getMnemonic(Mnemonic_Jcc, swapped?swapConditionMnemonic(cm):cm),
NULL, NULL));
 }

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=497005&r1=497004&r2=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.h
Wed Jan 17 04:32:02 2007
@@ -101,7 +101,7 @@
     CG_OpndHandle* shr(IntegerOp::Types,CG_OpndHandle* value,CG_OpndHandle* shiftAmount);
     CG_OpndHandle* shru(IntegerOp::Types,CG_OpndHandle* value,CG_OpndHandle* shiftAmount);
     CG_OpndHandle* select(CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle* src2,CG_OpndHandle*
src3);
-    CG_OpndHandle* cmp(CompareOp::Operators,CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle*
src2);
+    CG_OpndHandle* cmp(CompareOp::Operators,CompareOp::Types, CG_OpndHandle* src1,CG_OpndHandle*
src2, int ifNaNResult);
     CG_OpndHandle* czero(CompareZeroOp::Types opType,CG_OpndHandle* src);
     CG_OpndHandle* cnzero(CompareZeroOp::Types opType,CG_OpndHandle* src);
     void           branch(CompareOp::Operators,CompareOp::Types,CG_OpndHandle* src1,CG_OpndHandle*
src2);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp?view=diff&rev=497005&r1=497004&r2=497005
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/CodeGenerator.cpp Wed Jan 17 04:32:02
2007
@@ -727,28 +727,33 @@
                 CompareOp::Types opType = mapToCompareOpType(inst);
                 CompareOp::Operators cmpOp = mapToComparisonOp(inst);
                 CompareOp::Operators cmpOp2 = cmpOp;
-                
+
+                int ifNaNResult = -1;
+                if (cmpOp == CompareOp::Gtu || cmpOp == CompareOp::Geu)
+                    ifNaNResult = 1;
+
+                CG_OpndHandle* cgInst1 = 
+                    instructionCallback.cmp(cmpOp, opType,
+                                            getCGInst(inst->getSrc(0)),
+                                            getCGInst(inst->getSrc(1)), ifNaNResult);
+
                 // second operator has opposite NaN behavior for Floats
                 if ((opType==CompareOp::F) ||
                     (opType==CompareOp::S) ||
                     (opType==CompareOp::D)) {
                     switch (cmpOp) {
-                    case CompareOp::Gt: cmpOp2 = CompareOp::Gtu; break;
-                    case CompareOp::Gtu: cmpOp2 = CompareOp::Gt; break;
-                    case CompareOp::Ge: cmpOp2 = CompareOp::Geu; break;
-                    case CompareOp::Geu: cmpOp2 = CompareOp::Ge; break;
+                    case CompareOp::Gt: cmpOp2 = CompareOp::Gtu; ifNaNResult = 1; break;
+                    case CompareOp::Gtu: cmpOp2 = CompareOp::Gt; ifNaNResult = -1; break;
+                    case CompareOp::Ge: cmpOp2 = CompareOp::Geu; ifNaNResult = 1; break;
+                    case CompareOp::Geu: cmpOp2 = CompareOp::Ge; ifNaNResult = -1; break;
                     default: break;
                     };
                 }
                 
-                CG_OpndHandle* cgInst1 = 
-                    instructionCallback.cmp(cmpOp, opType,
-                                            getCGInst(inst->getSrc(0)),
-                                            getCGInst(inst->getSrc(1)));
                 CG_OpndHandle* cgInst2 = 
-                    instructionCallback.cmp(cmpOp2, opType,
+                    instructionCallback.cmp(cmpOp2, opType, 
                                             getCGInst(inst->getSrc(1)),
-                                            getCGInst(inst->getSrc(0)));
+                                            getCGInst(inst->getSrc(0)), ifNaNResult);
                 cgInst = 
                     instructionCallback.sub(ArithmeticOp::I4,
                                             cgInst1,



Mime
View raw message