JDK-8249165 : Remove unneeded nops introduced by 8234160 changes
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 15,16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2020-07-10
  • Updated: 2020-10-10
  • Resolved: 2020-07-13
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 15 JDK 16
15.0.2Fixed 16 b06Fixed
Related Reports
Relates :  
Description
Changes for JDK-8234160: "Enable optimized mitigation for Intel jcc erratum in C2" added NOP instructions before branch instructions to avoid crossing cache line.

But code which checks for branch instruction assumes that all blocks in generated code have a branch as last instruction:
http://hg.openjdk.java.net/jdk/jdk/file/e7d0ec2d06e8/src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp#l48

Which is not true for block which fall through to next block - C2 removes branch in such blocks.

Because of incorrect check we may see unneeded NOPs in code:

04c     movq    R10, [R10 + #192 (32-bit)]    # long
053     movq    [RAX], R10    # long

        nop     # 10 bytes pad for loops and calls

060     movl    [RAX + #8 (8-bit)], narrowklass: precise klass java/lang/Object: 0x00007fe6b02b86c0:Constant:exact *
067     movl    [RAX + #12 (8-bit)], R12    # int (R12_heapbase==0)


Comments
Fix Request for JDK 15 update. We need the fix in JDK 15 to avoid incorrectly generated code. Changes from JDK 16 applied cleanly. Testing done in JDK 16 since July 2020 - no related failures found. https://cr.openjdk.java.net/~kvn/8249165/webrev.00/ Review: https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2020-July/038972.html
30-09-2020

It seems these additional NOP instructions may cause issue found by GraalVM testing: # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (output.cpp:1705), pid=354, tid=30723 # guarantee((int)(blk_starts[i+1] - blk_starts[i]) >= (current_offset - blk_offset)) failed: shouldn't increase block size # # JRE version: Java(TM) SE Runtime Environment (15.0.1+6) (build 15.0.1+6-14) # Java VM: Java HotSpot(TM) 64-Bit Server VM (15.0.1+6-14, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64) # No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again # The guarantee() is caused by additional incorrect NOP instructions generated at the end of block between Spill nodes: 0x110816156: mov qword ptr [rsp + 0x18], rcx 0x11081615b: mov qword ptr [rsp], rdx 0x11081615f: nop 0x110816160: mov rbp, rsi
30-09-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/c6fe28c7fd94 User: kvn Date: 2020-07-13 23:41:09 +0000
13-07-2020

https://cr.openjdk.java.net/~kvn/8249165/webrev.00/
10-07-2020

I did not see significant difference in performance in our regular benchmarks (jvm2008, jbb) but I think we can clean up this code in current JDK.
10-07-2020

The fix: src/hotspot/cpu/x86/c2_intelJccErratum_x86.cpp @@ -49,7 +49,7 @@ if (node->is_MachCall() && !node->is_MachCallJava()) { return true; } - return node_index == (block->number_of_nodes() - 1); + return node->is_MachBranch(); }
10-07-2020