2 ms·
I think there are several slightly different variations, but generally a trampoline is something like this pseudo-code: while (next_fn_to_call != nullptr)
by quietbritishjim 6y ago
I think there are several slightly different variations, but generally a trampoline is something like this pseudo-code:
while (next_fn_to_call != nullptr) {
next_fn_to_call = next_fn_to_call()
}
So each function potentially wants to call a new function once it's done, but you don't want to blow the stack (or maybe use a stack at all) so it returns that function (pointer) rather than calling it. Then you need a little loop to call the return value: that's your trampoline.
The article is potentially a bit lower level given it's talking about things down at the CPU level, but I imagine its a vaguely connected idea.