You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexey Varlamov (JIRA)" <ji...@apache.org> on 2007/04/28 18:31:15 UTC
[jira] Assigned: (HARMONY-1852) [drlvm][jit] irem and idiv return
incorrect values when arguments are min value and -1 (Jitrino JET only)
[ https://issues.apache.org/jira/browse/HARMONY-1852?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexey Varlamov reassigned HARMONY-1852:
----------------------------------------
Assignee: Alexey Varlamov
> [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: 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.