Skip to content

JDK8 OpenJ9: Server and Desktop Gives Different Result #15349

@connglli

Description

@connglli

Java version

openjdk version "1.8.0_342-internal"
OpenJDK Runtime Environment (build 1.8.0_342-internal-_2022_06_10_15_18-b00)
Eclipse OpenJ9 VM (build master-3d06b2f9c, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20220610_000000 (JIT enabled, AOT enabled)
OpenJ9   - 3d06b2f9c
OMR      - cf8ddbd1a
JCL      - 2bb179375a based on jdk8u342-b05)

Javac version

javac 1.8.0_342-internal

Summary of problem

This issue gives a quite tricky Test.java.

On one hand, OpenJ9 (with above version) produces different result from HotSpot and the Android Runtime (ART).

On the other hand, the results of OpenJ9 running on our desktop and server are also different; and both different from HotSpot/ART.

No matter desktop or server, the results of OpenJ9 are deterministic.

class Test {
  static long instanceCount;
  static long vMeth_check_sum;

  static void vMeth(double d, int i) {
    if (ax$0) {
      int ax$6;
      int ax$5;
      int ax$2 = 0x03;
      int ax$1 = 8080;
      int ax$4 = 70000;
      byte[] ax$3 = new byte[1 << 14];
      for (ax$5 = 1; ax$5 < 58; ax$5++)
        for (ax$6 = ax$5; 400 > ax$6; ax$6++) {
          ax$3[ax$6] -= ax$4;
          ax$1 += ax$6;
          switch (i % 5) {
            case 107:
              i >>= ax$2;
          }
        }
      return;
    }
    boolean bArr;
    int i21, i22 = 251, i25, i26 = 109, i27, i33 = 11;
    for (i25 = 8; 192 > i25; ++i25)
      for (i27 = 1; i27 < 3; ++i27) {
        instanceCount += i22;
        i33 = 1;
        i26 += i33;
      }
    vMeth_check_sum += i26 + i33;
  }

  void mainTest(String[] strArr1) {
    try {
      ax$0 = true;
      for (int ax$9 = 0; ax$9 < 6683; ax$9 += 1) vMeth(0.2660549401640039, 572329205);
    } finally {
      ax$0 = false;
    }
    vMeth(2.39889, 4);
    System.out.println(vMeth_check_sum);
  }

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

  static Boolean ax$0;
}

Results of OpenJ9 on our desktop:

478
772
1066
1360
1654
1948
2242
2536
2830

Results of OpenJ9 on our server:

294
588
882
1176
1470
1764
2058
2352
2646
2940

Results of OpenJ9 (Interpreter), HotSpot (JDK8/11/17) and the Android Runtime (ART):

478
956
1434
1912
2390
2868
3346
3824
4302
4780

Configuration

Our desktop (Ubuntu 20.04; Intel i7; 16GiB )

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

$ cat /proc/cpuinfo
...
vendor_id	: GenuineIntel
cpu family	: 6
model		: 158
model name	: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
...

Our server (Ubuntu 20.04; AMD Threadripper; 256GiB )

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

$ cat /proc/cpuinfo
...
vendor_id	: AuthenticAMD
cpu family	: 23
model		: 49
model name	: AMD Ryzen Threadripper 3990X 64-Core Processor
...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions