Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6863155

Server compiler generates incorrect code (x86, long, bitshift, bitmask)

XMLWordPrintable

    • b06
    • b08
    • generic, x86
    • generic, windows_xp
    • Verified

        FULL PRODUCT VERSION :
        java version "1.7.0-ea"
        Java(TM) SE Runtime Environment (build 1.7.0-ea-b65)
        Java HotSpot(TM) Server VM (build 16.0-b06, mixed mode)

        FULL OS VERSION :
        Microsoft Windows XP [Version 5.1.2600]

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Intel x86 32-bit

        A DESCRIPTION OF THE PROBLEM :
        Code compiled with server compiler generates an incorrect result.

        Ran the source code with:
        -server
        -XX:CompileThreshold=10
        -XX:CompileOnly=jvmtest/Tester
        -XX:+PrintCompilation

        and got:
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
          13254907146 jvmtest.Tester::
        te3254907146s
        t3254907146 (51 bytes)

        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        3254907146
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150
        -1040060150

        The negative (incorrect) results seem to occur after the compiled code starts kicking in. The negative results never occur with client compiler or interpreted mode.

        THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

        THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run code without -server. Observe correct result.
        Then observe code with -server and a low compile threshold and observe incorrect result after code is compiled.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        The correct result from the code is '3254907146'. The result after the code is compiled is calculated as '-1040060150'.
        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package jvmtest;

        public class Tester
        {
        private static long test(byte bytes[])
            {
        long value;
        value = bytes[3] << 24 & 0xff000000L;
                value += bytes[2] << 16 & 0xff0000;
                value += bytes[1] << 8 & 0xff00;
                value += bytes[0] & 0xff;
                return(value);
            }

        public static void main(String... args)
        throws Exception
        {
        for (int i = 0; i < 1000; i++)
        {
        //byte[] bytes = new byte[] {10, -15, 1, -62};
        byte[] bytes = new byte[] {0x0a, (byte)0xf1, 0x01, (byte)0xc2};
        System.out.println(test(bytes));
        }
        }
        }
        ---------- END SOURCE ----------

              twisti Christian Thalinger (Inactive)
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: