JDK-6849984 : Value methods for platform dependent math functions constant fold incorrectly
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs16
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2009-06-10
  • Updated: 2010-04-02
  • Resolved: 2010-01-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 6 JDK 7 Other
6u21Fixed 7Fixed hs17Fixed
Related Reports
Relates :  
Relates :  
Description
This is actually a long standing issue but has only recently come to light.  C2 uses platform dependent Nodes to take advantage of hardware instructions for trig and log functions.  All of these nodes have Value methods which will constant fold a constant input.  The problem is that the SharedRuntime version of the functions are the strict ones but the platform dependent ones aren't strict so this can lead to different values being returned.  The fix is to stop constant folding these operations.

Comments
EVALUATION This is actually a long standing issue but has only recently come to light. C2 uses platform dependent Nodes to take advantage of hardware instructions for trig and log functions. All of these nodes have Value methods which will constant fold a constant input. The problem is that the SharedRuntime version of the functions are the strict ones but the platform dependent ones aren't necessary strict so this can lead to different values being returned. The fix is to provide implementations of these functions that can be used for constant folding. Additionally this exposed a problem with Xcomp and interpreter intrinsics where the interpreter will prefer a compiled version of a method to the interpreter intrinsic so we have to avoid compiling them. Tested with new test case and the Math and StrictMath regression test from the JDK. C1 doesn't constant fold these operations so no changes were needed there.
19-01-2010

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/ddb7834449d0
15-01-2010

EVALUATION Alternatively we could have callable versions of the platform dependent ones but that seems like overkill for such a small benefit.
10-06-2009