Trampoline (computers)

Trampoline (computers)

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. See [http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html GCC internals: Trampolines for Nested Functions] , [http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html GCC nested function usage] and the mentioned paper, [http://people.debian.org/~aaronl/Usenix88-lexic.pdf Lexical Closures for C++] .

* 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. [http://home.pipeline.com/~hbaker1/CheneyMTA.html]

* 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 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.

* In Objective-C, a trampoline is an object returned by a method that acts like a delegate, "bouncing" a message on to another object.

* 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". 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. See [http://ddj.com/showArticle.jhtml?documentID=ddj0109h "Trampolines for Embedded Systems: Minimizing interrupt handlers latency"] by Joseph M. Link.
** 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 -- see [http://einaros.blogspot.com/2006/08/thunking-in-win32.html "Thunking in Win32 with C++"] by Einar Otto Stangvik. Another method is to use a "generic listener" -- see [http://java.sun.com/products/jfc/tsc/articles/generic-listener/index.html "Trampolines in Java"] by Hans Muller.
* [http://trampoline.sourceforge.net/ 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 tookit that provides structured graphics.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Trampoline (disambiguation) — A trampoline is a gymnastics and recreation device.Trampoline may also refer to:* Trampoline (computers) * Trampoline (multihulls), a part of multihull sailboats * Trampoline (horse) (1825–?), thoroughbred racehorseIn music:* Trampoline Records,… …   Wikipedia

  • Thunk — The word thunk has at least three related meanings in computer science. A thunk may be: * a piece of code to perform a delayed computation (similar to a closure) * a feature of some virtual function table implementations (similar to a wrapper… …   Wikipedia

  • Platform game — This article is about the computer and video game genre. For platformer units in petroleum refining, see Catalytic reforming …   Wikipedia

  • Acer Inc. — Acer Incorporated 宏碁股份有限公司 Type Public company Traded as LSE:  …   Wikipedia

  • Mister Fantastic — Mr. Fantastic Artwork for the cover of Fantastic Four vol. 3, 52 (Apr, 2002). Art by Mike Wieringo. Publication information Publisher …   Wikipedia

  • Olympic Games — 1. Also called Olympian Games. the greatest of the games or festivals of ancient Greece, held every four years in the plain of Olympia in Elis, in honor of Zeus. 2. a modern international sports competition, held once every four years. [1600 10]… …   Universalium

  • House — For other uses, see House (disambiguation). A traditional house in Novosibirsk, Siberia, Russia …   Wikipedia

  • NX bit — The NX bit, which stands for No eXecute, is a technology used in CPUs to segregate areas of memory for use by either storage of processor instructions (or code) or for storage of data, a feature normally only found in Harvard architecture… …   Wikipedia

  • Ladder (computer game) — Ladder is a clone of Donkey Kong , written for the CP/M operating system. Since the screens on these computers only accept text characters and not rendered graphics, the game uses letters, numbers, and symbols lined up to create walls and… …   Wikipedia

  • Stormlord — Infobox VG| title = Stormlord developer = Raffaele Cecco publisher = Hewson Consultants designer = engine = released = 1989 genre = Platform game modes = Single player ratings = platforms = ZX Spectrum, Amstrad CPC, Commodore 64, Amiga, Atari ST …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”