harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Irina Arkhipets (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1852) [drlvm][jit] irem and idiv return incorrect values when arguments are min value and -1 (Jitrino JET only)
Date Fri, 13 Oct 2006 06:58:34 GMT
[drlvm][jit]  irem and idiv return incorrect values when arguments are min value and -1 (Jitrino
JET only)
----------------------------------------------------------------------------------------------------------

                 Key: HARMONY-1852
                 URL: http://issues.apache.org/jira/browse/HARMONY-1852
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
         Environment: Linux IA-32, Windows IA-32
            Reporter: Irina Arkhipets


J2SE VM Specification reads about irem and idev instructions:
...
irem: This identity holds even in the special case in which the dividend is the negative int
of largest possible magnitude for its type and the divisor is -1 (the remainder is 0).

idiv: There is one special case that does not satisfy this rule: if the dividend is the negative
integer of largest possible magnitude for the int type, and the divisor is -1, then overflow
occurs, and the result is equal to the dividend. Despite the overflow, no exception is thrown
in this case.
...

However, idiv and irem instructions return incorrect values when arguments are Integer.MIN_VALUE
and -1 in some cases.
This bug is reproducible with Jitrino JET only. I am not able to reproduce it with Jitrino
OPT and interpreter.

Please, compile the following soutsec and run them with "-Xem:jet" switch to reproduce this
bug:

--------- test_irem.java ----------
public class test_irem {

    public static void main(String [] args) {

        int i_min = Integer.MIN_VALUE;
        int i_1 = -1;
        int res = i_min % i_1;

        if (res == 0) {
            System.out.println("PASSED");
        } else {
            System.out.println("FAILED: " + res);
        }
    }
}
--------- test_idiv.java ---------
public class test_idiv {

    public static void main(String [] args) {

        int i_min = Integer.MIN_VALUE;
        int i_1 = -1;
        int res = i_min / i_1;

        if (res == Integer.MIN_VALUE) {
            System.out.println("PASSED");
        } else {
            System.out.println("FAILED: " + res);
        }
    }
}
-------------------------------------

Sample output is:
...
F:\...home\users\iarkhipe>java -Dvm.assert_dialog=false -Xem:jet test_irem
FAILED: 1

F:\...home\users\iarkhipe>java -Dvm.assert_dialog=false -Xem:jet test_idiv
FAILED: 21247424
...

Please, note thet the following test examples works fine and always passes with Jitrino JET:
--------- test_irem.java ----------
public class test_irem {

    public static void main(String [] args) {

        int res = Integer.MIN_VALUE % -1;

        if (res == 0) {
            System.out.println("PASSED");
        } else {
            System.out.println("FAILED: " + res);
        }
    }
}
--------- test_idiv.java ---------
public class test_idiv {

    public static void main(String [] args) {

        int res = Integer.MIN_VALUE / -1;

        if (res == Integer.MIN_VALUE) {
            System.out.println("PASSED");
        } else {
            System.out.println("FAILED: " + res);
        }
    }
}
-------------------------------------


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message