harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2141) [drlvm] [jit] [opt] ABCD removes low bound check if certain constraint exists before array access with a negative index
Date Fri, 10 Nov 2006 09:29:37 GMT
[drlvm] [jit] [opt] ABCD removes low bound check if certain constraint exists before array
access with a negative index
-----------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2141
                 URL: http://issues.apache.org/jira/browse/HARMONY-2141
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
         Environment: Any
            Reporter: Elena Sayapina


ABCD  optimization removes low bound check if certain constraint exists before array access
with a negative index.

ArrayIndexOutOfBoundsException must be thrown if array alement with negative index is accessed.

But harmony doesn't throw the Exception if abcd pass is turned on in the following case:
Array elements are accessed inside a loop and array index depends on the loop control variable.
A call to an array element with negative index occurred if
control loop variable satisfies some linear constraint.

Please, see the code example below.

Code for reproducing:

public class abcdTest {

    public static void main(String[] args) {
        System.out.println("Start Test ...");
        int i = 0;
        int arr[] = new int[300000];
        try {
            for(i=0; i<100000; i++) {
                while(i<3) {
                    arr[i-1] = 1;
                    i++;
                }
            }
            System.out.println("TEST 1 FAILED: " +
                "ArrayIndexOutOfBoundsException wasn't thrown");
        } catch (ArrayIndexOutOfBoundsException ae) {
            System.out.println("TEST 1 PASSED");
        }
        i = 0;
        try {
            for(i=0; i<100000; i++) {
                if (i>5) {
                    arr[i-100] = 1;
                    i++;
                }
            }
            System.out.println("TEST 2 FAILED: " +
                "ArrayIndexOutOfBoundsException wasn't thrown");
        } catch (ArrayIndexOutOfBoundsException ae) {
            System.out.println("TEST 2 PASSED");
        }
    }
}

Steps to Reproduce:
Compile abcdTest class and run it on harmony with '-Xem:server_static'.

Note:
If remove loop variable constraints 'while(i<3)' , 'if(i>5)' in test1, test2 correspondingly,
then abcdTest passes.

Windows output:
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r473012, (Nov 10 2006), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony
Start Test ...
TEST 1 FAILED: ArrayIndexOutOfBoundsException wasn't thrown
TEST 2 FAILED: ArrayIndexOutOfBoundsException wasn't thrown

Linux output:
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0" 
pre-alpha : not complete or compatible
svn = r473012, (Nov 10 2006), Linux/ia32/icc 900, release build
http://incubator.apache.org/harmony
Start Test ...
TEST 1 FAILED: ArrayIndexOutOfBoundsException wasn't thrown
TEST 2 FAILED: ArrayIndexOutOfBoundsException wasn't thrown

Output on RI:
Start Test ...
TEST 1 PASSED
TEST 2 PASSED


-- 
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