JDK-8288726 : HotSpot's Interpreter and JIT Compilers Give Different Result
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u331
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2022-06-14
  • Updated: 2022-11-04
  • Resolved: 2022-11-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8u371Resolved
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Arch: x86_64
OS: MacOS
HotSpot
- java version "1.8.0_331"
- Java(TM) SE Runtime Environment (build 1.8.0_331-b09)
- Java HotSpot(TM) 64-Bit Server VM (build 25.331-b09, mixed mode)
javac: javac 1.8.0_331


A DESCRIPTION OF THE PROBLEM :
The problem was found in the repo https://github.com/openjdk/jdk8u-dev (commit 820ab134), OpenJDK 1.8.0_352 (internal). 

Unfortunately, it can also be reproduced on OpenJDK 1.8.0_331.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ javac Test.java

$ java -Xint Test
0
0
0
0
0
0
0
0
0
0

$ java -Xcomp Test
0
-74060
-74060
-74060
-74060
-74060
-74060
-74060
-74060
-74060

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Options `-Xint` and `-Xcomp` give the same result
ACTUAL -
Options `-Xint` and `-Xcomp` give different results

---------- BEGIN SOURCE ----------
class Test {
  int N = 256;
  volatile long instanceCount;
  short sFld;
  int iFld;
  volatile long lArrFld[] = new long[N];

  void vMeth(int i, int i1) {
    int i21, i24, i25 = 46;
    float f1;
    byte by2 = 97;
    sFld = (short) 1457395900305333787L;
    for (i21 = 11; i21 < 192; i21++) {
      for (f1 = 3; 1 < f1; f1 -= 3) {
        i1 = sFld;
        for (i24 = 1; 3 > i24; ++i24) {
          lArrFld = lArrFld;
          sFld = (short) i25;
          lArrFld[(int) f1] *= by2;
        }
      }
      sFld *= i1;
      i1 *= instanceCount;
    }
  }

  void mainTest(String[] strArr1) {
    int i28, i31 = 3, i36, i39 = 50982, iArr3[] = new int[N];
    vMeth(iFld, 5);
    for (i28 = 2; 138 > i28; i28++) {
      i36 = 1;
      while (++i36 < 37)
        switch (69) {
          case 69:
            i39 = sFld;
          case 70:
            iArr3[i28] -= i39;
          case 76:
            i31 = iArr3[i36];
        }
    }
    System.out.println(i31);
  }

  public static void main(String[] strArr) {
    Test _instance = new Test();
    for (int i = 0; i < 10; i++) _instance.mainTest(strArr);
  }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Closing as dupe of JDK-8243670 according to current understanding.
04-11-2022

Issue is reproduced with JDK 8u333 OS: Windows 10 JDK 8u333: Fail JDK 9ea141: Pass JDK 11.0.15.1: Pass JDK 17.0.3: Pass JDK 18.0.1.1 : Pass Output Fail: java -Xint Test 0 0 0 0 0 0 0 0 0 0 java -Xcomp Test 0 -74060 -74060 -74060 -74060 -74060 -74060 -74060 -74060 -74060 Output Pass: java -Xint Test 0 0 0 0 0 0 0 0 0 0 java -Xcomp Test 0 0 0 0 0 0 0 0 0 0
20-06-2022