Initialization of static data in Java
Per Bothner
bothner@cygnus.com
Thu Nov 19 08:20:00 GMT 1998
> One seriously weakness in Java is its ability to initialize static
> data tables. This is primarily because the VM does not have the
> ability to directly reference memory created by the compiler.
We definitely intend to have gcj generate generate good code for
array initializer in Java source. There are some subtle points
to keep in mind, theoug, such as when the atable can actually
be static. Note it can only be static it it is final - but
final does not imply read-only! There are also garbage
collection implications for arrays containing references.
> I would guess that once gcj can actually compile source code that
> these Java pregnancies would go away, but it would be nice if gcj
> could collect up all the constants between the `newarray byte' and the
> `putstatic' and do them within the compiler, effectively emiting the
> same byte table that a C++ compiler would create???
While we will generate good code when given array initializer in
Java source (though not yet), I cannot promise the same when
compiling Java bytecodes. That requires some extra analysis.
The analysis is probably not that difficult, but it is lower
priority, and so will probably be written later.
--Per Bothner
Cygnus Solutions bothner@cygnus.com http://www.cygnus.com/~bothner
More information about the Java
mailing list