JDK-8329984 : Different output of program when using JIT in release jdk-21.0.2
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 21.0.2
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2024-04-03
  • Updated: 2024-04-09
Description
ADDITIONAL SYSTEM INFORMATION :
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
...

$ oracle-jdk-21.0.2/bin/java -version
java version "21.0.2" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
When I run the program below with JDK 21, I notice different output results when I use the -Xint and -Xcomp options.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -Xcomp Test > result_1
java -Xint Test > result_2
diff result_1 result_2

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no diff
ACTUAL -
[run] 1
4,20c4,20
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
< 22738
---
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0
> 0

---------- BEGIN SOURCE ----------
class Test {

  int a = 400;
  int[] e = new int[a];

  void mainTest(String[] g) {
    int i = 22738;
    int b;
    int h;
    int[] c = new int[a];
    for (b = 3; b < 273; b++) {
      h = 1;
      while (++h < 97) switch (b % 6 + 56) {
        case 56:
          c[1] = i;
        case 57:
          synchronized (new Test()) {}
      }
    }
    int k = 0;
    for (int j = 0; j < c.length; j++) k += c[j];
    System.out.println(k);
  }

  public static void main(String[] f) {
    Test d = new Test();
    for (int i = 0; i < 20; i++) d.mainTest(f);
  }
}

---------- END SOURCE ----------


Comments
Verified in-house with Ubuntu 4.4 LTS (Jammy Jellyfish) and Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing No issue with: Java HotSpot(TM) 64-Bit Server VM (build 25.391-b13, mixed mode) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.21+9-LTS-193, mixed mode) Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240) Moving to JDK for further analysis. ILW= LHL = P5
09-04-2024