JDK-4345910 : On x86 platforms, C2 Math.{sin, cos} implementations violate the 1.3 spec
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.2.0,1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_7,windows_98
  • CPU: x86
  • Submitted: 2000-06-15
  • Updated: 2000-11-16
  • Resolved: 2000-11-16
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.
1.3.1 betaFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
In 1.3, the specification for java.lang.Math.{sin, cos} was changed
from an operational definition (use FDLIBM algorithms) to a
declarative one (use any approximation with 1 ulp accuracy and good
monotonicity properties).  On x86 platforms, for values smaller in
magnitude than 2^63, effectively the C1 and C2 compilers use the raw
x86 instructions fsin and fcos to implement Math.{sin, cos}.  This
does not follow the spec since the 66 bit argument reduction used by
fsin/fcos introduces large deviations from the true values of sine and
cosine for some inputs.  Outside of +/-2^63, C1 and C2 use FDLIBM
algorithms which do proper argument reduction.  This introduces an
inconsistency in the periodicity of the approximation to sine/cosine.

The solution is to have the Math.{sin, cos} do their own argument
reduction to [-pi/4, pi/4] and then call fsin/fcos; this will
guarantee the specified accuracy and monotonicity properties.  The
needed argument reduction functions are already available from FDLIBM,

This bug is filed against C1 as bug id 4345903.

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: ladybird INTEGRATED IN: ladybird-beta

WORK AROUND Use the methods in the FDLIBM-based java.lang.StrictMath to implement java.lang.Math.

SUGGESTED FIX See suggested fix in bug id 4345903.

PUBLIC COMMENTS On x86 platforms, C1 and C2 use the fsin and fcos instructions to implement java.lang.Math.{sin, cos} without fully compensating for the accuracy and range limitations of those instructions -- leading to java.lang.Math.{sin, cos} implementations that don't meet the accuracy requirements of the 1.3 specification.

EVALUATION Fixed for C2 and the interpreter in the Cheetah workspace. Fix is intended to go back to the Ladybird release. cliff.click@eng 2000-06-15