Kiyo Inaba wrote:
| >There are two problems with this code:
| >
| >1. Registers d2-d7/a2-a5 are clobbered by JIT-generated code, but are not saved
| > here. GCC puts automatic variables in registers, and expects them to
| > survive function calls. In particular, the `success' variable tested at
| > line 464 of classMethod.c is clobbered. This is why the static class
| > constructor of java.lang.Runtime() "fails".
|
| True. That is the main problem why pizza does not work. But the
| work around is simple. Just compile everything without any
| optimization. I've posted a progress report to the Kaffe porting
| database.
|
| >2. At no point is the location of the arguments indicated to the JIT code.
| > We build an argument vector in the automatic variable `extraargs', but
| > we don't pass its address to the called code, so I'm not sure how the code
| > can ever find it.
|
| Well...
| You are right that 'extraargs' is not passed, EXPLICITLY...
| The magic is, when a function is called via 'sysdepCallMethod',
| the callee assumes "arguments are on stack". On the other hand,
| 'sysdepCallMethod' macro does not push any arguments on stack,
| explicitly. So the callee fetches the arguments from the closest
| local variables. In this case, it is 'extraargs' array, built
| on top of stack. I stole this idea from some other port (may
| be i386) and works fine for m68k.
|
| # This magic is fully CPU and compiler dependent.
It also assumes that the arguments are located at a well-known offset from
the top of the stack. This is not true if you save and restore d2-d7/a2-a5
as I mention above.
Since compiling with optimization off is not a solution, IMHO, I will have
to go back and rewrite the invoker if I cannot otherwise get it to work.
I find this code a bit too "cute" for my tastes. May I suggest that when
someone makes use of the stack layout like this, that at least a comment is
put in the code, so that I don't break anything later?