[kaffe] About ARM JIT's Exception Handling in Kaffe

Bytecode bytecode at tom.com
Wed Oct 20 09:27:40 PDT 2004


I'm porting Kaffe to an ARM-like processor. Now JIT works OK.  I find an
error in JIT for ARM in my porting work.

Kaffe's JIT uses stack trace to deal with exception handling. The stack
frame's structure is "PC LR SP FP ..." for ARM. 

The stack trace structure is as followed.
throwExternalException in exception.c
-->buildStackTrace(0) in stackTrace.c
-->JITed Java method
-->caller ...

If an exception occurs the Kaffe will build the first frame(It is
throwExternalException's frame) and uses FP to get the caller's frame(It is
buildStackTrace's frame). Then Kafee will build Java method's frame and
search matched handler.  The progress continues until Kaffe find a matched
handler.

You can find that the first two frame is indeed useless. We can remove the
construction of the two functions' frames in buildStackTrace().

But if we use GCC's O2 option to compile Kaffe, GCC will optimize the
prologue of the two functions (throwExternalException and buildStackTrace)
and thus destroy the stack trace structure. You can use GCC -O2 -S to
compile some programs and find that FP register disappears in the prologue
of the function.
(I trace the error for several days.  I am cracy:). Finally I disassembled
the libkaffe.so and read the assemble code of the two functions. I find the
bug!)

So we must not use O2 option to compile exception.c and stackTrace.c. 

Any suggestion is welcome.











More information about the kaffe mailing list