[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Math patch
From: |
Dalibor Topic |
Subject: |
Re: Math patch |
Date: |
Fri, 28 Feb 2003 00:50:36 -0800 (PST) |
hi Chris,
--- Chris Gray <address@hidden> wrote:
> On Thu, 27 Feb 2003, David P Grove wrote:
>
> > > [CG]
> > > What we really need is
> > > #define isNaN(a) ((a) != (a))
> >
> > I thought we had this already because the
> classpath Double.isNaN is defined
> > as:
> >
> > /**
> > * Return <code>true</code> if the
> <code>double</code> has the same
> > * value as <code>NaN</code>, otherwise return
> <code>false</code>.
> > *
> > * @param v the <code>double</code> to compare
> > * @return whether the argument is
> <code>NaN</code>.
> > */
> > public static boolean isNaN(double v)
> > {
> > // This works since NaN != NaN is the only
> reflexive inequality
> > // comparison which returns true.
> > return v != v;
> > }
> >
> > So, it seems to me that using isNaN should be
> preferred as it is clearer
> > and will have no runtime cost (any JIT should
> inline a trivial static
> > method like this).
>
> OTOH JIT *is* a runtime cost. In principle the
> static method could be
> inlined by a static analysis tool, but I don't
> believe a bytecode compiler
> is allowed to do it - it should leave open the
> possibility that the code
> will be deployed against a different version of
> java.lang.Math to that
> against which it was compiled. SFAIK the only
> legitimate inlining a
> bytecode compiler can do is for static final
> constants.
I doubt even that is safe, as
http://java.sun.com/j2se/1.4/docs/api/java/awt/event/MouseEvent.html#MOUSE_LAST
this field surely changed between the java releases
when they introduced mouse wheel support ;)
In my opinion, the safest place to do constant
inlining is in a class loader, when you know that
which specific implementation you're going to 'link'
to. Method inlining is possible during class loading
as well, but would probably require a good heuristic
to avoid a huge increase in code size.
I intend to experiment with that in kaffe, but I'm too
busy merging stuff in to do much development at the
moment ;)
cheers,
dalibor topic
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/