词条 | Trampoline (computing) |
释义 |
In computer programming, the word trampoline has a number of meanings, and is generally associated with jumps (i.e., moving to different code paths). Low-level programmingTrampolines (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:
High-level programming
Continuation-passing style is a popular intermediate format for compilers of function languages, because many control flow constructs can be elegantly expressed and tail call optimization is easy. When compiling to a language without optimized tail calls, one can avoid stack growth via a technique called trampolining. The idea is to not make the final continuation call inside the function, but to exit and to return the continuation to a trampoline. That trampoline is simply a loop that invokes the returned continuations. Hence, there are no nested function calls and the stack won’t grow. For example, the previous CPS code can be rewritten as follows to support a trampoline.[1]
No-execute stacksSome implementations of trampolines cause a loss of no-execute stacks (NX stack). In the GNU Compiler Collection (GCC) in particular, a nested function builds a trampoline on the stack at runtime, and then calls the nested function through the data on stack. The trampoline requires the stack to be executable. No execute stacks and nested functions are mutually exclusive under GCC. If a nested function is used in the development of a program, then the NX stack is silently lost. GCC offers the -Wtrampoline warning to alert of the condition. Software engineered using secure development lifecycle often do not allow the use of nested functions due to the loss of NX stacks.[12] See also
References1. ^Asynchronous programming and continuation-passing style in JavaScript - 2ality [2][3][4][5][6][7][8][9][10]2. ^1 {{cite web |title=C-Based Toolchain Hardening |author-last1=Walton |author-first1=Jeffrey |author-first2=Jim |author-last2=Manico |author-first3=Kevin |author-last3=Wall |date=2018-03-02 |orig-year=2013 |publisher=The Open Web Application Security Project (OWASP) |url=http://www.owasp.org/index.php/C-Based_Toolchain_Hardening#GCC.2FBinutils |access-date=2018-03-02 |dead-url=no |archive-url=https://web.archive.org/web/20180527105523/https://www.owasp.org/index.php/C-Based_Toolchain_Hardening |archive-date=2018-05-27}} 3. ^1 2 {{cite web |title=Asserting Control Over the GUI: Commands, Defaults, and Resource Bundles |author-first=Hans |author-last=Muller |date=2005-01-31 |website=today.java.net |at=Trampolines |url=http://today.java.net/pub/a/today/2005/01/31/controlGUI.html#trampolines |access-date=2015-11-06 |dead-url=yes |archive-url= |archive-date=}} [https://community.oracle.com/docs/DOC-983126] 4. ^1 {{cite web |author-first=Joseph M. |author-last=Link |title=Trampolines for Embedded Systems: Minimizing interrupt handlers latency |date=2001-09-01 |journal=Dr. Dobb's Journal (DDJ) |url=http://www.drdobbs.com/184404772 |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20180527101123/http://www.drdobbs.com/embedded-systems/trampolines-for-embedded-systems/184404772 |archive-date=2018-05-27}} 5. ^1 {{cite web |title=Thunking in Win32 with C++ |author-first=Einar Otto |author-last=Stangvik |date=2006-08-16 |url=http://www.codeproject.com/Articles/16785/Thunking-in-Win32-Simplifying-Callbacks-to-Non-sta |dead-url=yes |archive-url=https://web.archive.org/web/20121015180318/http://www.codeproject.com/Articles/16785/Thunking-in-Win32-Simplifying-Callbacks-to-Non-sta |archive-date=2012-10-15}} 6. ^1 {{cite web |title=Higher Order Messaging (HOM) |author-first=Marcel |author-last=Weiher |date=2004 |url=http://www.metaobject.com/papers/HOM-Presentation.pdf |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20180527101632/http://www.metaobject.com/papers/HOM-Presentation.pdf |archive-date=2018-05-26}} 7. ^1 {{cite web |title=Trampolines for Nested Functions |at=18.11 |date=2018 |orig-year=2002 |work=Using the GNU Compiler Collection (GCC) |url=http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20180527105902/http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html |archive-date=2018-05-27}} 8. ^1 {{cite web |title=Nested functions |at=6.4 |date=2018 |orig-year=2002 |work=Using the GNU Compiler Collection (GCC) |url=http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20180527105902/http://gcc.gnu.org/onlinedocs/gccint/Trampolines.html |archive-date=2018-05-27}} 9. ^1 {{cite web |author-first=Thomas M. |author-last=Breuel |title=Lexical Closures for C++ |date=2013 |url=http://www-cs-students.stanford.edu/~blynn/files/lexic.pdf |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20171212030215/http://www-cs-students.stanford.edu/~blynn//files/lexic.pdf |archive-date=2017-12-12}} 10. ^1 {{cite web |author=fuz |title=Implementation of nested functions |date=2011-11-18 |work=StackOverflow |url=https://stackoverflow.com/questions/8179521/implementation-of-nested-functions |access-date=2018-05-26 |dead-url=no |archive-url=https://web.archive.org/web/20160329071658/http://stackoverflow.com/questions/8179521/implementation-of-nested-functions |archive-date=2016-03-29}} }} 1 : Computing terminology |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。