This is the mail archive of the java-patches@sourceware.cygnus.com 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]

Re: Use of pointer casts in the interpreter


Per Bothner <per@bothner.com> writes:

> Kresten Krab Thorup <krab@gnu.org> writes:
> >  #define PUSHA(V)  \
> > - ({ jobject __v=(V); *(jobject*)sp++ = __v; })
> > + ({ jobject __v=(V); (sp++)->o = __v; })
> 
> I'm curious as to why you use the temporary variable __v.
> To me it seems like nothing but overhead (more verbose, harder to
> read, more work for the compiler, more variables to emit in
> the debugging symbols).

I just did this to make them more robust; there are some cases where
the argument to PUSH involves the stack itself, and then the order of
those pre- and post increment opeations might be wrong.  

But maybe you can tell me this, is

	*p++ = *--p;

equivalent to

        tmp = *--p;
        *p++ = tmp;

If it is, then clearly the extra local is not necessary.   

-- Kresten

 Kresten Krab Thorup, Ph.D. Candidate
 c/o Yonezawa Laboratory
 Department of Information Science   
 The University of Tokyo             
 7-3-1 Hongo, Bunkyo-ku, Tokyo 113 Japan
 Fax: +81-(0)3-5689-4365	 
 Phone: +81-(0)3-5841-4118
 Mobile: +81-(0)90-3693-5715

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