Ãyvind Harboe <[EMAIL PROTECTED]> writes:

> - Many backends do not support trampolines. Are trampolines 
>   something that is ultimately being added to the backends?

As and if the port maintainers care, I think.

> - Do (theoretical?) alternatives to trampolines exist?
>   I.e. something that does not generate code runtime.

So, first off, let me point out that trampolines are only used if you
take a pointer to a nested function.  Many uses of nested functions
(including those in languages where they are natural, e.g. Pascal,
Ada) don't need to do that.

Now, if the routine that calls the function pointer is aware that it
is calling a nested function, the trampoline can be avoided.  The
typical technique is to make the pointer to the nested function be a
2-tuple of the actual code address and the value to load into the
static chain register.  The problem with this is, the caller generally
doesn't know that, so you would have to make all function pointers be
like that.  And then you run up against the problem that in C there
are strong practical constraints against making function pointers be
bigger than data pointers (tho the language would permit it).  It's
not at all out of the question for Ada, though, and I recall seeing
one of the Ada maintainers mention that they were interested in moving
to that technique.

Some architecture ABIs also allow clever tricks.  For example, on ia64
the on-stack trampoline is just four pointers, no executable code
(there is also a helper routine in libgcc).  A similar technique is
usable with some PowerPC OSes.

zw

Reply via email to