JDK-8148175 : C1: G1 barriers don't preserve FP registers
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u60,9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-01-25
  • Updated: 2019-01-14
  • Resolved: 2016-03-28
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 JDK 9
8u192Fixed 9 b114Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
I have a code which looks like:
    public void go()  {
        final float FINAL = getValue(); 
        for (...) {
             if (FINAL != getValue()) {
                 System.out.println("FAIL");
             }
        }
     } 
     float getValue() { 
         return 6; 
     }

Being run with G1 and -Xcomp the value of the FINAL variable may change...

The source is attached.
# java -Xmx300m -XX:+UseG1GC -Xmixed TestFinalFloat
Final value: 6.0
Still passed
Still passed
Still passed
Final values has changed: -8.532477E32
TEST FAILED

Comments
The problem is C1-specific: reproduced with -XX:TieredStopAtLevel=1 ... Final value: 6.0 877 162 b 1 TestFinalFloat::getY (27 bytes) 878 163 b 1 TestFinalFloat::getX (14 bytes) 893 164 % b 1 TestFinalFloat::go @ 120 (228 bytes) 906 165 b 1 TestFinalFloat::go (228 bytes) Final values has changed: 0.0 TEST FAILED
11-03-2016

Still reproducible with jdk9 b107 on Solaris-x64 > java9 -Xmx300m -XX:+UseG1GC -Xmixed TestFinalFloat Final value: 6.0 Still passed Still passed Still passed Final values has changed: -5.553831E34 TEST FAILED > java9 -Xmx300m -XX:+UseG1GC -Xmixed TestFinalFloat Final value: 6.0 Still passed Still passed Still passed Final values has changed: -1.2279746E31 TEST FAILED > java9 -version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+107-2016-02-25-014321.javare.4520) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+107-2016-02-25-014321.javare.4520, mixed mode)
29-02-2016

Seems to be reproducing only with G1.
25-01-2016

The problem is well reproducible. I manage to reproduce it on Solaris and Windows, on jdk8_u60 and jdk9_b102.
25-01-2016