harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r538149 - in /harmony/enhanced/drlvm/trunk: src/test/regression/H1852/ src/test/regression/H1852/DivIntTest.java src/test/regression/H1852/run.test.xml vm/jitrino/src/jet/cg_ia32.cpp
Date Tue, 15 May 2007 12:19:56 GMT
Author: varlax
Date: Tue May 15 05:19:55 2007
New Revision: 538149

URL: http://svn.apache.org/viewvc?view=rev&rev=538149
Log:
Fixed HARMONY-1852 [drlvm][jit] irem and idiv return incorrect values when arguments are min
value and -1 (Jitrino JET only)

Added:
    harmony/enhanced/drlvm/trunk/src/test/regression/H1852/
    harmony/enhanced/drlvm/trunk/src/test/regression/H1852/DivIntTest.java
    harmony/enhanced/drlvm/trunk/src/test/regression/H1852/run.test.xml
Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1852/DivIntTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1852/DivIntTest.java?view=auto&rev=538149
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1852/DivIntTest.java (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1852/DivIntTest.java Tue May 15 05:19:55
2007
@@ -0,0 +1,22 @@
+package org.apache.harmony.drlvm.tests.regression.h1852;
+
+import junit.framework.TestCase;
+
+public class DivIntTest extends TestCase {
+
+    public void testIDIV() {
+        int i_min = Integer.MIN_VALUE;
+        int i_1 = -1;
+        int res = i_min / i_1;
+
+        assertEquals(Integer.MIN_VALUE, res);
+    }
+
+    public void testIREM() {
+        int i_min = Integer.MIN_VALUE;
+        int i_1 = -1;
+        int res = i_min % i_1;
+
+        assertEquals(0, res);
+    }
+}

Added: harmony/enhanced/drlvm/trunk/src/test/regression/H1852/run.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/src/test/regression/H1852/run.test.xml?view=auto&rev=538149
==============================================================================
--- harmony/enhanced/drlvm/trunk/src/test/regression/H1852/run.test.xml (added)
+++ harmony/enhanced/drlvm/trunk/src/test/regression/H1852/run.test.xml Tue May 15 05:19:55
2007
@@ -0,0 +1,9 @@
+<project name="RUN HARMONY-1852 Regression Test">
+    <target name="run-test">
+        <run-junit-test 
+             test="org.apache.harmony.drlvm.tests.regression.h1852.DivIntTest"
+             vmarg="-Xem:jet">
+        </run-junit-test>
+    </target>
+</project>
+

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp?view=diff&rev=538149&r1=538148&r2=538149
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_ia32.cpp Tue May 15 05:19:55 2007
@@ -37,6 +37,10 @@
 namespace Jitrino {
 namespace Jet {
 
+/**
+ * Provides fine-tuned implementation for IDIV/IREM operations on IA32-compatible platforms,

+ * in replacement of common arithmetic helper (see arith_rt.h).
+ */
 bool CodeGen::gen_a_platf(JavaByteCodes op, jtype jt)
 {
     if (jt != i32) return false;
@@ -58,18 +62,16 @@
     alu(alu_cmp, v2.as_opnd(), Opnd(-1));
     unsigned br_normal = br(ne, 0, 0);
     alu(alu_cmp, v1.as_opnd(), Opnd(INT_MIN));
-    unsigned br_cont = NOTHING, br_exit = NOTHING;
+    unsigned br_exit = NOTHING;
     if (op == OPCODE_IREM) {
-        br_cont = br(ne, 0, 0);
-        br_exit = br(cond_none, 0, 0);
+        do_mov(edx, Opnd(0)); // prepare exit value for the corner case
+        br_exit = br(eq, 0, 0);
     }
     else {
+        do_mov(eax, v1);
         br_exit = br(eq, 0, 0);
     }
     patch(br_normal, ip());
-    if (br_cont != NOTHING) {
-        patch(br_cont, ip());
-    }
     do_mov(eax, v1);
     //
     // The method is supposed to be platform-depended, and may not have 
@@ -84,9 +86,8 @@
     EncoderBase::Operands args(RegName_EDX, RegName_EAX, 
                                devirt(v2.reg(), i32));
     ip(EncoderBase::encode(ip(), Mnemonic_IDIV, args));
-    if (br_exit != NOTHING) {
-        patch(br_exit, ip());
-    }
+    patch(br_exit, ip());
+
     vpop();
     vpop();
     vpush(op == OPCODE_IREM ? edx : eax);



Mime
View raw message