Trampoline (computers)
From Free net encyclopedia
In computer programming, the word "trampoline" has a number of meanings, associated with jumps.
- Trampolines (sometimes referred to as indirect jump vectors) are memory locations holding addresses pointing to interrupt service routines, I/O routines, etc. The idea of "bouncing" off a trampoline is to overcome the limitations imposed by a CPU architecture that expects to always find vectors in fixed locations.
- In the GCC compiler, trampoline refers to a technique for implementing pointers to nested functions. The trampoline is a small piece of code which is constructed on the fly on the stack when the address of a nested function is taken. The trampoline sets up the static link pointer, which allows the nested function to access local variables of the enclosing functions. The function pointer is then simply the address of the trampoline. This avoids having to use "fat" function pointers for nested functions which carry both the code address and the static link.
- Used in some LISP implementations, a trampoline is a loop that iteratively invokes thunk-returning functions. A single trampoline is sufficient to express all control transfers of a program; a program so expressed is trampolined or in "trampolined style"; converting a program to trampolined style is trampolining. Trampolined functions can be used to implement tail recursive function calls in stack-oriented languages.[1]
- When an operating system is booted on an SMP machine only one processor, the boot-strap processor, will be active. After the operating system has configured itself it will instruct the other processors to jump to a piece of trampoline code which will initialize the processors and wait for the operating system to start scheduling threads on them.
- In the esoteric programming language Befunge, a trampoline is an instruction to skip the next cell in the control flow.
- In Java, a trampoline refers to using reflection to save the overhead of inner classes, for example in event listeners. The overhead of a single reflection call is negligible compared to that of inner classes. Trampolines in Java usually involve the creation of a GenericListener to pass events to an outer class.
[edit]