class gc
Jon Olson
olson@mmsi.com
Mon Mar 1 15:05:00 GMT 1999
On 1999年3月01日, Per Bothner wrote:
>> hmm... what objects besides classes can gcj allocate statically? String
>> literals?
>>String literals can only be allocated statically if you do link-time
>merging (since Strings have to be interned). This is difficult
>when doing dynamic linking, but should be straight-forward when
>satic linking.
>>> Static/final members maybe?
>>Yes, those can be statically allocated. The advantage is biggest for
>arrays, but even non-arrays can win if you can "inline" some of the
>initialization as initialized static data.
>>Currently gcj does not do this, but it is planned.
>> --Per Bothner
>Cygnus Solutions bothner@cygnus.com http://www.cygnus.com/~bothner
Hmmm... Looks to me that `gcj' statically allocates static members. For
example `java.lang.System.out' corresponds to the statically allocated
data field:
_Q34java4lang6System$out
It does not, however, statically allocate the object which java.lang.System.out
references. It would be a big win to be able to allocate static/final tables in
classes such as `java/lang/Character.class'. This monster merely contains
initializations of a few static arrays, and in C or C++ would be tiny. Yet, in
Java, this compiles into mammoth run-time initialization of the arrays,
individually checking the subscripts of each element. Unfortunately, JVMs
have no way of initializing static tables ;-( It may be necessary for `gcj'
to compile java source instead of class files to properly initialize
static/final tables in an efficient way.
--
Jon Olson, Modular Mining Systems
3289 E. Hemisphere Loop
Tucson, AZ 85706
INTERNET: olson@mmsi.com
PHONE: (520)746-9127
FAX: (520)889-5790
More information about the Java
mailing list