eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 722 forks source link

Wrong result in Option -Xcomp #19403

Closed RuifengFu closed 1 month ago

RuifengFu commented 6 months ago

Java -version output

openjdk version "1.8.0_402"
IBM Semeru Runtime Open Edition (build 1.8.0_402-b06)
Eclipse OpenJ9 VM (build openj9-0.43.0, JRE 1.8.0 Windows 10 amd64-64-Bit Compressed References 20240131_874 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 0fa9d9c532 based on jdk8u402-b06)

openjdk version "11.0.22" 2024-01-16
IBM Semeru Runtime Open Edition 11.0.22.0 (build 11.0.22+7)
Eclipse OpenJ9 VM 11.0.22.0 (build openj9-0.43.0, JRE 11 Windows 10 amd64-64-Bit Compressed References 20240131_835 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 7876cac747 based on jdk-11.0.22+7)

openjdk version "21.0.2" 2024-01-16 LTS
IBM Semeru Runtime Open Edition 21.0.2.0 (build 21.0.2+13-LTS)
Eclipse OpenJ9 VM 21.0.2.0 (build openj9-0.43.0, JRE 21 Windows 10 amd64-64-Bit Compressed References 20240116_95 (JIT enabled, AOT enabled)
OpenJ9   - 2c3d78b48
OMR      - ea8124dbc
JCL      - 78c4500a434 based on jdk-21.0.2+13)

Summary of problem

I got wrong execute outputs in 8.0, 11.0, 21.0 with -Xcomp option, but got the right result in 17.0.

Dagnostic files

Expect Result:

warmup
CHECKSUM: 536880812

Actual Result:

warmup
CHECKSUM: 9900

Reproduce step:

cd workdir
java -Xcomp -cp . Test6892265

Test6892265.zip

hzongaro commented 6 months ago

It looks like there are a pair of System.arraycopy calls in Test6892265.test(), and the code after the first call is removed by Value Propagation, as it thinks that an ArrayCopyBNDCHK operation will fail.

IL before Value Propagation:

n260n     istore  <auto slot 0>[#361  Auto] [flags 0x3 0x0 ]                                  [       0x119398100] bci=[-1,413,-] rc=0 vc=35 vn=- li=- udi=- nc=1
n259n       iconst 0x20000000 (X!=0 X>=0 )                                                    [       0x1193980b0] bci=[-1,411,-] rc=4 vc=35 vn=- li=- udi=- nc=0 flg=0x104
n267n     treetop                                                                             [       0x119398330] bci=[-1,423,-] rc=0 vc=35 vn=- li=- udi=- nc=1
n266n       call  java/lang/System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V[#372  final native static Method] [flags 0x20500 0x0 ] ()  [       0x1193982e0] bci=[-1,423,-] rc=1 vc=35 vn=- li=- udi=- nc=5 flg=0x20
n261n         aload  Test6892265.src2 [I[#365  Static] [flags 0x307 0x0 ]                     [       0x119398150] bci=[-1,414,-] rc=1 vc=35 vn=- li=- udi=- nc=0
n262n         iconst 0 (X==0 X>=0 X<=0 )                                                      [       0x1193981a0] bci=[-1,417,-] rc=2 vc=35 vn=- li=- udi=- nc=0 flg=0x302
n263n         aload  Test6892265.dst2 [I[#366  Static] [flags 0x307 0x0 ]                     [       0x1193981f0] bci=[-1,418,-] rc=1 vc=35 vn=- li=- udi=- nc=0
n259n         ==>iconst 0x20000000
n265n         iconst 1 (X!=0 X>=0 )                                                           [       0x119398290] bci=[-1,422,-] rc=2 vc=35 vn=- li=- udi=- nc=0 flg=0x104
n274n     treetop                                                                             [       0x119398560] bci=[-1,435,-] rc=0 vc=35 vn=- li=- udi=- nc=1
n273n       call  java/lang/System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V[#372  final native static Method] [flags 0x20500 0x0 ] ()  [       0x119398510] bci=[-1,435,-] rc=1 vc=35 vn=- li=- udi=- nc=5 flg=0x20
n268n         aload  Test6892265.dst2 [I[#366  Static] [flags 0x307 0x0 ]                     [       0x119398380] bci=[-1,426,-] rc=1 vc=35 vn=- li=- udi=- nc=0
n259n         ==>iconst 0x20000000
n270n         aload  Test6892265.src2 [I[#365  Static] [flags 0x307 0x0 ]                     [       0x119398420] bci=[-1,430,-] rc=1 vc=35 vn=- li=- udi=- nc=0
n262n         ==>iconst 0
n265n         ==>iconst 1
n278n     treetop                                                                             [       0x1193986a0] bci=[-1,442,-] rc=0 vc=35 vn=- li=- udi=- nc=1
n277n       icall  JITFuzzing/Check.checksum(II)I[#364  static Method] [flags 0x500 0x0 ]     [       0x119398650] bci=[-1,442,-] rc=2 vc=35 vn=- li=- udi=- nc=2
n275n         iload  Test6892265.CHECKSUM I[#356  Static] [flags 0x303 0x0 ]                  [       0x1193985b0] bci=[-1,438,-] rc=1 vc=35 vn=- li=- udi=- nc=0
n259n         ==>iconst 0x20000000
n279n     istore  Test6892265.CHECKSUM I[#356  Static] [flags 0x303 0x0 ]                     [       0x1193986f0] bci=[-1,445,-] rc=0 vc=35 vn=- li=- udi=- nc=1
n277n       ==>icall
n280n     return                                                                              [       0x119398740] bci=[-1,448,-] rc=0 vc=35 vn=- li=- udi=- nc=0
n4n       BBEnd </block_4> =====                                                              [       0x1193083a0] bci=[-1,448,-] rc=0 vc=35 vn=- li=- udi=- nc=0

then after Local Value Propagation:

[   143]  25.5    O^O VALUE PROPAGATION: Changing call call [00000001193982E0] to arraycopy
[   144]  25.6    O^O VALUE PROPAGATION: Removing rest of block after ArrayCopyBNDCHK [000000011939A4F0]
...
n1n       BBStart <block_4> (freq 10000)                                                      [       0x1193082b0] bci=[-1,411,-] rc=0 vc=37 vn=- li=- udi=- nc=0
n260n     istore  <auto slot 0>[#361  Auto] [flags 0x3 0x0 ]                                  [       0x119398100] bci=[-1,413,-] rc=0 vc=37 vn=- li=- udi=- nc=1
n259n       iconst 0x20000000 (X!=0 X>=0 )                                                    [       0x1193980b0] bci=[-1,411,-] rc=2 vc=37 vn=- li=- udi=- nc=0 flg=0x104
n369n     NULLCHK on n261n [#32]                                                              [       0x11939a310] bci=[-1,414,-] rc=0 vc=37 vn=- li=- udi=- nc=1
n368n       arraylength (stride 4) (X>=0 cannotOverflow )                                     [       0x11939a2c0] bci=[-1,414,-] rc=2 vc=37 vn=- li=- udi=- nc=1 flg=0x1100
n261n         aload  Test6892265.src2 [I[#365  Static] [flags 0x307 0x0 ]                     [       0x119398150] bci=[-1,414,-] rc=1 vc=37 vn=- li=- udi=- nc=0
n371n     NULLCHK on n263n [#32]                                                              [       0x11939a3b0] bci=[-1,418,-] rc=0 vc=37 vn=- li=- udi=- nc=1
n370n       arraylength (stride 4) (X>=0 cannotOverflow )                                     [       0x11939a360] bci=[-1,418,-] rc=2 vc=37 vn=- li=- udi=- nc=1 flg=0x1100
n263n         aload  Test6892265.dst2 [I[#366  Static] [flags 0x307 0x0 ]                     [       0x1193981f0] bci=[-1,418,-] rc=1 vc=37 vn=- li=- udi=- nc=0
n373n     ArrayCopyBNDCHK [#1]                                                                [       0x11939a450] bci=[-1,414,-] rc=0 vc=37 vn=- li=- udi=- nc=2
n372n       isub (cannotOverflow )                                                            [       0x11939a400] bci=[-1,414,-] rc=1 vc=37 vn=- li=- udi=- nc=2 flg=0x1000
n368n         ==>arraylength
n265n         iconst 1 (X!=0 X>=0 )                                                           [       0x119398290] bci=[-1,422,-] rc=2 vc=37 vn=- li=- udi=- nc=0 flg=0x104
n262n       iconst 0 (X==0 X>=0 X<=0 )                                                        [       0x1193981a0] bci=[-1,417,-] rc=1 vc=37 vn=- li=- udi=- nc=0 flg=0x302
n375n     ArrayCopyBNDCHK [#1]                                                                [       0x11939a4f0] bci=[-1,418,-] rc=0 vc=37 vn=- li=- udi=- nc=2
n374n       isub (cannotOverflow )                                                            [       0x11939a4a0] bci=[-1,418,-] rc=1 vc=37 vn=- li=- udi=- nc=2 flg=0x1000
n370n         ==>arraylength
n265n         ==>iconst 1
n259n       ==>iconst 0x20000000
n376n     return                                                                              [       0x11939a540] bci=[-1,418,-] rc=0 vc=37 vn=- li=- udi=- nc=0
n4n       BBEnd </block_4> =====                                                              [       0x1193083a0] bci=[-1,448,-] rc=0 vc=36 vn=- li=- udi=- nc=0

I strongly suspect that this is a duplicate of issue #19247.

hzongaro commented 5 months ago

@dylanjtuttle, as I mentioned above, I suspect this is a duplicate of issue #19247. May I ask you to look at these two issues together?

dylanjtuttle commented 1 month ago

Closed as completed in omr #7461

pshipton commented 1 month ago

Reopen until the PR is added to 0.48

github-actions[bot] commented 1 month ago

Issue Number: 19403 Status: Closed Actual Components: comp:jit, userRaised Actual Assignees: No one :( PR Assignees: dylanjtuttle, dylanjtuttle