This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: class initialization
- To: tromey at cygnus dot com
- Subject: Re: class initialization
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: Mon, 01 May 2000 21:17:49 +1200
- CC: Java Discuss List <java-discuss at sourceware dot cygnus dot com>
- References: <87ya5xssrz.fsf@cygnus.com>
Tom Tromey wrote:
> A while back Anthony changed the compiler to keep track of whether a
> class was already initialized in a given method. This lets us
> eliminate some initializations statically, at least when optimization
> is enabled.
>
> Today it occurred to me that we currently initialize this local flag
> as `0' while we could actually initialize it with `class.state >= 12'.
> This is a load, a compare, and a branch per generated call to
> _Jv_InitClass. Is this worth doing? When would it hurt?
I can't see how this could be anything but good. A class actually needing
to be initialized is the (very) uncommon case, and checking class.state
is the first thing _Jv_InitClass does anyway. Combined with a
__builtin_expect-style trick (to straight-line the common case), I think
we'd see a respectable speedup!
regards
[ bryce ]