Trampoline (computing)
This article may need to be rewritten to comply with Wikipedia's quality standards. (June 2009) |
This article may meet Wikipedia's criteria for speedy deletion as a very short article lacking sufficient context to identify the subject of the article. See CSD A1.
If this article does not meet the criteria for speedy deletion, or you intend to fix it, please remove this notice, but do not remove this notice from pages that you have created yourself. If you created this page and you disagree with the given reason for deletion, you can click the button below and leave a message explaining why you believe it should not be deleted. You can also visit the talk page to check if you have received a response to your message. Note that this article may be deleted at any time if it unquestionably meets the speedy deletion criteria, or if an explanation posted to the talk page is found to be insufficient.
Note to administrators: this article has content on its talk page which should be checked before deletion. Administrators: check links, talk, history (last), and logs before deletion. Consider checking Google.This page was last edited by Cymbelmineer (contribs | logs) at 11:02, 12 October 2010 (UTC) (14 years ago) |
,
This article may meet Wikipedia's criteria for speedy deletion as a very short article lacking sufficient context to identify the subject of the article. See CSD A1.
If this article does not meet the criteria for speedy deletion, or you intend to fix it, please remove this notice, but do not remove this notice from pages that you have created yourself. If you created this page and you disagree with the given reason for deletion, you can click the button below and leave a message explaining why you believe it should not be deleted. You can also visit the talk page to check if you have received a response to your message. Note that this article may be deleted at any time if it unquestionably meets the speedy deletion criteria, or if an explanation posted to the talk page is found to be insufficient.
Note to administrators: this article has content on its talk page which should be checked before deletion. Administrators: check links, talk, history (last), and logs before deletion. Consider checking Google.This page was last edited by Cymbelmineer (contribs | logs) at 11:02, 12 October 2010 (UTC) (14 years ago) |
In computer programming, the word trampoline has a number of meanings, and is generally associated with jumps (i.e., moving to different code paths).
- Trampolines (sometimes referred to as indirect jump vectors) are memory locations holding addresses pointing to interrupt service routines, I/O routines, etc. Execution jumps into the trampoline and then immediately jumps out, or bounces, hence the term trampoline. They have many uses:
- Trampoline can be used to overcome the limitations imposed by a CPU architecture that expects to always find vectors in fixed locations.
- 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.
- When interfacing pieces of code with incompatible calling conventions, a trampoline is used to convert the caller's convention into the callee's convention.
- In embedded systems, trampolines are short snippets of code that start up other snippets of code. For example, rather than write interrupt handlers entirely in assembly language, another option is to write interrupt handlers mostly in C, and use a short trampoline to convert the assembly-language interrupt calling convention into the C calling convention. [1]
- When passing a Callback to a system that expects to call a C function, but one wants it to execute the method function of a particular instance of an object written in C++, one uses a short trampoline to convert the C function-calling convention to the C++ method-calling convention. One method of writing such a trampoline is to use a thunk.[2] Another method is to use a generic listener.[3]
- In the esoteric programming language Befunge, a trampoline is an instruction to skip the next cell in the control flow.
- In Objective-C, a trampoline is an object returned by a method that acts like a delegate, "bouncing" a message on to another object.
- 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.[4][5][6]
- Used in some LISP implementations, a trampoline is a loop that iteratively invokes thunk-returning functions (continuation-passing style). 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.[7]
- In Java, a trampoline refers to using reflection to avoid using inner classes, for example in event listeners. The time overhead of a reflection call is traded for the space overhead of an inner class. Trampolines in Java usually involve the creation of a GenericListener to pass events to an outer class.[8]
- Trampoline! is also an extension to the Tcl/Tk script programming language to get PDF files from the canvas widget, an interface component of the Tk graphical toolkit that provides structured graphics.
References
- ^ "Trampolines for Embedded Systems: Minimizing interrupt handlers latency", Joseph M. Link.
- ^ "Thunking in Win32 with C++", Einar Otto Stangvik
- ^ "Trampolines in Java", Hans Muller
- ^ GCC internals: Trampolines for Nested Functions
- ^ GCC nested function usage
- ^ Lexical Closures for C++
- ^ [1]
- ^ "Trampolines in Java", Hans Muller