Initialization test
Jonathan Brumley
jbrumley at objectspace.com
Thu Oct 29 08:38:19 PST 1998
That's an interesting point about compiled code taking a hit.
Perhaps the solution (for you JIT writers) is to use interpreter code until
the static initializer for the class is run, and afterwards, switch over to
compiled code.
-- Jonathan
> -----Original Message-----
> From: Godmar Back [SMTP:gback at cs.utah.edu]
> Sent: Thursday, October 29, 1998 12:31 AM
> To: kaffe at rufus.w3.org
> Cc: max at immsp.kiev.ua; abies at pg.gda.pl; kaffe at kaffe.org;
> japhar at hungry.com; tya-hackers at sax.sax.de
> Subject: Re: Initialization test
>
>
> Kaffe and the JDK pass the tests, and the tests are correct.
> As for tests 1 and 3: no method or constructor of these classes is ever
> invoked, and no non-constant variable is ever accessed, hence the classes
> are not initialized.
>
> Essentially, the initialization behavior does not depend on all possible
> paths that could be taken, but only on those actually taken. Clearly,
> compiled code takes a hit here (gcj, for instance, always puts a call
> to the static class initializer before any static access). Kaffe
> inserts a softcall_initialise_class if needed.
>
> The relevant quote for this behavior is given by John:
> >
> > Here are the initialization rules as I read them, reading from both
> > examples and text in JLS 12.4.1: static initializers should be called
> when
> > any constructor or method (static or otherwise) in the class is invoked,
> or
> > when a non-constant variable (static or otherwise) that is *not*
> constant is
> > used. By constant, it means final, static, and initialized from the
> pool of
> > compile-time constants. There is some reason that makes it so that this
> > variable will *always* have its initialized value and not the
> uninitialized
> > one.
> >
>
> There is no argument as to test 2.
>
> It is hard to see how to make a JVM fail test 4, given that the main
> function of InitClass does not contain any reference to Class 4 at
> all. The access to the final static variable is compiled into an
> ICONST_5 instruction.
>
> - Godmar
More information about the kaffe
mailing list