Why doesn't HotSpot use div machine code?
Christian.Thalinger at Sun.COM
Wed Jan 13 02:16:20 PST 2010
On Wed, 2010-01-13 at 10:05 +0000, Andrew Haley wrote:
> On 01/13/2010 09:55 AM, Christian Thalinger wrote:
> > On Wed, 2009-12-23 at 22:01 +0100, Ulf Zibis wrote:
> >> Why doesn't HotSpot use div machine code?
> >> I guess this would be faster here.
> > Intel's div/idiv instructions have a very high latency and the latency
> > even varies with the input values, as you can see in Intels'
> > Optimization Reference Manual around page C-27.
> > Additionally a Java division (idiv) needs special treatment of corner
> > cases, as you can read in the JVM specification.
> Actually it doesn't, as you can see in the gcj implementation: it's
> possible to fixup the corner cases afterwards.
That's interesting. I didn't know GCJ is doing that. But actually you
have to handle the corner case, just not in-line but out-of-line. But
indeed it saves a couple of cycles.
More information about the hotspot-compiler-dev