Math trig intrinsics and compiler options
mark at klomp.org
Fri Aug 7 02:47:08 PDT 2009
On Thu, 2009-08-06 at 19:56 +0100, Andrew John Hughes wrote:
> 2009/8/6 Joseph D. Darcy <Joe.Darcy at sun.com>:
> > My preferred long-term approach is to port the FDLIBM C code to Java, which
> > I've wanted to do for a while, but has never bubbled to the top of my to-do
> > list.
> I don't know the full history of it (perhaps mjw can shed some more
> light), but as far as I'm aware, the Java StrictMath methods in GNU
> Classpath were written as exactly this: Java versions of the fdlibm
> code. Developers of Java-based VMs such as JNode and JikesRVM
> preferred these, because they didn't have to incur the cost of
> dropping out to native code.
Yes, Eric Blake implemented StrictMath in pure java back in 2002.
The discussion thread is interesting. As Eric said "converting arcane C
to Java is not an exercise for the weak-minded :)".
I believe this was originally done because of an initial
misunderstanding that StrictMath had to be pure java strictfp. So Eric
went off and just did that instead of plopping in fdlibm.
So in GNU Classpath StrictMath is pure (strictfp) java, but Math uses
VMMath intrinsics. If the VM doesn't implement those itself those fall
back on the fdlibm c code (it could also have fallen back on the
StrictMath implementation of course, but Math was written and used
fdlibm before StrictMath was implemented).
One drawback of having StrictMath in java itself is that not all VMs
actually support strictfp mode. For such VMs falling back to the fdlibm
c implementation would have been better.
More information about the hotspot-dev