[kaffe] Re: kjc on m68k/netbsd works.

Kiyo Inaba inaba at src.ricoh.co.jp
Tue Aug 24 06:15:38 PDT 2004


Hi Tony,

We miss you for long...

Tony Wyatt wrote:
>>> As attached patch suggests, this is a revert patch against Tony submitted
>>> several years ago. This portion is to correctly setup saved registers
>>> area (usually for d2-d7/a2-a5) when exception was raised and I have no
>>> idea why he commented it out.
>> 
>> I've CC:ed Tony, maybe he can remember why the change was necessary.
>> 
>I can't get to my notebook at the moment, but I seem to remember that it was
>because when unwinding an exception, registers were "unsaved" unnecessarily,
>which corrupted the return address (in A3?). I'll try to find out what it
>was. In any case, so much else has changed since then that my change may be
>obsolete.

OK. Let me clarify the behavior.

The major difference between jit and jit3 for m68k (or, actually it
is not m68k specific), is the register save/restore mechanism which
is invoked everytime prologue or epilogue is called. In jit3, registers
which may be destroyed in a method are stored in method prologue, just
after the 'link' instruction is invoked. So, in stack, you have stored
values just above the frame info. Because it is not so easy to detect
which registers (candidates are d2-d7/a2-a5) are used and destroyed
in one method, all of these candidate registers are stored. (10 registers,
or 40 bytes are pushed into the stack).

After this prologue, jit3 can freely use these 10 registers to keep
some 'frequently used' data for optimization (BTW, my feeling is jit3
simply allocates registers whenever it found local values...), and the
epilogue restore these registers just before 'unlk' instruction.

This is the method how each method can keep its own register set in
jit3. But, there is one big exception (in English sence). In case of
exception (in Java's sence), someone has to adjust stack pointers
reflecting to the method it is now focused. This stack pointer adjustment
can be done by two places. One is the eprologue, or the caller of
eprologue.

In the current implementation, it looks to adjust SP in eprologue.
In eprologue, it first calculate frame size by 'op_addal_ia', with
a label associated with this instruction, based on current FP (the
value for FP is adjusted by caller of eprologue), and then it escapes
register set save area for NEXT method (the method which calls the
method where we are now talking about) by using 'op_subaw_ia'.

As I said, it is too hard to detect how many registers are used,
and constant SRNR (which is defined as 10 in jit.h) is used to
keep the area for next method.

If I commented out this 'op_subaw_ia' and trace the behavior of
kjc, I noticed 'a2' register value is changed when it was returned
from 'tryBundle' method of kjc.

I am so sure that, at one time, even with this adjustment, kjc does
not work, and I guess some other fix (maybe done by Helmer) also
contributes to this problem.

In case of jit, this does not involve any local registers for variable,
and there are no problem as I describe here.

>The change was applied to 1.0.7 - I don't know how valid it is for later
>versions.

I really appreciate if you can make amigaos port work again with current
version. I hope the separation of sysdepCallMethod into each port may
help you to merge your modification.

Kiyo





More information about the kaffe mailing list