This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Socket timeout patch


Bryce McKinlay wrote:
> 
> >>but in this case the assignments are redundant and should be removed
> >>(initializing to zero or null is not neccessary in Java, and it causes
> >>GCJ to generate redundant finit code).
> >>
> >
> >Maybe, but it also makes clear what is going on. The variables are
> >cache variables, Someone reading the related methods might not
> >understand them.
> >
> 
> I agree that it makes the code clearer in some cases to explicitly
> specify it, but it does cause GCJ to generate less efficient code.
> Perhaps we can fix GCJ to remove/ignore the redundant assignment though.
> Do other bytecode compilers generate field initializer code for null and
> zero initializations?

Yes, at the moment jikes emits null and zero initializations for both
class (static) and instance fields.

You may also be interested in this comment from JVMS 2.17.6 (step 4 in
initializing instances):

"(In some early implementations, the compiler incorrectly omitted the
code to initialize a field if the field initializer expression was a
constant expression whose value was equal to the default initialization
value for its type. This was a bug.)"

Of course, that statement applies to bytecode emission; when compiling
to native code, I see no problem in omitting initializations if it is to
the default value. And the above comment only applied to instance
fields; to my knowledge Sun has never forbidden omitting initializers
for class fields.


-- 
This signature intentionally left boring.

Eric Blake             ebb9@email.byu.edu
  BYU student, free software programmer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]