Topic: Inline expansion

Ads by Google

Related Topics

In the News (Tue 31 Mar 15)

inline specifies that it is desirable for the compiler to produce inlinecalls to the functions named by function-names; that is, the code for a specified function-name should be integrated into the calling routine, appearing ``in line'' in place of a procedure call.

inline and notinline declarations otherwise have no effect when the lexically visible definition of function-name is a macro definition.

inline and notinline declarations of functions that appear before the body of a flet or labels form that defines that function are bound declarations.

In computer science, an inline function is a programming language construct used to suggest to a compiler that a particular function be subjected to in-line expansion; that is, it suggests that the compiler insert the complete body of the function in every context where that function is used.

Inlineexpansion is typically used to eliminate the inherent time overhead that occurs in calling a function; it is typically used for functions that execute very quickly, as this overhead is more significant in this case.

Also, in some languages inline functions interact intimately with the compilation model; for example, in C++, it is necessary to define an inline function in every module that uses it, whereas ordinary functions must be defined in only a single module.

Coding Conventions for all Sun Systems Inline templates should be coded as expansions of C- compatible procedure calls, with the difference that the return address cannot be depended upon to be in the expected place, since no call instruction will have been executed.

The floating point stack will be empty at the start of the inlineexpansion template, and must be empty (except for a returned floating point value) at the end.

The compiler cannot inline a function that is in a different translation unit (assuming it does seperate compilation, which AFAIK they all do).

Inline should be used for small definitions, and in most such cases rarely the definition is changed slightly.

The purpose of inline functions is to encourage programmers to decompose their functions into smaller functions and allow the compiler to inline them *automatically*.

www.codecomments.com /message280788.html (2551 words)

5.8 Inline Expansion(Site not responding. Last check: 2007-11-04)

Inlineexpansion is a compiler optimization technique that reduces the overhead of a function call by simply not doing the call: instead, the compiler effectively rewrites the program to appear as though the definition of the called function was inserted at each call site.

When the function expanded inline is large, the program after inlineexpansion may be substantially larger than the original program.

If the program becomes too large, inlineexpansion hurts speed rather than helping it, since hardware resources such as physical memory and cache will be exhausted.

The expansion is performed by the command `M-x eudc-expand-inline' which is available from the `Expand Inline Query' menu item but can also be conveniently bound to a key shortcut (Note: Installation).

After querying the server for the given string, the expansion specified by `eudc-inline-expansion-format' is inserted in the buffer at point.

Inline queries consisting of two words are considered as consisting of a first name followed by a surname.

In the context of functional programming languages, inlineexpansion is often referred to as beta reduction, a term used in the lambda calculus, the formal language underlying these languages.

Inlineexpansion itself is an optimization, since it eliminates call overhead, but it is much more important as an enabling transformation.

That is, once the body of the function is expanded in the context of its call site, often with arguments that may be fixed constants, the code is opened to a variety of new optimizations that were not possible before.

Inlineexpansion or inlining for short is a compiler optimization which "expands" a function call site into the actual implementation of the function which is called, rather than each call transferring control to a common piece of code.

Note that an INLINE proclamation does two things: (1) It tells the compiler to do extra things when it sees the function -definition-, to make it possible to code the function inline.

Note that while implementations are never required to performinlineexpansion of function calls, many implementations that do support inlineexpansion will not be able to respond to local INLINE requests if this technique is not followed.

Rationale: Local INLINE declarations are of little use without some way of alerting the compiler to the possibility of inlineexpansion before the function is compiled.

It doesn't affect other parts of the standard language, in that writing inline on a function does not change how you use the function (for example, you can still take the function's address), and it is not possible for standards-conforming C++ code to programmatically detect whether a given function was declared as inline or not.

Modern compilers are usually better than programmers are at deciding which function calls to inline, including whether to performinlineexpansion of the same function at some call sites but not at others.

Among other things, this compiler is able to inline virtual member functions by assuming that the receiver of the virtual call will be of a given declared type (in order to avoid the cost not only of the function call but of the extra expense of virtual dispatch).

Inline functions must also be defined in header files, or in the same.cpp file where it is being used, since the compiler needs to know the function body to be able to inline it.

You only really want to inline small and common functions thou, so like if you have a func with a few lines that gets called alot, then i define it in the header, as stated in post above, it does have to be in the class def.

The insertion (called inlineexpansion or inlining) occurs only if the compiler's cost/benefit analysis show it to be profitable.

The most important and popular inter-procedural optimization is inlineexpansion, that is replacing the call of a procedure with the procedure's body.

If, after expansion, a procedure is so large (or contains such complicated expressions) that the number of registers provided by the architecture is not enough, then spill code will have to be inserted when we run out of registers.

Hence, the body of a macro is analyzed statically in the environment of the caller, the body of an inlined procedure is analyzed in the environment of the callee (itself).

Once these criteria are met, the compiler picks the routines whose inlineexpansions will provide the greatest benefit to program performance.

The default heuristic always inlines very small functions that meet the minimum inline criteria.

When you do not use profile-guided optimizations with -ip or -ipo, the compiler uses less aggressive inlining heuristics: it inlines a function if the inlineexpansion does not increase the size of the final program.

Semi-inline expansion shares a single copy of a function across all the calls in a component by converting the inlineexpansion into a local function (see section 5.6.) This takes up less space when there are multiple calls, but also provides less opportunity for context dependent optimization.

This mechanism of inlineexpansion combined with local call also allows recursive functions to be inline expanded.

Although recursive functions are often so complex that there is little advantage to semi-inline expansion, it can still be useful in the same sort of cases where normal inlineexpansion is especially advantageous, i.e.