<s>
In	O
computer	B-General_Concept
programming	I-General_Concept
,	O
the	O
word	O
trampoline	B-General_Concept
has	O
a	O
number	O
of	O
meanings	O
,	O
and	O
is	O
generally	O
associated	O
with	O
jump	O
instructions	O
(	O
i.e.	O
</s>
<s>
Trampolines	B-General_Concept
(	O
sometimes	O
referred	O
to	O
as	O
indirect	B-Language
jump	I-Language
vectors	O
)	O
are	O
memory	O
locations	O
holding	O
addresses	O
pointing	O
to	O
interrupt	B-Application
service	O
routines	O
,	O
I/O	B-General_Concept
routines	O
,	O
etc	O
.	O
</s>
<s>
Execution	O
jumps	O
into	O
the	O
trampoline	B-General_Concept
and	O
then	O
immediately	O
jumps	O
out	O
,	O
or	O
bounces	O
,	O
hence	O
the	O
term	O
trampoline	B-General_Concept
.	O
</s>
<s>
Trampoline	B-General_Concept
can	O
be	O
used	O
to	O
overcome	O
the	O
limitations	O
imposed	O
by	O
a	O
central	B-General_Concept
processing	I-General_Concept
unit	I-General_Concept
(	O
CPU	O
)	O
architecture	O
that	O
expects	O
to	O
always	O
find	O
vectors	O
in	O
fixed	O
locations	O
.	O
</s>
<s>
When	O
an	O
operating	B-General_Concept
system	I-General_Concept
is	O
booted	O
on	O
a	O
symmetric	B-Operating_System
multiprocessing	I-Operating_System
(	O
SMP	O
)	O
machine	O
,	O
only	O
one	O
processor	O
,	O
the	O
bootstrap	O
processor	O
,	O
will	O
be	O
active	O
.	O
</s>
<s>
After	O
the	O
operating	B-General_Concept
system	I-General_Concept
has	O
configured	O
itself	O
,	O
it	O
will	O
instruct	O
the	O
other	O
processors	O
to	O
jump	O
to	O
a	O
piece	O
of	O
trampoline	B-General_Concept
code	O
that	O
will	O
initialize	O
the	O
processors	O
and	O
wait	O
for	O
the	O
operating	B-General_Concept
system	I-General_Concept
to	O
start	O
scheduling	O
threads	O
on	O
them	O
.	O
</s>
<s>
As	O
used	O
in	O
some	O
Lisp	B-Language
implementations	O
,	O
a	O
trampoline	B-General_Concept
is	O
a	O
loop	O
that	O
iteratively	O
invokes	O
thunk-returning	O
functions	O
(	O
continuation-passing	B-Application
style	I-Application
)	O
.	O
</s>
<s>
A	O
single	O
trampoline	B-General_Concept
suffices	O
to	O
express	O
all	O
control	O
transfers	O
of	O
a	O
program	O
;	O
a	O
program	O
so	O
expressed	O
is	O
trampolined	O
,	O
or	O
in	O
trampolined	O
style	O
;	O
converting	O
a	O
program	O
to	O
trampolined	O
style	O
is	O
trampolining	B-General_Concept
.	O
</s>
<s>
Programmers	O
can	O
use	O
trampolined	O
functions	O
to	O
implement	O
tail-recursive	B-Language
function	I-Language
calls	O
in	O
stack-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Continuation-passing	B-Application
style	I-Application
is	O
a	O
popular	O
intermediate	O
format	O
for	O
compilers	B-Language
of	O
functional	O
languages	O
,	O
because	O
many	O
control	O
flow	O
constructs	O
can	O
be	O
elegantly	O
expressed	O
and	O
tail	B-Language
call	I-Language
optimization	I-Language
is	O
easy	O
.	O
</s>
<s>
When	O
compiling	B-Language
to	O
a	O
language	O
without	O
optimized	O
tail	B-Language
calls	I-Language
,	O
one	O
can	O
avoid	O
stack	O
growth	O
via	O
a	O
technique	O
called	O
trampolining	B-General_Concept
.	O
</s>
<s>
The	O
idea	O
is	O
to	O
not	O
make	O
the	O
final	O
continuation	O
call	O
inside	O
the	O
function	O
,	O
but	O
to	O
exit	O
and	O
to	O
return	O
the	O
continuation	O
to	O
a	O
trampoline	B-General_Concept
.	O
</s>
<s>
That	O
trampoline	B-General_Concept
is	O
simply	O
a	O
loop	O
that	O
invokes	O
the	O
returned	O
continuations	O
.	O
</s>
<s>
In	O
Java	B-Language
,	O
trampoline	B-General_Concept
refers	O
to	O
using	O
reflection	B-Language
to	O
avoid	O
using	O
inner	O
classes	O
,	O
for	O
example	O
in	O
event	O
listeners	O
.	O
</s>
<s>
The	O
time	O
overhead	O
of	O
a	O
reflection	B-Language
call	O
is	O
traded	O
for	O
the	O
space	O
overhead	O
of	O
an	O
inner	B-Language
class	I-Language
.	O
</s>
<s>
Trampolines	B-General_Concept
in	O
Java	B-Language
usually	O
involve	O
the	O
creation	O
of	O
a	O
GenericListener	O
to	O
pass	O
events	O
to	O
an	O
outer	O
class	O
.	O
</s>
<s>
In	O
Mono	O
Runtime	O
,	O
trampolines	B-General_Concept
are	O
small	O
,	O
hand-written	O
pieces	O
of	O
assembly	O
code	O
used	O
to	O
perform	O
various	O
tasks	O
.	O
</s>
<s>
When	O
interfacing	O
pieces	O
of	O
code	O
with	O
incompatible	O
calling	O
conventions	O
,	O
a	O
trampoline	B-General_Concept
is	O
used	O
to	O
convert	O
the	O
caller	O
's	O
convention	O
into	O
the	O
callee	O
's	O
convention	O
.	O
</s>
<s>
In	O
embedded	B-Architecture
systems	I-Architecture
,	O
trampolines	B-General_Concept
are	O
short	O
snippets	O
of	O
code	O
that	O
start	O
up	O
other	O
snippets	O
of	O
code	O
.	O
</s>
<s>
For	O
example	O
,	O
rather	O
than	O
write	O
interrupt	B-Application
handlers	O
entirely	O
in	O
assembly	O
language	O
,	O
another	O
option	O
is	O
to	O
write	O
interrupt	B-Application
handlers	O
mostly	O
in	O
C	B-Language
,	O
and	O
use	O
a	O
short	O
trampoline	B-General_Concept
to	O
convert	O
the	O
assembly-language	O
interrupt	B-Application
calling	O
convention	O
into	O
the	O
C	B-Language
calling	O
convention	O
.	O
</s>
<s>
When	O
passing	O
a	O
callback	O
to	O
a	O
system	O
that	O
expects	O
to	O
call	O
a	O
C	B-Language
function	O
,	O
but	O
one	O
wants	O
it	O
to	O
execute	O
the	O
method	O
of	O
a	O
particular	O
instance	O
of	O
a	O
class	O
written	O
in	O
C++	B-Language
,	O
one	O
uses	O
a	O
short	O
trampoline	B-General_Concept
to	O
convert	O
the	O
C	B-Language
function-calling	O
convention	O
to	O
the	O
C++	B-Language
method-calling	O
convention	O
.	O
</s>
<s>
One	O
way	O
of	O
writing	O
such	O
a	O
trampoline	B-General_Concept
is	O
to	O
use	O
a	O
thunk	B-Application
.	O
</s>
<s>
In	O
Objective-C	B-Language
,	O
a	O
trampoline	B-General_Concept
is	O
an	O
object	O
returned	O
by	O
a	O
method	O
that	O
captures	O
and	O
reifies	O
all	O
messages	O
sent	O
to	O
it	O
and	O
then	O
"	O
bounces	O
"	O
those	O
messages	O
on	O
to	O
another	O
object	O
,	O
for	O
example	O
in	O
higher	B-Application
order	I-Application
messaging	I-Application
.	O
</s>
<s>
In	O
the	O
GCC	B-Application
compiler	I-Application
,	O
trampoline	B-General_Concept
refers	O
to	O
a	O
technique	O
for	O
implementing	O
pointers	O
to	O
nested	O
functions	O
.	O
</s>
<s>
The	O
trampoline	B-General_Concept
is	O
a	O
small	O
piece	O
of	O
code	O
which	O
is	O
constructed	O
on	O
the	O
fly	O
on	O
the	O
stack	O
when	O
the	O
address	O
of	O
a	O
nested	O
function	O
is	O
taken	O
.	O
</s>
<s>
The	O
trampoline	B-General_Concept
sets	O
up	O
the	O
static	O
link	O
pointer	O
,	O
which	O
allows	O
the	O
nested	O
function	O
to	O
access	O
local	O
variables	O
of	O
the	O
enclosing	O
function	O
.	O
</s>
<s>
The	O
function	O
pointer	O
is	O
then	O
simply	O
the	O
address	O
of	O
the	O
trampoline	B-General_Concept
.	O
</s>
<s>
In	O
the	O
esoteric	O
programming	O
language	O
Befunge	B-Language
,	O
a	O
trampoline	B-General_Concept
is	O
an	O
instruction	O
to	O
skip	O
the	O
next	O
cell	O
in	O
the	O
control	O
flow	O
.	O
</s>
<s>
Some	O
implementations	O
of	O
trampolines	B-General_Concept
cause	O
a	O
loss	O
of	O
no-execute	B-General_Concept
stacks	I-General_Concept
(	O
NX	O
stack	O
)	O
.	O
</s>
<s>
In	O
the	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
(	O
GCC	B-Application
)	O
in	O
particular	O
,	O
a	O
nested	O
function	O
builds	O
a	O
trampoline	B-General_Concept
on	O
the	O
stack	O
at	O
runtime	O
,	O
and	O
then	O
calls	O
the	O
nested	O
function	O
through	O
the	O
data	O
on	O
stack	O
.	O
</s>
<s>
The	O
trampoline	B-General_Concept
requires	O
the	O
stack	O
to	O
be	O
executable	O
.	O
</s>
<s>
No-execute	B-General_Concept
stacks	I-General_Concept
and	O
nested	O
functions	O
are	O
mutually	O
exclusive	O
under	O
GCC	B-Application
.	O
</s>
<s>
GCC	B-Application
offers	O
the	O
-Wtrampolines	O
warning	O
to	O
alert	O
of	O
the	O
condition	O
.	O
</s>
<s>
Software	O
engineered	O
using	O
secure	B-Application
development	I-Application
lifecycle	I-Application
often	O
do	O
not	O
allow	O
the	O
use	O
of	O
nested	O
functions	O
due	O
to	O
the	O
loss	O
of	O
NX	O
stacks	O
.	O
</s>
