Explanation for trampolines

Alexandre Oliva oliva at dcc.unicamp.br
Mon Sep 14 01:40:56 PDT 1998

Senthil Kumar <skumars at earthlink.net> writes:

> Can anyone give me a brief explanation of this
> trampoline stuff that is used in kaffe.

Trampolines are a useful concept for setting a pointer to a function
that will be generated on demand.  When Kaffe (JIT) loads a class, it
creates a trampoline for each method.  Whenever this trampoline is
invoked, it calls a regular function that finds out which method the
trampoline refers to, and invokes the JIT compiler to generate the
method.  Then, when the compiler returns, some processor-dependent
magic obtains the address of the newly compiled method and invokes it, 
as if it had been invoked in the first place.

It's a nice trick that avoids having to check whether a method has
been compiled already every time you have to call it, and does not
require you to tweak with page faults.

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

More information about the kaffe mailing list