harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Varlamov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-1852) [drlvm][jit] irem and idiv return incorrect values when arguments are min value and -1 (Jitrino JET only)
Date Tue, 15 May 2007 06:38:16 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-1852?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexey Varlamov updated HARMONY-1852:
-------------------------------------

    Attachment: H1852.diff

The bug was in IA32-tuned version of runtime arithmetic helper, which did not handle the corenr
case properly.
Fix + regtest is attached.

> [drlvm][jit]  irem and idiv return incorrect values when arguments are min value and
-1 (Jitrino JET only)
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1852
>                 URL: https://issues.apache.org/jira/browse/HARMONY-1852
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Linux IA-32, Windows IA-32
>            Reporter: Irina Arkhipets
>         Assigned To: Alexey Varlamov
>         Attachments: H1852.diff, test_idiv.java, test_irem.java
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message