Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Trampoline (computing)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==High-level programming== * As used in some [[Lisp (programming language)|Lisp]] implementations, a trampoline is a loop that iteratively invokes [[thunk (functional programming)|thunk]]-returning functions ([[continuation-passing style]]). A single trampoline suffices 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. Programmers can use trampolined functions to implement [[tail-recursive function]] calls in [[stack-oriented programming language]]s.<ref name="Baker_1995"/> * In [[Java (programming language)|Java]], ''trampoline'' refers to using [[reflection (computer science)|reflection]] to avoid using [[inner class]]es, 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.<ref name="muller"/> * In [[Mono_(software)|Mono Runtime]], trampolines are small, hand-written pieces of assembly code used to perform various tasks.<ref>{{cite web |title=Trampolines |url=https://github.com/mono/website/blob/b4f3b7ad0413743e35e9cfe009302e57c1cd0c61/docs/advanced/runtime/docs/trampolines.md |publisher=Mono Project |date=8 October 2022}}</ref> * When interfacing pieces of code with incompatible [[calling convention]]s, a trampoline is used to convert the caller's convention into the callee's convention. ** In [[embedded system]]s, 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.<ref name="Link"/> ** When passing a [[callback (computer science)|callback]] to a system that expects to call a [[C (programming language)|C]] function, but one wants it to execute the method of a particular instance of a class written in [[C++]], one uses a short ''trampoline'' to convert the C function-calling convention to the C++ method-calling convention. One way of writing such a trampoline is to use a [[thunk (object-oriented programming)|thunk]].<ref name="Stangvik"/> Another method is to use a ''generic listener''.<ref name="muller"/> * In [[Objective-C]], a trampoline is an object returned by a method that captures and [[reification (computer science)|reifies]] all messages sent to it and then "bounces" those messages on to another object, for example in [[higher order message|higher order messaging]].<ref name="Weiher"/> * In the [[GNU Compiler Collection|GCC]] [[compiler]], trampoline refers to a technique for implementing pointers to [[nested function]]s when <code>-ftrampolines</code> option is enabled.<ref name="Stackoverflow"/> 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 function. The function pointer is then simply the address of the trampoline. This avoids having to use [[fat pointer|"fat" function pointer]]s for nested functions which carry both the code address and the static link.<ref name="GCC_Trampolines"/><ref name="GCC_Nested"/><ref name="Breuel"/> This, however, conflicts with the desire to make the stack non-executable for security reasons. * In the [[esoteric programming language]] [[Befunge]], a trampoline is an instruction to skip the next cell in the [[control flow]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)