Use of pointer casts in the interpreter

Kresten Krab Thorup krab@gnu.org
Mon Aug 9 00:12:00 GMT 1999


Per Bothner <per@bothner.com> writes:

> ...  I suggest:
> 
> typedef union {
>   jint i;
>   jfloat f;
>   jint ia[1];  // Half of _Jv_word2.
>   void* p;
>   _Jv_Field *fld;
>   ...  
> } _Jv_word;
> 
> typedef union {
>   jint ia[2];
>   jlong l;
>   jdouble d;
> } _Jv_word2;
> 
> class _Jv_InterpMethodInvocation {
>   _Jv_InterpMethod *running;
>   _Jv_word *sp;
>   ...
> };
> 
> #define PUSHA(V)  ((sp++)->p = (V))
> #define PUSHI(V)  ((sp++)->i = (V))
> #define PUSHF(V)  ((sp++)->f = (V))
> #define PUSHL(V)  ({ _Jv_word2 word2_tmp;  \
>    word2_tmp.l = (V); (sp++)->ia[0] = word2_tmp.ia[0]; (sp++)->ia[0] = word2_tmp.ia[1]; })

Sounds fine with me.  I'd suggest a slight modificaton, that is that
this union (or collecton of unions) is unified with the `raw format'
in ffi, which will stream line the ffi-interface.  That is, when a
integer value is "on the stack" it is promoted, but "demoted" to jint
when popped off.  This of cause assumes that the promoted integer size
is at least 32 bits. 

I'll implement this right away, and send you a patch.  I still don't
have write access to the repository...  Anthony?

ALSO: This _Jv_Word type should be the type of elements in the
constant pool.   This may require a compiler modification, dunno?

BTW Per, have you tried compiling resolve.cc, interpret.cc and
defineclass.cc without optimization?  At one point, I ran into a
problem thet I thought was this aliasing thing, but it turned out to
be something else.

Admittedly, the interpreter is pretty hard to debug, so I'm willing to
help with specific stuff until we're more stable.  But it's hard to
debug the interpreter using someone else's class files, which I
learned while getting antlr up and running.  Per, if you have
something concrete that I can try to run, please send it to me.

-- 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


More information about the Java mailing list