Trampolines on Harvard architecture?

Ian Lance Taylor iant@google.com
Wed Apr 10 04:24:00 GMT 2013


On Mon, Apr 8, 2013 at 6:24 PM, James Bowman <jamesb@excamera.com> wrote:
> Do any Harvard architecture targets attempt support for trampolines?
>
> It seems that some limited support is feasible, but if every other
> Harvard architecture bails on trampolines, I'll follow the pack.

On a true Harvard architecture, for which there is absolutely no way
to write data to the instruction memory, then trampolines are fairly
difficult to implement.  Most systems like that do not bother to
implement trampolines.

That said, on a true Harvard architecture you normally have control
over the ABI.  And that means that you can use a slightly unusual
representation of a function pointer: you can make a function pointer
be a pointer to a function descriptor.  Most ABIs on the PPC do this.
The descriptor contains (at least) two words: a pointer to the code in
instruction memory, and a value to load into the static chain register
before jumping to that code.  Calling a function pointer becomes a
multi-instruction sequence: load the static chain register and then
branch to the code.  With this approach, trampolines do not require
writing into instruction memory.

Ian



More information about the Gcc-help mailing list