On Sat, 17 Jul 2004 02:31:35 +0900 (JST)
Kiyo Inaba <[EMAIL PROTECTED]> wrote:

> I wrote:
> >I checkouted your version. And it works (which I mean, the compiled
> >version stops at the same place as mine) on m68k/netbsd.
> 
> I continuing to debug jit3 for m68k. And if there are someone
> who has some experience to debug jit3, I appreciate to get
> some hint...
> 
> The compiled code of  'Runtime/loadLibrary' contains a funny
> code segment as below.
> 
> 0x28da14:       movel %a4@(8),%d0
> 0x28da18:       cmpl %d0,%d4
> 0x28da1a:       movel %d0,%fp@(-44)
> 0x28da1e:       bcsl 0x28da2a
> 0x28da24:       jsr 0x2b452 <soft_badarrayindex>        ; !!!!!
> 0x28da2a:       moveal %fp@(-32),%a0
> 
> Of course this is m68k asm and usual people don't want to read
> them, but the core part is simple. At 0x28da1e, it checks a
> flag and try to skip next instruction (subroutine call to
> 'soft_badarrayindex'). But, on m68k 'move' instruction changes
> its flag, and that's why soft_badarrayindex is called :-<

In order to check the array index, the jitter uses the
cbranch_offset_int instruction. Since the m68k backend
doesn't provide this instruction, the jitter uses the
following instructions instead:

load_offset_int(tmp, src, offs)
cmp_int(dst, src, tmp)
branch(l, gt)
call_soft(soft_badarrayindex)

Therefore, %d0 contains the value of the temp slot tmp
and the incorrect movel looks like %d0 is spilled onto
the stack in order to update the contents of the temp
slot on the stack, which is done between the cmp_int
and the branch.

Since the jitter has to make sure that an exception
handler can access the current value of the different
slots, it regularly spills the registers of the different
slots onto the stack. This is the type of spill that
happens between two instructions, just like the one
described earlier.

However, since temp slots are only used in order to
translate a single bytecode instruction, this type of
spill is not necessary for temp slots. Therefore I've
attached a patch that prevents this type of spill for
temp slots.

HTH,
Helmer 
Index: kaffe/kaffevm/jit3/machine.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/jit3/machine.c,v
retrieving revision 1.54
diff -u -r1.54 machine.c
--- kaffe/kaffevm/jit3/machine.c        17 Jul 2004 07:57:29 -0000      1.54
+++ kaffe/kaffevm/jit3/machine.c        17 Jul 2004 14:28:52 -0000
@@ -838,7 +838,7 @@
                                         * in case its used in a subsequent
                                         * basic block.
                                         */
-                                       if( t->jflags.ANY )
+                                       if( t->jflags.ANY && (t->u[i].slot<tempinfo))
                                        {
                                                spillAndUpdate(t->u[i].slot,
                                                               true);
_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to