GCC 17 Kills Trampolines: Nested Functions with Capture Now Trampoline-Free
Using GCC's Nested Functions with Wide Pointers and No Trampolines II
GCC 16 guarantees that nested functions not capturing parent variables avoid trampolines, and GCC 17 adds built-ins to eliminate trampolines even for capturing functions. This enables safe, efficient nested function calls with wide pointers, as demonstrated by a simple example that compiles to a single instruction.
In fact, with trampolines out of the picture, all that GCC does under the hood is to automatically transform this into the example above!
- mbeavitt
Why would someone want to use a nested function, practically speaking?
- mananaysiempre
What about your older patch where -fno-trampolines meant a function pointer could either be a code pointer or a closure (descriptor) pointer, distinguished by a tag?
- tpoacher
What's a "trampoline"?