Heuristics for JIT/interpretation

Alexandre Oliva oliva at dcc.unicamp.br
Wed Sep 30 21:55:28 PDT 1998


Senthil Kumar <skumars at earthlink.net> writes:

> I was wondering what kind of heuristics could be employed
> to determine if a method should be JIT or interpreted?

One possible heuristics is to always JIT compile a method if its
bytecode is larger than a certain constant; this constant should be
made target-dependent, but there should be a reasonably large default.
It would also be nice to scan the bytecode of a method for gotos with
negative offsets, since we don't want to interpret methods that
contain loops.  If we could estimate the cost of a loop and guess the
number of iterations in advance, we could improve the heuristics, but
this might be too costly to bring any benefit.

I had also thought that class initializers should never be JIT
compiled.  However, some classes might benefit from JIT compilation if
they had large loops within class initializers.  Deciding how large
that should be is an open problem.

Another approach would be to start a JIT compiler as a separate
thread, and arrange that, whenever a thread needs a method to be
JIT-compiled, it adds the method to a queue and signals the JIT
compiler thread.  Then, the requester thread could either wait for the 
method to be compiled or proceed to interpret it.

> Special thanks to Alexandre Oliva for the solution.

You're welcome :-)

-- 
Alexandre Oliva
mailto:oliva at dcc.unicamp.br mailto:aoliva at acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



More information about the kaffe mailing list