You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "George Timoshenko (JIRA)" <ji...@apache.org> on 2007/04/06 12:26:32 UTC

[jira] Commented: (HARMONY-3216) [drlvm][jit][opt] OPT loses ArrayStoreException when optimizing java.lang.System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

    [ https://issues.apache.org/jira/browse/HARMONY-3216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487211 ] 

George Timoshenko commented on HARMONY-3216:
--------------------------------------------

the problem is I was too optimistic while iimplementing arraycopy optimisation.

at compiile time we can optimise only if the types of arrays are exactly the same.
isSubClassOf can not be used. As the issue shows one of the arrays can be instantiated with some of it's descendant.
And the descendant can have nothing similar to the second array.

Let' divide the problem into two parts:
1 - as a fix of the issue I replase isSubClassOf by the comparison of the array classes.

2 - this feature (arraycopy call replacement) can be done in the guarded manner. When the classes of the arrays are being checked at runtime.
(It is not obvious if it gives a performance effect or not).
when this approach (guarded arraycopy call "inlining") is being implemented this optimisation should be moved out from the translator and inserted (before inliner) into the HLO path as a separate optimisation.

> [drlvm][jit][opt] OPT loses ArrayStoreException when optimizing java.lang.System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
> --------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3216
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3216
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>         Environment: Linux x86 (SLES9), Windows x86 (XP )
>            Reporter: Nina Rinskaya
>            Priority: Minor
>
> Looks that OPT loses ArrayStoreException when optimizing java.lang.System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length), please see testcase and outputs below:
> public class MyTest {
>     Object[] oo1 = new String[3];
>     public int test() {
>         Integer[] oo2 = new Integer[oo1.length];
>         for (int i=0; i<oo2.length; i++) {
>             oo2[i] = new Integer(i);
>         }
>         try {
>             System.arraycopy(oo2, 0, oo1, 0, oo1.length);
>         } catch (ArrayStoreException ase) {
>             return 0;
>         }
>         return 1;
>     }
>     public static void main(String[] args) {
>         try {
>             int res = new MyTest().test();
>             if (res != 0 ) {
>                 System.out.println("Failed: ArrayStoreException not thrown!");
>             } else
>                 System.out.println("Passed");
>         } catch (Throwable t) {
>             System.out.println("Error: ");
>             t.printStackTrace();
>         }
>     }
> }
> Output on RI:
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
> java.lang.ArrayStoreException
>         at java.lang.System.arraycopy(Native Method)
>         at ac.test(ac.java:9)
>         at ac.main(ac.java:18)
> Passed: ArrayStoreException thrown
> Output on Harmony (with default options):
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509548, (Feb 20 2007), Linux/ia32/gcc 3.3.3, debug build
> http://incubator.apache.org/harmony
> java.lang.ArrayStoreException: bad arrayCopy
>         at java.lang.VMMemoryManager.arrayCopy(VMMemoryManager.java)
>         at java.lang.System.arraycopy(System.java)
>         at ac.test(ac.java:9)
>         at ac.main(ac.java:18)
> Passed: ArrayStoreException thrown
> Output on Harmony with -Xem:opt:
> 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 = r509548, (Feb 20 2007), Linux/ia32/gcc 3.3.3, debug build
> http://incubator.apache.org/harmony
> Failed: ArrayStoreException not thrown!
> Output on Harmony with -Xem:opt -XDjit.arg.genArrayCopyRepMove=false:
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r509548, (Feb 20 2007), Linux/ia32/gcc 3.3.3, debug build
> http://incubator.apache.org/harmony
> java.lang.ArrayStoreException: bad arrayCopy
>         at java.lang.VMMemoryManager.arrayCopy(VMMemoryManager.java)
>         at java.lang.System.arraycopy(System.java)
>         at ac.test(ac.java:9)
>         at ac.main(ac.java:18)
> Passed: ArrayStoreException thrown

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.